{ // 获取包含Hugging Face文本的span元素 const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap'); spans.forEach(span => { if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) { span.textContent = 'AI快站'; } }); }); // 替换logo图片的alt属性 document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => { if (img.alt.match(/Hugging\s*Face/i)) { img.alt = 'AI快站 logo'; } }); } // 替换导航栏中的链接 function replaceNavigationLinks() { // 已替换标记,防止重复运行 if (window._navLinksReplaced) { return; } // 已经替换过的链接集合,防止重复替换 const replacedLinks = new Set(); // 只在导航栏区域查找和替换链接 const headerArea = document.querySelector('header') || document.querySelector('nav'); if (!headerArea) { return; } // 在导航区域内查找链接 const navLinks = headerArea.querySelectorAll('a'); navLinks.forEach(link => { // 如果已经替换过,跳过 if (replacedLinks.has(link)) return; const linkText = link.textContent.trim(); const linkHref = link.getAttribute('href') || ''; // 替换Spaces链接 - 仅替换一次 if ( (linkHref.includes('/spaces') || linkHref === '/spaces' || linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) && linkText !== 'OCR模型免费转Markdown' && linkText !== 'OCR模型免费转Markdown' ) { link.textContent = 'OCR模型免费转Markdown'; link.href = 'https://fast360.xyz'; link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); replacedLinks.add(link); } // 删除Posts链接 else if ( (linkHref.includes('/posts') || linkHref === '/posts' || linkText === 'Posts' || linkText.match(/^s*Postss*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } // 替换Docs链接 - 仅替换一次 else if ( (linkHref.includes('/docs') || linkHref === '/docs' || linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) && linkText !== '模型下载攻略' ) { link.textContent = '模型下载攻略'; link.href = '/'; replacedLinks.add(link); } // 删除Enterprise链接 else if ( (linkHref.includes('/enterprise') || linkHref === '/enterprise' || linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } }); // 查找可能嵌套的Spaces和Posts文本 const textNodes = []; function findTextNodes(element) { if (element.nodeType === Node.TEXT_NODE) { const text = element.textContent.trim(); if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') { textNodes.push(element); } } else { for (const child of element.childNodes) { findTextNodes(child); } } } // 只在导航区域内查找文本节点 findTextNodes(headerArea); // 替换找到的文本节点 textNodes.forEach(node => { const text = node.textContent.trim(); if (text === 'Spaces') { node.textContent = node.textContent.replace(/Spaces/g, 'OCR模型免费转Markdown'); } else if (text === 'Posts') { // 删除Posts文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } else if (text === 'Enterprise') { // 删除Enterprise文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } }); // 标记已替换完成 window._navLinksReplaced = true; } // 替换代码区域中的域名 function replaceCodeDomains() { // 特别处理span.hljs-string和span.njs-string元素 document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换hljs-string类的span中的域名(移除多余的转义符号) document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换pre和code标签中包含git clone命令的域名 document.querySelectorAll('pre, code').forEach(element => { if (element.textContent && element.textContent.includes('git clone')) { const text = element.innerHTML; if (text.includes('huggingface.co')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 处理特定的命令行示例 document.querySelectorAll('pre, code').forEach(element => { const text = element.innerHTML; if (text.includes('huggingface.co')) { // 针对git clone命令的专门处理 if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 特别处理模型下载页面上的代码片段 document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => { const content = container.innerHTML; if (content && content.includes('huggingface.co')) { container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 特别处理模型仓库克隆对话框中的代码片段 try { // 查找包含"Clone this model repository"标题的对话框 const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]'); if (cloneDialog) { // 查找对话框中所有的代码片段和命令示例 const codeElements = cloneDialog.querySelectorAll('pre, code, span'); codeElements.forEach(element => { if (element.textContent && element.textContent.includes('huggingface.co')) { if (element.innerHTML.includes('huggingface.co')) { element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); } // 更精确地定位克隆命令中的域名 document.querySelectorAll('[data-target]').forEach(container => { const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string'); codeBlocks.forEach(block => { if (block.textContent && block.textContent.includes('huggingface.co')) { if (block.innerHTML.includes('huggingface.co')) { block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); }); } catch (e) { // 错误处理但不打印日志 } } // 当DOM加载完成后执行替换 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); }); } else { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); } // 增加一个MutationObserver来处理可能的动态元素加载 const observer = new MutationObserver(mutations => { // 检查是否导航区域有变化 const hasNavChanges = mutations.some(mutation => { // 检查是否存在header或nav元素变化 return Array.from(mutation.addedNodes).some(node => { if (node.nodeType === Node.ELEMENT_NODE) { // 检查是否是导航元素或其子元素 if (node.tagName === 'HEADER' || node.tagName === 'NAV' || node.querySelector('header, nav')) { return true; } // 检查是否在导航元素内部 let parent = node.parentElement; while (parent) { if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') { return true; } parent = parent.parentElement; } } return false; }); }); // 只在导航区域有变化时执行替换 if (hasNavChanges) { // 重置替换状态,允许再次替换 window._navLinksReplaced = false; replaceHeaderBranding(); replaceNavigationLinks(); } }); // 开始观察document.body的变化,包括子节点 if (document.body) { observer.observe(document.body, { childList: true, subtree: true }); } else { document.addEventListener('DOMContentLoaded', () => { observer.observe(document.body, { childList: true, subtree: true }); }); } })(); \\n\") }\n # File.open(save_path, 'w') { |f| f.write(\"---\\nlayout: page\\ntitle: #{title}\\n---\\n\\n#{@contents.xpath('//div[@id=\"bodyContent\"]').to_html}\") }\n end","def save_related\n if self.links.present?\n self.links.each do | link |\n link.parent_type = :action_item\n link.parent_key = self.key\n link.save!\n end\n end\n end","def create\n @link = Link.new(params[:link])\n doc = Pismo::Document.new(@link.url) \n #grab metadata from doc\n if doc.title.nil?\n @link.name = doc.description\n else\n @link.name = doc.title\n end\n @link.favicon = doc.favicon\n\n #FOR OFFLINE USE\n #@link.name = \"Offline Description\"\n\n\n\n\n paginate_all_links\n respond_to do |format|\n if @link.save\n #if using bookmarklet foward back to link you came from\n if request.referer =~ /autosave/\n format.html { redirect_to @link.url }\n else\n #if using frontpage redirect to show all links \n format.html { redirect_to root_url+\"#show-links\", notice: 'Link was successfully created.' }\n end\n format.html { redirect_to @link.url, notice: 'Link was successfully created.' }\n format.json { render json: @link, status: :created, location: @link }\n else\n format.html { render action: \"new\" }\n format.json { render json: @link.errors, status: :unprocessable_entity }\n end\n end\n end","def link(_link, _title, content)\n content.to_s\n end","def write_content\n File.open(absolute_path,'w') do |file|\n file << content if content\n end\n # TODO git functionality\n end","def rewrite\n rewrited_content = parse_for_urls(content)\n parse_for_ids(rewrited_content)\n end","def dump_file_data(io)\n io.write(@link_target)\n end","def htmlUpdateLinks(html)\n #puts \"Page BEFORE URL update: \" + html\n #puts \" \"\n \n # Step 1: Update urls and insert marker\n allPages().each do |page|\n # Replace full urls\n html = html.gsub(\n \"http://www.mosync.com/\" + pageOriginalFile(page), \n \"/NEWDOC_UPDATED_URL_TEMPLATE_DOC_PATH/\" + pageTargetFile(page) + \"/index.html\")\n\t# Replace short urls\n html = html.gsub(\n pageOriginalFile(page), \n \"NEWDOC_UPDATED_URL_TEMPLATE_DOC_PATH/\" + pageTargetFile(page) + \"/index.html\")\n end\n \n # Step 2: Strip off absolute urls and markers\n html = html.gsub(\"http://www.mosync.com/NEWDOC_UPDATED_URL_\", \"\")\n html = html.gsub(\"/NEWDOC_UPDATED_URL_\", \"\")\n html = html.gsub(\"NEWDOC_UPDATED_URL_\", \"\")\n \n # Step 3: Clean up weird urls\n html = html.gsub(\"//index.html\", \"/index.html\")\n html = html.gsub(\"//index.html\", \"/index.html\")\n html = html.gsub(\"index.html/\", \"index.html\")\n html = html.gsub(\"TEMPLATE_DOC_PATH//\", \"TEMPLATE_DOC_PATH/\")\n \n #puts \"Page AFTER URL update: \" + html\n #puts \" \"\n \n html\nend","def rebuild_and_save_links\n fail NoAliasWithHostPresentError if alias_with_host.blank?\n\n conference_id = alias_with_host[/BVA(\\d+)@/, 1]\n link_service = VirtualHearings::LinkService.new(conference_id)\n\n # confirm that we extracted the conference ID correctly,\n # and that the original link was generated with the link service\n if link_service.alias_with_host != alias_with_host ||\n link_service.host_pin != host_pin_long ||\n link_service.guest_pin != guest_pin_long\n fail LinkMismatchError\n end\n\n update!(host_hearing_link: link_service.host_link, guest_hearing_link: link_service.guest_link)\n end","def save_rss_feed content\n File.open(@rss_outfile, \"w\") do |file|\n file.write(content)\n end\n\n File.open(@backup_file, \"w\") do |file|\n file.write(content)\n end\n end","def replace_urls_by_content_assets(content)\n return \"\" unless content\n self.mounting_point.content_assets.each do |path, asset|\n content.gsub!(path, asset.local_filepath)\n end\n content\n end","def transform_links_in_files files\n files.each do |filename|\n text = File.read filename\n content = transform_links_in_text text\n File.open(filename, \"w\") { |file| file << content }\n end\n end","def save(host, uri, content)\n end","def storeRec(link,catg) \n\t\tres_links = Nokogiri::HTML(open(link))\n\t\t\n\t\tres_links.css('div.topSection h3 a').each do |res|\n\t\t\tarr=[]\n\t\t\tarr.push res.text \n\t\t\tarr.push res['href']\t\n\t\t @arr_res.push arr\n\t\t\t@db.execute 'insert into recipe values (?, ? ,?, ?,?,?)', @cnt, arr[0], arr[1],catg,'',''\n\t\t\t@cnt += 1\n\n\t\tend\n\n\tend","def fix_html_link(link)\n return link.gsub(\"documentcloud.org\", \"assets.documentcloud.org\").sub(\"-\", \"/\").gsub(\".html\", \".pdf\").gsub(\"www.\", \"\")\n end","def change_hrefs(html)\n DOM.walk(html) do |node|\n for attr_name in %w{href src}\n attr_obj = node.attributes[attr_name]\n\n # Ignore if its blank\n next if !attr_obj\n\n # URL encode any spaces\n orig_href = attr_obj.to_s.gsub(\" \", \"%20\")\n\n begin\n src = URI(orig_href)\n rescue\n log \"#{orig_href} not a valid URI\"\n next\n end\n\n if internal_link?(src.to_s)\n linked_item = nil\n\n if src.path == \"\"\n # If its just an anchor like '#this' just set to the current file\n linked_item = self\n else\n # Match on the unescaped href\n unescaped_path = URI::unescape(src.path)\n linked_item = get_item(unescaped_path)\n end\n\n # Change link\n if linked_item\n new_path = linked_item.normalized_hashed_path(:relative_to => self)\n new_path = URI(new_path)\n\n if src.fragment\n new_path.fragment = src.fragment\n end\n\n log \"Changing #{src.to_s} to #{new_path.to_s}\"\n attr_obj.content = new_path.to_s\n else\n log \"No item in manifest for #{src}\"\n end\n end\n end\n end\n end","def save\n CONNECTION.execute(\"UPDATE links SET assignment_id = '#{self.assignment_id}', link = '#{self.link}', type = '#{self.type}', WHERE id = #{self.id};\")\n end","def append_link\n url = params[:link]\n @link = Link.new()\n @link.url = url[:url]\n @link.package = Package.find(params[:package_id])\n @link.save()\n # renova a busca para atualizar lista de links.\n @links = Link.find(:all, :conditions => [\"package_id = ?\", params[:package_id]])\n\n flash[:notice] = \"Link was successfully appended.
\" + url[:url]\n redirect_to :action => 'show', :id => params[:package_id]\n end","def save_adword_urls_right(page) \n\t\tadword_urls_right(page).each do |url|\n\t\t\tcreate_adword_url(url, \"right\")\n\t\tend\n\tend","def update\n mod_key(\"permalink\") if data.has_key?(\"permalink\") && @fm_mods[\"permalink\"]\n merge_data\n @content.sub!(FRONTMATTER_REGEXP, to_frontmatter) || @content\n end","def save_current_page(options = {})\r\n default_options = {:replacement => true}\r\n options = default_options.merge(options)\r\n to_dir = options[:dir] || default_dump_dir\r\n\r\n if options[:filename]\r\n file_name = options[:filename]\r\n else\r\n file_name = Time.now.strftime(\"%m%d%H%M%S\") + \".html\"\r\n end\r\n\r\n Dir.mkdir(to_dir) unless File.exists?(to_dir)\r\n file = File.join(to_dir, file_name)\r\n\r\n content = page_source\r\n base_url = @web_browser.context.base_url\r\n current_url = @web_browser.url\r\n current_url =~ /(.*\\/).*$/\r\n current_url_parent = $1\r\n if options[:replacement] && base_url =~ /^http:/\r\n File.new(file, \"w\").puts absolutize_page_nokogiri(content, base_url, current_url_parent)\r\n else\r\n File.new(file, \"w\").puts content\r\n end\r\n\r\n end","def fix_image_links( file_name )\r\n\tlines = File.readlines(file_name)\r\n lines.each do |line| \r\n \tline.gsub!(/processed_files/, File.basename( file_name, '.htm') + \"_files\")\r\n\tend\r\n\tFile.open( file_name, 'w') { |f| f.write lines }\r\nend","def commit_with_content(page, content, log = nil)\n escaped_page = escape(page)\n wiki = File.read(File.join(@data_path, \"text\", \".wiki\"))\n dir = File.join(@root, wiki, escaped_page).untaint\n revision = last_revision(page) + 1\n page_path = File.join(@data_path, \"text\", escaped_page).untaint\n FileUtils.mkdir_p(dir)\n FileUtils.rm_f(File.join(dir, \".removed\"))\n\n File.open(page_path, \"w+\") do |file|\n file.write(content)\n end\n FileUtils.cp(page_path, File.join(dir, revision.to_s))\n end","def href_contents=(value)\n @href_contents = value\n nokogiri_element.value = value\n end","def test_that_sanitize_does_not_mangle_ref_tags_and_such\n text = \"Hi 2007 ho Bar 2006 fum Foo.\"\n content = contents(:cons1)\n otu = Otu.new(:name => 'foo')\n ct = ContentType.new(:name => 'bar')\n content.update_attributes!(:text => text, :otu => otu, :content_type => ct)\n content.reload\n assert_equal(text, content.text)\n end","def save_images(mkd,path)\n regexp_img_links = /!\\[(.*?)\\]\\((.*?)\\)/\n img_dirname = File.basename(path)\n FileUtils.mkdir_p(path,{:mode => 0755})\n client = HTTPClient.new\n mkd.gsub!(regexp_img_links).with_index do |matched,i|\n #save image\n alttext = $1\n imgurl = $2\n $stdout.puts imgurl\n\n ext = File.extname(imgurl).match(/(.*?)(?:\\?.*)?$/)[1]\n filename = (\"%07\\d\" % i)+ext\n filename_fullpath = File.join(path,filename)\n begin\n data=client.get_content(imgurl)\n rescue\n # if we could not get image,we do not edit link.\n next \"![#{alttext}](#{imgurl})\"\n end\n File.open(filename_fullpath,\"w\"){|file| file.write(data)}\n\n #fix the link\n \"![#{alttext}](#{File.join(\"./\",img_dirname,filename)})\"\n end\nend","def save(filename, content)\n\t\t# FIXME - if the file exists, this should bail out\n\t\t\n\t\t# write the contents into the file\n\t\tfile = dir + '/' + filename + '.md'\n\t\tf = File.new(file, \"w\")\n\t\tf.write(content)\n\t\tf.close\n\t\t\n\t\t# return the new file\n\t\treturn page(filename)\n\tend","def save(filename, content)\n\t\t# FIXME - if the file exists, this should bail out\n\t\t\n\t\t# write the contents into the file\n\t\tfile = dir + '/' + filename + '.md'\n\t\tf = File.new(file, \"w\")\n\t\tf.write(content)\n\t\tf.close\n\t\t\n\t\t# return the new file\n\t\treturn page(filename)\n\tend","def make_link(old) File.link(old, path) end","def hyperlink(file, domain, link_dictionary)\n\n link_dictionary = JSON.parse(link_dictionary)\n original_file_values = JSON.parse(File.read(file))\n transformed_file_values = {}\n\n headers_to_skip=[\n \"coinName\",\n \"term\",\n \"hyperlinkOn\",\n \"knownTickers\",\n \"preferredTicker\",\n ]\n original_file_values.each do |header, original_content|\n content = original_content\n unless headers_to_skip.include?(header)\n if content =~ /^https?:\\/\\// \n urls = content.split(\", \").map do |url|\n url = url.strip\n \"[#{url}](#{url})\"\n end\n content = urls.join(\", \")\n else \n link_dictionary.each do |term, link_address|\n if file.match(/#{link_address}\\.json$/) # if this term would hyper link to itself\n # put a \"!!\" in front of it so that it doesn't get picked up by any other superstring matches\n content = content.gsub(\n /(^|\\s|\\()(#{term})($|\\.|\\)|\\s|')/i, \n \"\\\\1!!\\\\2\\\\3\"\n ) \n else\n content = content.sub( # only hyperlink the first occurrence of a given within a section\n /(^|\\s|\\()(#{term})($|\\.|\\)|\\s|')/i, # match the term if it's preceded+followed by a space, period, \\n etc.\n \"\\\\1[\\\\2](#{domain}#{link_address})\\\\3\"\n )\n end\n end\n content = content.gsub(/!!/, \"\") # remove all \"!!\" used to remove self linking terms from the link pool\n end\n end\n transformed_file_values[header] = content\n end\n return transformed_file_values\nend","def link!\n self.linkbutton = true\n self.save\n self.linkbutton\n end","def save_to(path); end","def convert(content)\n button_parts = content.match('div class=\"content-edit-page\"')\n source_parts = content.match(/\\(source\\)<\\/a>/)\n if button_parts == nil and source_parts != nil\n url = source_parts[1]\n button_start = '
SHORT_URL + \"/\" + Base32::Crockford.encode(link.id)\n end","def replace(id, new_content)\n File.write(find(id), new_content)\n end","def save_content(title, content)\n\tFile.open(\"pages/#{title}.txt\" , \"w\") do |file|\n\t file.print(content)\n end \t\t\nend","def save\n return if @content.nil?\n put_rest \"extra/#{@name}\", @content, :content_type => \"application/octet-stream\"\n end","def update_link!(link)\n key = link.key\n val = link.val\n @store.remove(key)\n link = @store.append(key,val) #this is where you move the link to end of list\n @map[key] = link\n end","def store_path_links_to(path, links)\n return if links.empty?\n redis.sadd path_links_to_key(path), links\n end","def reformat_link\n reg = /^https?:\\/\\//\n link = self.link\n if link.present? && !link.match(reg)\n link.insert(0,\"http://\")\n end\n self.link = link\n end","def fetch_and_store!\n # Get links from page\n # Download files from links concurrently\n download self.extract!\n end","def write_pending_links(links = nil)\n\t\tdebug.print(3, \"Saving links to file\", File.basename(__FILE__), __LINE__)\n\t\t\n\t\t#moverdatawriter.write_marshal_dump( fail_queue)\n\t\tpending_links = links || get_unfinished_links()\n\t\t###binding.pry\n\t\tlinkw.write_array(pending_links)\n\n\tend","def store_path_linked_to_from(path, links)\n return if links.empty?\n redis.sadd path_linked_to_from_key(path), links\n end","def update_link\n # if save\n # true\n # else\n sr_clone = SitescanCommon::SearchResult.includes(:search_product)\n .references(:search_product).where.not(id: id).find_by_link link\n if sr_clone\n if search_product and search_product.product\n sr_clone.destroy\n true\n elsif search_product and sr_clone.search_product and\n sr_clone.search_product.product or\n not search_product and sr_clone.search_product\n destroy\n false\n else\n sr_clone.destroy\n true\n end\n end\n true\n # end\n end","def write_urls_db()\n end","def save(path)\n update\n Zip::OutputStream.open(path) do |out|\n zip.each do |entry|\n out.put_next_entry(entry.name)\n\n if @replace[entry.name]\n out.write(@replace[entry.name])\n else\n out.write(zip.read(entry.name))\n end\n end\n end\n zip.close\n end","def save\n es = EsClient.new(YAML_CONFIG, nil)\n es.write(type: 'email_link',\n body_hash: self.as_hash)\n end","def save\n es = EsClient.new(YAML_CONFIG, nil)\n es.write(type: 'email_link',\n body_hash: self.as_hash)\n end","def replace_asset_urls(content)\n return '' if content.blank?\n\n _content = content.dup\n\n content.force_encoding('utf-8').scan(REGEX).map do |match|\n url, type, filename = match[0], match[2], match[5]\n folder = case type\n when 'assets', 'pages' then File.join('samples', \"_#{env}\", type)\n when 'theme' then $4\n when /\\Acontent_entry/ then File.join('samples', \"_#{env}\", 'content_entries')\n end\n\n Thread.new do\n if filepath = write_asset(url, File.join(path, 'public', folder, filename))\n [url, File.join('', folder, File.basename(filepath)).to_s]\n else\n [url, '']\n end\n end\n end.map(&:value).each do |(url, replacement)|\n _content.gsub!(url, replacement)\n end\n\n _content\n end","def save\n save_to_file(@output_file, @contents)\n end","def link(link, title, content)\n \"#{content} (#{link})\"\n end","def cache_urls(doc, latex=false)\n doc.tap do |text|\n text.gsub!(/\\\\(href|url){(.*?)}/) do\n command, url = $1, $2\n key = digest(url)\n literal_cache[key] = url\n command == 'url' ? \"\\\\href{#{key}}{#{url}}\" : \"\\\\href{#{key}}\"\n end\n end\n end","def insert_link (fileArray, linkName, utilHash)\n\nend","def update_hrefs(css_selector)\n @doc.css(css_selector + ' a').each do |a|\n\n href = Flatfish::Url.absolutify(a['href'], @cd)\n\n # Create tokens for internal links and images/files\n if href =~ /#{@accepted_domain}/\n # NB: the brackets will be URL encoded, so we are flagging them here and gsubbing them before saving\n if @file_whitelist.include?(File.extname(href))\n media = get_media(href)\n href = \"[FLATFISHmedia:#{media.id}FLATFISH]\"\n elsif href !~ /mailto:/\n link = Flatfish::Link.find_or_create_by(url: href)\n href = \"[FLATFISHlink:#{link.id}FLATFISH]\"\n end\n end\n a['href'] = href\n end\n end","def save_to(path)\n update\n Zip::OutputStream.open(path) do |out|\n zip.each do |entry|\n next unless entry.file?\n\n out.put_next_entry(entry.name)\n\n if @replace[entry.name]\n out.write(@replace[entry.name])\n else\n out.write(zip.read(entry.name))\n end\n end\n end\n end","def convert _obj\n if _obj.figures.length == 1 && _obj.figures.first.link.present?\n _obj.figures.first.link = _obj.figures.first.link.gsub(\"http://\", \"https://\")\n _obj.save!\n end\nend","def update!\n open(link)\n end","def link(link, title, content)\n link = OodAppkit.files.api(path: @app_path.to_s + '/' + link).to_s if @app_path && relative?(link)\n return \"#{content}\" unless id_link?(link)\n return \"#{content}\"\n end","def inline_auto_link(text)\n text.gsub!(AUTO_LINK_RE) do\n all, leading, proto, url, post = $&, $1, $2, $3, $6\n if leading =~ /=]?/\n # don't replace URL's that are already linked\n # and URL's prefixed with ! !> !< != (textile images)\n all\n else\n # Idea below : an URL with unbalanced parethesis and\n # ending by ')' is put into external parenthesis\n if ( url[-1]==?) and ((url.count(\"(\") - url.count(\")\")) < 0 ) )\n url=url[0..-2] # discard closing parenth from url\n post = \")\"+post # add closing parenth to post\n end\n tag = content_tag('a', proto + url, :href => \"#{proto==\"www.\"?\"http://www.\":proto}#{url}\", :class => 'external')\n %(#{leading}#{tag}#{post})\n end\n end\n end","def update_link\n tree.new_branch_in available_folder\n FileUtils.rm current_directory\n link_target\n end","def parse_link; end","def save_content(title, content)\n File.open(\"pages/#{title}.txt\", \"w\") do |file|\n file.print(content)\n end\nend","def save_nonadword_urls(page)\n\t\tnonadword_urls(page).each do |url|\n\t\t\tcreate_nonadword_url(url, \"center\")\n\t\tend\n\tend","def make_link( old ) File.link( old, expand_tilde ) end","def handle_item item\n separator item.link\n file_handle.write(open(item.link).read)\n file_handle.write(\"\\n\\n\")\n end","def save_and_open\n return unless File.exist?(session.saved_page_dir)\n\n filename = \"#{session.saved_page_dir}/webrat-#{Time.now.to_i}.html\"\n \n File.open(filename, \"w\") do |f|\n f.write rewrite_css_and_image_references(session.response_body)\n end\n\n open_in_browser(filename)\n end","def update; @doc = get(link('self')); nil; end","def update; @doc = get(link('self')); nil; end","def save(seo)\n @database.save_doc(seo.merge('_id' => seo[:url]))\n seo\n end","def replace(entry, src_path); end","def export_link(builder, link)\n folders = []\n folders << link.folder.name if link.folder\n folders = folders + link.keywords if link.keywords.present?\n builder.bookmarks << Markio::Bookmark.create({\n title: link.name,\n href: link.url,\n folders: folders.present? ? folders : nil,\n add_date: link.saved_at\n })\n end","def update_paths_linked_to_from_path(document)\n document.domain_specific_paths.each do |url|\n link_uri_path = normalize_path Addressable::URI.parse(url.strip).path\n document_uri_path = normalize_path document.uri.path\n next if link_uri_path == document_uri_path\n\n store_path link_uri_path\n store_path_linked_to_from(link_uri_path, [document_uri_path])\n end\n end","def update_link(link)\n if i = find_index { |l| l.rel.to_s == link.rel.to_s }\n return self[i] = link\n end\n self << link\n end","def unlink!\n parse \n @tags.each do |tag|\n @doc.xpath(\"//a[ends_with(@href,'#{tag}')]\", EndsWithFilter.new).each do |element|\n element.swap(element.children)\n end\n end\n output = @doc.xpath(\"/#{@wrap_tag}/body/p\").inner_html\n output = @doc.xpath(\"/#{@wrap_tag}/body\").inner_html if output == \"\"\n output\n end"],"string":"[\n \"def update_references_html\\r\\n fixup_page\\r\\n html = display_content\\r\\n includes = find_includes(html)\\r\\n page_names = find_referenced_names(html)\\r\\n save_references(page_names, includes)\\r\\n end\",\n \"def save_file path, content\\n\\t\\t\\t\\tif @fix\\n\\t\\t\\t\\t\\tcontent = content.gsub \\\"url('/\\\", \\\"url('\\\"\\n\\t\\t\\t\\t\\tcontent = content.gsub 'src=\\\"/', 'src=\\\"'\\n\\t\\t\\t\\t\\tcontent = content.gsub 'href=\\\"/', 'href=\\\"'\\n\\t\\t\\t\\tend\\n\\t\\t\\t\\tFile.open(path, 'w+') { |f| f.puts content }\\n\\t\\t\\tend\",\n \"def save\\n @link.Save\\n end\",\n \"def save_posted_link( )\\n\\t\\n\\tdata_file = \\\"posted_link.dat\\\"\\n\\tfp = File.open(data_file,\\\"a\\\")\\n\\t$link_posted.keys.each { |link|\\n\\t\\tfp.puts( link )\\n\\t}\\n\\tfp.close()\\t\\nend\",\n \"def convert_links\\n\\n # fetch leaf content\\n c = self.content\\n\\n # regexps\\n # url = /( |^)http:\\\\/\\\\/([^\\\\s]*\\\\.[^\\\\s]*)( |$)/\\n tag_regex = /( |^)#(\\\\w+)( |$)/\\n user_regex = /( |^)@(\\\\w+)( |$)/\\n \\n #TODO: make sure no one is typing javascript into the field **IMPORTANT**\\n\\n #replace #tags with links to that tag search\\n while c =~ tag_regex\\n c.gsub! \\\"##{$2}\\\", \\\"##{$2}\\\"\\n self.has_tags = true\\n end\\n\\n #replace @usernames with links to that user, if user exists\\n while c =~ user_regex\\n user = $2\\n if User.find(user)\\n c.sub! \\\"@#{$2}\\\", \\\"@#{$2}\\\"\\n end\\n end\\n\\n #replace urls with links\\n #while c =~ url\\n #name = $2\\n #c.sub! /( |^)http:\\\\/\\\\/#{name}( |$)/, \\\" #{name} \\\"\\n #end\\n\\n self.content = c\\n\\n end\",\n \"def store_article_text(entry)\\n puts \\\"storing data\\\"\\n if(entry.link != '#')\\n \\n # Get html from link\\n response = Net::HTTP.get(URI.parse(entry.link))\\n if(response.downcase.include?(\\\"

moved permanently

\\\"))\\n html = Nokogiri::HTML(response, nil, 'UTF-8')\\n tag = html.css(\\\"a\\\")\\n link = tag.attribute('href')\\n response = Net::HTTP.get(URI.parse(link))\\n end\\n \\n # Use readability to find text from html\\n data = Readability::Document.new(response || \\\"\\\")\\n if(data.content == nil || data.content.length < 15)\\n new_data = entry.description\\n else\\n new_data = data.content.gsub(/<[^>]+>/,\\\"\\\").squeeze(\\\" \\\").strip.toutf8 || \\\"\\\"\\n end\\n \\n else\\n new_data = entry.description\\n end\\n \\n # Save data if new\\n if(!entry.data || entry.data != new_data)\\n entry.data = new_data\\n return true\\n end\\n return false\\nend\",\n \"def save_plagiarism_html(match_link, html)\\n File.open(path_to_plagarism_html(match_link), 'w') do |out_file|\\n out_file.puts html\\n end\\n end\",\n \"def save_results\\n unless self.options[:disable_save] == true\\n self.final_path.inject(nil) do |previous, link|\\n unless previous.nil? || previous.element.bacon_link.present?\\n previous.element.update_attribute(:bacon_link_id, link.element.id)\\n end\\n link\\n end\\n end\\n\\n self.final_path\\n end\",\n \"def fixup_page\\r\\n html = content\\r\\n if html.gsub!(/(href|src)=(['\\\"])..\\\\/..\\\\//, '\\\\1=\\\\2/')\\r\\n content = html\\r\\n save!\\r\\n end\\r\\n end\",\n \"def refetch\\n resolver = Link.select_resolver(url)\\n canonical_url = resolver.fetch_canonical_url(url)\\n\\n # 現在のURLが取得したcanonical_urlとは異なるのに、レコードにその記録がある場合は、\\n # 保存するとURL重複となるためスルーする\\n return if url != canonical_url && Link.find_by(url: canonical_url)\\n\\n page = Nokogiri::HTML.parse(open(canonical_url).read)\\n update_attributes(resolver.new(canonical_url, page).fetch)\\n save\\n end\",\n \"def save\\n CONNECTION.execute(\\\"UPDATE links SET link = '#{self.link}', relative_assignment = '#{self.relative_assignment}' WHERE id = #{self.id};\\\")\\n end\",\n \"def save_as_field(field, save_path = false)\\n lambda do |release, links|\\n links.map do |link|\\n result = {\\n link: link,\\n field => link.content.delete('/')\\n }\\n result[:repo_url] = \\\"#{release[:url]}#{link[:href]}\\\" if save_path\\n result\\n end\\n end\\n end\",\n \"def rewrite(link)\\n return link unless link =~ /^https\\\\:\\\\/\\\\/github/\\n @downloads.push(link)\\n File.basename(link)\\n end\",\n \"def save_information(keyword, page)\\n\\t\\t\\tkeyword.save_adword_urls(page)\\n\\t\\t\\tkeyword.save_nonadword_urls(page)\\n \\tend\",\n \"def add_link\\n @bib.link.each do |l|\\n case l.type&.downcase\\n when \\\"doi\\\" then @item.doi = l.content\\n when \\\"file\\\" then @item.file2 = l.content\\n when \\\"src\\\" then @item.url = l.content\\n end\\n end\\n end\",\n \"def driveNameReplace(original, name)\\n folder_path = File.dirname(__FILE__) + \\\"/Cyclo\\\"\\n Dir.glob(folder_path + \\\"/*\\\").sort.each do |path|\\n f = File.open(path, \\\"r+\\\")\\n doc = Nokogiri::XML(f)\\n doc.search(\\\".//image\\\").each do |node|\\n #puts node['href']\\n newLink = node['href'].split('/').last\\n #complete = \\\"file:///Users/freelance/Google Drive/Specialized Docs/_photosBIKE/#{newLink}\\\"\\n complete = \\\"file:///Users/freelance/Google Drive/Specialized Docs/dump_output/#{newLink}\\\"\\n puts complete\\n #node['href'] = node['href'].gsub(original, name)\\n node['href'] = complete\\n end\\n f.close()\\n o = File.new(path, \\\"w\\\")\\n o.write(doc)\\n o.close()\\n\\n end\\nend\",\n \"def save(link_hash)\\n setup_file\\n \\n link_database = File.open('link_db.txt').read\\n existing_links = JSON.parse(link_database) \\n # link_database.close\\n \\n existing_links << link_hash\\n link_json = JSON.generate(existing_links)\\n \\n File.open('link_db.txt', 'w+') do |link_database|\\n link_database.write(link_json)\\n end\\nend\",\n \"def saveurl\\n url_str = link_params[:url]\\n url_str.insert(0, 'http://') if url_str.match('^http').nil?\\n \\n annotations = get_annotations(url_str)\\n \\n url = Url.find_by_url(url_str)\\n if url.nil?\\n url = Url.new({:url => link_params[:url], :icon => annotations[:icon]})\\n if !url.save\\n render :status => 404\\n end\\n else\\n Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\\n end\\n\\n @bookmark = Bookmark.new({:url => url, :title => annotations[:title], :description => annotations[:desc], :user => current_user})\\n\\n @share_with_group = Group.find(params[:id]) if params[:id]\\n\\n annotations[:keywords].each do |tag|\\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\\n @tag = Tag.new\\n @tag.tagname = tag.strip.gsub(' ','-').downcase\\n @bookmark.tags << @tag\\n else\\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\\n end\\n end\\n\\n respond_to do |format|\\n format.html { render action: 'bookmark_form' }\\n format.js\\n end\\n end\",\n \"def fix_ckeditor_attachment_paths\\n\\t if self.content.include?(\\\"_cke_saved_href\\\")\\n\\t \\tself.content.gsub!(/href=\\\\\\\"javascript:void\\\\(0\\\\)\\\\/\\\\*\\\\d+\\\\*\\\\/\\\\\\\"/, '')\\n\\t \\tself.content.gsub!(/_cke_saved_href/, 'href')\\n\\t end\\n\\tend\",\n \"def save_web_content\\n begin\\n body = Mechanize.new.get(self.discussion).body\\n url_body = HtmlContent.create(:discussion_id=>self.id,:content=>body)\\n rescue => e\\n end if self.discussion_type == \\\"URL\\\"\\n end\",\n \"def save_adword_urls(page)\\n\\t\\tsave_adword_urls_right(page) \\n\\t\\tsave_adword_urls_top(page)\\n\\tend\",\n \"def pdef_replace_link(txt)\\n # NOTE: it works with only link\\n link_url = nil\\n str_after = ''\\n str_before = ''\\n aa = txt.split('link:')\\n if aa.size == 2\\n aa[1].lstrip!\\n bb = aa[1].index(/[\\\\)\\\\, ]/)\\n link_url = aa[1][0..bb - 1]\\n str_after = aa[1][bb..-1]\\n str_before = aa[0]\\n end\\n\\n if link_url\\n str_link = \\\"#{link_url.gsub(\\\"http://\\\", \\\"\\\")}\\\"\\n str_res = str_before + str_link + str_after\\n else\\n return txt\\n end\\n end\",\n \"def save(link_hash)\\n setup_file\\n \\n link_database = File.open('link_db.txt').read\\n existing_links = JSON.parse(link_database)\\n # link_database.close\\n \\n existing_links << link_hash\\n link_json = JSON.generate(existing_links)\\n \\n\\n\\n File.open('link_db.txt', 'w+') do |link_database|\\n link_database.write(link_json)\\n end\\nend\",\n \"def fix_ckeditor_attachment_paths\\n\\t if self.contents.include?(\\\"_cke_saved_href\\\")\\n\\t \\tself.contents.gsub!(/href=\\\\\\\"javascript:void\\\\(0\\\\)\\\\/\\\\*\\\\d+\\\\*\\\\/\\\\\\\"/, '')\\n\\t \\tself.contents.gsub!(/_cke_saved_href/, 'href')\\n\\t end\\n\\tend\",\n \"def fix_ckeditor_attachment_paths\\n\\t if self.contents.include?(\\\"_cke_saved_href\\\")\\n\\t \\tself.contents.gsub!(/href=\\\\\\\"javascript:void\\\\(0\\\\)\\\\/\\\\*\\\\d+\\\\*\\\\/\\\\\\\"/, '')\\n\\t \\tself.contents.gsub!(/_cke_saved_href/, 'href')\\n\\t end\\n\\tend\",\n \"def create\\n\\n @link = Link.new(params[:link])\\n @link.resource_id = @resource.id\\n \\n if !@link.link.include? \\\"http://\\\"\\n @link.link = \\\"http://\\\" + @link.link\\n end\\n\\n\\n @resource.attachment = @link\\n @resource.save\\n\\n @link.save\\n\\n\\n\\n respond_to do |format|\\n if @link.update_attributes(params[:text]) && @resource.update_attributes(params[:resource])\\n format.js\\n end\\n end \\n end\",\n \"def save_locally(dir)\\n FileUtils.mkdir_p(dir) unless File.exists? dir\\n \\n # remove HTML BASE tag if it exists\\n @contents.xpath('//base').each { |t| t.remove }\\n # remove head tag\\n @contents.xpath('//head').each { |t| t.remove }\\n # remove link tags\\n @contents.xpath('//link').each { |t| t.remove }\\n # remove script tags\\n @contents.xpath('//script').each { |t| t.remove }\\n # remove comments\\n @contents.xpath('//comment()').each { |t| t.remove }\\n # remove mediawiki meta tag\\n @contents.xpath('//meta').each { |t| t.remove if t['name'] == \\\"generator\\\" }\\n # remove sitesub h3 tag\\n @contents.xpath('//h3').each { |t| t.remove if t['id'] == \\\"siteSub\\\" }\\n\\n # get lastmod/viewcount values\\n @contents.xpath('//li').each do |t|\\n if t['id'] == \\\"lastmod\\\"\\n @lastmod = t.text.strip\\n end\\n if t['id'] == \\\"viewcount\\\"\\n @viewcount = t.text.strip\\n end\\n end\\n\\n # remove unneeded divs\\n @contents.xpath('//div').each do |t|\\n t.remove if t['id'] == \\\"column-one\\\"\\n t.remove if t['id'] == \\\"footer\\\"\\n t.remove if t['id'] == \\\"catlinks\\\"\\n t.remove if t['id'] == \\\"contentSub\\\"\\n t.remove if t['id'] == \\\"jump-to-nav\\\"\\n t.remove if t['class'] == \\\"printfooter\\\"\\n t.remove if t['class'] == \\\"visualClear\\\"\\n end\\n\\n if @main_page == true\\n save_path = File.join(dir, \\\"index\\\")\\n title = 'Dublin Core Metadata Initiative Media-Wiki Archive'\\n else\\n save_path = File.join(dir, File.basename(uri.to_s))\\n title = File.basename(uri.to_s).gsub(\\\"_\\\", \\\" \\\")\\n end\\n save_path += '.html' if save_path !~ /\\\\.((html?)|(txt))$/\\n File.open(save_path, 'w') { |f| f.write(\\\"\\\\n\\\\n\\\\n\\\\n\\\\n#{title}\\\\n\\\\n\\\\n

This is an archived MediaWiki page.
#{@lastmod}
#{@viewcount}

\\\\n#{@contents.xpath('//div[@id=\\\"bodyContent\\\"]').to_html}\\\\n\\\\n\\\") }\\n # File.open(save_path, 'w') { |f| f.write(\\\"---\\\\nlayout: page\\\\ntitle: #{title}\\\\n---\\\\n\\\\n#{@contents.xpath('//div[@id=\\\"bodyContent\\\"]').to_html}\\\") }\\n end\",\n \"def save_related\\n if self.links.present?\\n self.links.each do | link |\\n link.parent_type = :action_item\\n link.parent_key = self.key\\n link.save!\\n end\\n end\\n end\",\n \"def create\\n @link = Link.new(params[:link])\\n doc = Pismo::Document.new(@link.url) \\n #grab metadata from doc\\n if doc.title.nil?\\n @link.name = doc.description\\n else\\n @link.name = doc.title\\n end\\n @link.favicon = doc.favicon\\n\\n #FOR OFFLINE USE\\n #@link.name = \\\"Offline Description\\\"\\n\\n\\n\\n\\n paginate_all_links\\n respond_to do |format|\\n if @link.save\\n #if using bookmarklet foward back to link you came from\\n if request.referer =~ /autosave/\\n format.html { redirect_to @link.url }\\n else\\n #if using frontpage redirect to show all links \\n format.html { redirect_to root_url+\\\"#show-links\\\", notice: 'Link was successfully created.' }\\n end\\n format.html { redirect_to @link.url, notice: 'Link was successfully created.' }\\n format.json { render json: @link, status: :created, location: @link }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @link.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def link(_link, _title, content)\\n content.to_s\\n end\",\n \"def write_content\\n File.open(absolute_path,'w') do |file|\\n file << content if content\\n end\\n # TODO git functionality\\n end\",\n \"def rewrite\\n rewrited_content = parse_for_urls(content)\\n parse_for_ids(rewrited_content)\\n end\",\n \"def dump_file_data(io)\\n io.write(@link_target)\\n end\",\n \"def htmlUpdateLinks(html)\\n #puts \\\"Page BEFORE URL update: \\\" + html\\n #puts \\\" \\\"\\n \\n # Step 1: Update urls and insert marker\\n allPages().each do |page|\\n # Replace full urls\\n html = html.gsub(\\n \\\"http://www.mosync.com/\\\" + pageOriginalFile(page), \\n \\\"/NEWDOC_UPDATED_URL_TEMPLATE_DOC_PATH/\\\" + pageTargetFile(page) + \\\"/index.html\\\")\\n\\t# Replace short urls\\n html = html.gsub(\\n pageOriginalFile(page), \\n \\\"NEWDOC_UPDATED_URL_TEMPLATE_DOC_PATH/\\\" + pageTargetFile(page) + \\\"/index.html\\\")\\n end\\n \\n # Step 2: Strip off absolute urls and markers\\n html = html.gsub(\\\"http://www.mosync.com/NEWDOC_UPDATED_URL_\\\", \\\"\\\")\\n html = html.gsub(\\\"/NEWDOC_UPDATED_URL_\\\", \\\"\\\")\\n html = html.gsub(\\\"NEWDOC_UPDATED_URL_\\\", \\\"\\\")\\n \\n # Step 3: Clean up weird urls\\n html = html.gsub(\\\"//index.html\\\", \\\"/index.html\\\")\\n html = html.gsub(\\\"//index.html\\\", \\\"/index.html\\\")\\n html = html.gsub(\\\"index.html/\\\", \\\"index.html\\\")\\n html = html.gsub(\\\"TEMPLATE_DOC_PATH//\\\", \\\"TEMPLATE_DOC_PATH/\\\")\\n \\n #puts \\\"Page AFTER URL update: \\\" + html\\n #puts \\\" \\\"\\n \\n html\\nend\",\n \"def rebuild_and_save_links\\n fail NoAliasWithHostPresentError if alias_with_host.blank?\\n\\n conference_id = alias_with_host[/BVA(\\\\d+)@/, 1]\\n link_service = VirtualHearings::LinkService.new(conference_id)\\n\\n # confirm that we extracted the conference ID correctly,\\n # and that the original link was generated with the link service\\n if link_service.alias_with_host != alias_with_host ||\\n link_service.host_pin != host_pin_long ||\\n link_service.guest_pin != guest_pin_long\\n fail LinkMismatchError\\n end\\n\\n update!(host_hearing_link: link_service.host_link, guest_hearing_link: link_service.guest_link)\\n end\",\n \"def save_rss_feed content\\n File.open(@rss_outfile, \\\"w\\\") do |file|\\n file.write(content)\\n end\\n\\n File.open(@backup_file, \\\"w\\\") do |file|\\n file.write(content)\\n end\\n end\",\n \"def replace_urls_by_content_assets(content)\\n return \\\"\\\" unless content\\n self.mounting_point.content_assets.each do |path, asset|\\n content.gsub!(path, asset.local_filepath)\\n end\\n content\\n end\",\n \"def transform_links_in_files files\\n files.each do |filename|\\n text = File.read filename\\n content = transform_links_in_text text\\n File.open(filename, \\\"w\\\") { |file| file << content }\\n end\\n end\",\n \"def save(host, uri, content)\\n end\",\n \"def storeRec(link,catg) \\n\\t\\tres_links = Nokogiri::HTML(open(link))\\n\\t\\t\\n\\t\\tres_links.css('div.topSection h3 a').each do |res|\\n\\t\\t\\tarr=[]\\n\\t\\t\\tarr.push res.text \\n\\t\\t\\tarr.push res['href']\\t\\n\\t\\t @arr_res.push arr\\n\\t\\t\\t@db.execute 'insert into recipe values (?, ? ,?, ?,?,?)', @cnt, arr[0], arr[1],catg,'',''\\n\\t\\t\\t@cnt += 1\\n\\n\\t\\tend\\n\\n\\tend\",\n \"def fix_html_link(link)\\n return link.gsub(\\\"documentcloud.org\\\", \\\"assets.documentcloud.org\\\").sub(\\\"-\\\", \\\"/\\\").gsub(\\\".html\\\", \\\".pdf\\\").gsub(\\\"www.\\\", \\\"\\\")\\n end\",\n \"def change_hrefs(html)\\n DOM.walk(html) do |node|\\n for attr_name in %w{href src}\\n attr_obj = node.attributes[attr_name]\\n\\n # Ignore if its blank\\n next if !attr_obj\\n\\n # URL encode any spaces\\n orig_href = attr_obj.to_s.gsub(\\\" \\\", \\\"%20\\\")\\n\\n begin\\n src = URI(orig_href)\\n rescue\\n log \\\"#{orig_href} not a valid URI\\\"\\n next\\n end\\n\\n if internal_link?(src.to_s)\\n linked_item = nil\\n\\n if src.path == \\\"\\\"\\n # If its just an anchor like '#this' just set to the current file\\n linked_item = self\\n else\\n # Match on the unescaped href\\n unescaped_path = URI::unescape(src.path)\\n linked_item = get_item(unescaped_path)\\n end\\n\\n # Change link\\n if linked_item\\n new_path = linked_item.normalized_hashed_path(:relative_to => self)\\n new_path = URI(new_path)\\n\\n if src.fragment\\n new_path.fragment = src.fragment\\n end\\n\\n log \\\"Changing #{src.to_s} to #{new_path.to_s}\\\"\\n attr_obj.content = new_path.to_s\\n else\\n log \\\"No item in manifest for #{src}\\\"\\n end\\n end\\n end\\n end\\n end\",\n \"def save\\n CONNECTION.execute(\\\"UPDATE links SET assignment_id = '#{self.assignment_id}', link = '#{self.link}', type = '#{self.type}', WHERE id = #{self.id};\\\")\\n end\",\n \"def append_link\\n url = params[:link]\\n @link = Link.new()\\n @link.url = url[:url]\\n @link.package = Package.find(params[:package_id])\\n @link.save()\\n # renova a busca para atualizar lista de links.\\n @links = Link.find(:all, :conditions => [\\\"package_id = ?\\\", params[:package_id]])\\n\\n flash[:notice] = \\\"Link was successfully appended.
\\\" + url[:url]\\n redirect_to :action => 'show', :id => params[:package_id]\\n end\",\n \"def save_adword_urls_right(page) \\n\\t\\tadword_urls_right(page).each do |url|\\n\\t\\t\\tcreate_adword_url(url, \\\"right\\\")\\n\\t\\tend\\n\\tend\",\n \"def update\\n mod_key(\\\"permalink\\\") if data.has_key?(\\\"permalink\\\") && @fm_mods[\\\"permalink\\\"]\\n merge_data\\n @content.sub!(FRONTMATTER_REGEXP, to_frontmatter) || @content\\n end\",\n \"def save_current_page(options = {})\\r\\n default_options = {:replacement => true}\\r\\n options = default_options.merge(options)\\r\\n to_dir = options[:dir] || default_dump_dir\\r\\n\\r\\n if options[:filename]\\r\\n file_name = options[:filename]\\r\\n else\\r\\n file_name = Time.now.strftime(\\\"%m%d%H%M%S\\\") + \\\".html\\\"\\r\\n end\\r\\n\\r\\n Dir.mkdir(to_dir) unless File.exists?(to_dir)\\r\\n file = File.join(to_dir, file_name)\\r\\n\\r\\n content = page_source\\r\\n base_url = @web_browser.context.base_url\\r\\n current_url = @web_browser.url\\r\\n current_url =~ /(.*\\\\/).*$/\\r\\n current_url_parent = $1\\r\\n if options[:replacement] && base_url =~ /^http:/\\r\\n File.new(file, \\\"w\\\").puts absolutize_page_nokogiri(content, base_url, current_url_parent)\\r\\n else\\r\\n File.new(file, \\\"w\\\").puts content\\r\\n end\\r\\n\\r\\n end\",\n \"def fix_image_links( file_name )\\r\\n\\tlines = File.readlines(file_name)\\r\\n lines.each do |line| \\r\\n \\tline.gsub!(/processed_files/, File.basename( file_name, '.htm') + \\\"_files\\\")\\r\\n\\tend\\r\\n\\tFile.open( file_name, 'w') { |f| f.write lines }\\r\\nend\",\n \"def commit_with_content(page, content, log = nil)\\n escaped_page = escape(page)\\n wiki = File.read(File.join(@data_path, \\\"text\\\", \\\".wiki\\\"))\\n dir = File.join(@root, wiki, escaped_page).untaint\\n revision = last_revision(page) + 1\\n page_path = File.join(@data_path, \\\"text\\\", escaped_page).untaint\\n FileUtils.mkdir_p(dir)\\n FileUtils.rm_f(File.join(dir, \\\".removed\\\"))\\n\\n File.open(page_path, \\\"w+\\\") do |file|\\n file.write(content)\\n end\\n FileUtils.cp(page_path, File.join(dir, revision.to_s))\\n end\",\n \"def href_contents=(value)\\n @href_contents = value\\n nokogiri_element.value = value\\n end\",\n \"def test_that_sanitize_does_not_mangle_ref_tags_and_such\\n text = \\\"Hi 2007 ho Bar 2006 fum Foo.\\\"\\n content = contents(:cons1)\\n otu = Otu.new(:name => 'foo')\\n ct = ContentType.new(:name => 'bar')\\n content.update_attributes!(:text => text, :otu => otu, :content_type => ct)\\n content.reload\\n assert_equal(text, content.text)\\n end\",\n \"def save_images(mkd,path)\\n regexp_img_links = /!\\\\[(.*?)\\\\]\\\\((.*?)\\\\)/\\n img_dirname = File.basename(path)\\n FileUtils.mkdir_p(path,{:mode => 0755})\\n client = HTTPClient.new\\n mkd.gsub!(regexp_img_links).with_index do |matched,i|\\n #save image\\n alttext = $1\\n imgurl = $2\\n $stdout.puts imgurl\\n\\n ext = File.extname(imgurl).match(/(.*?)(?:\\\\?.*)?$/)[1]\\n filename = (\\\"%07\\\\d\\\" % i)+ext\\n filename_fullpath = File.join(path,filename)\\n begin\\n data=client.get_content(imgurl)\\n rescue\\n # if we could not get image,we do not edit link.\\n next \\\"![#{alttext}](#{imgurl})\\\"\\n end\\n File.open(filename_fullpath,\\\"w\\\"){|file| file.write(data)}\\n\\n #fix the link\\n \\\"![#{alttext}](#{File.join(\\\"./\\\",img_dirname,filename)})\\\"\\n end\\nend\",\n \"def save(filename, content)\\n\\t\\t# FIXME - if the file exists, this should bail out\\n\\t\\t\\n\\t\\t# write the contents into the file\\n\\t\\tfile = dir + '/' + filename + '.md'\\n\\t\\tf = File.new(file, \\\"w\\\")\\n\\t\\tf.write(content)\\n\\t\\tf.close\\n\\t\\t\\n\\t\\t# return the new file\\n\\t\\treturn page(filename)\\n\\tend\",\n \"def save(filename, content)\\n\\t\\t# FIXME - if the file exists, this should bail out\\n\\t\\t\\n\\t\\t# write the contents into the file\\n\\t\\tfile = dir + '/' + filename + '.md'\\n\\t\\tf = File.new(file, \\\"w\\\")\\n\\t\\tf.write(content)\\n\\t\\tf.close\\n\\t\\t\\n\\t\\t# return the new file\\n\\t\\treturn page(filename)\\n\\tend\",\n \"def make_link(old) File.link(old, path) end\",\n \"def hyperlink(file, domain, link_dictionary)\\n\\n link_dictionary = JSON.parse(link_dictionary)\\n original_file_values = JSON.parse(File.read(file))\\n transformed_file_values = {}\\n\\n headers_to_skip=[\\n \\\"coinName\\\",\\n \\\"term\\\",\\n \\\"hyperlinkOn\\\",\\n \\\"knownTickers\\\",\\n \\\"preferredTicker\\\",\\n ]\\n original_file_values.each do |header, original_content|\\n content = original_content\\n unless headers_to_skip.include?(header)\\n if content =~ /^https?:\\\\/\\\\// \\n urls = content.split(\\\", \\\").map do |url|\\n url = url.strip\\n \\\"[#{url}](#{url})\\\"\\n end\\n content = urls.join(\\\", \\\")\\n else \\n link_dictionary.each do |term, link_address|\\n if file.match(/#{link_address}\\\\.json$/) # if this term would hyper link to itself\\n # put a \\\"!!\\\" in front of it so that it doesn't get picked up by any other superstring matches\\n content = content.gsub(\\n /(^|\\\\s|\\\\()(#{term})($|\\\\.|\\\\)|\\\\s|')/i, \\n \\\"\\\\\\\\1!!\\\\\\\\2\\\\\\\\3\\\"\\n ) \\n else\\n content = content.sub( # only hyperlink the first occurrence of a given within a section\\n /(^|\\\\s|\\\\()(#{term})($|\\\\.|\\\\)|\\\\s|')/i, # match the term if it's preceded+followed by a space, period, \\\\n etc.\\n \\\"\\\\\\\\1[\\\\\\\\2](#{domain}#{link_address})\\\\\\\\3\\\"\\n )\\n end\\n end\\n content = content.gsub(/!!/, \\\"\\\") # remove all \\\"!!\\\" used to remove self linking terms from the link pool\\n end\\n end\\n transformed_file_values[header] = content\\n end\\n return transformed_file_values\\nend\",\n \"def link!\\n self.linkbutton = true\\n self.save\\n self.linkbutton\\n end\",\n \"def save_to(path); end\",\n \"def convert(content)\\n button_parts = content.match('div class=\\\"content-edit-page\\\"')\\n source_parts = content.match(/\\\\(source\\\\)<\\\\/a>/)\\n if button_parts == nil and source_parts != nil\\n url = source_parts[1]\\n button_start = '
SHORT_URL + \\\"/\\\" + Base32::Crockford.encode(link.id)\\n end\",\n \"def replace(id, new_content)\\n File.write(find(id), new_content)\\n end\",\n \"def save_content(title, content)\\n\\tFile.open(\\\"pages/#{title}.txt\\\" , \\\"w\\\") do |file|\\n\\t file.print(content)\\n end \\t\\t\\nend\",\n \"def save\\n return if @content.nil?\\n put_rest \\\"extra/#{@name}\\\", @content, :content_type => \\\"application/octet-stream\\\"\\n end\",\n \"def update_link!(link)\\n key = link.key\\n val = link.val\\n @store.remove(key)\\n link = @store.append(key,val) #this is where you move the link to end of list\\n @map[key] = link\\n end\",\n \"def store_path_links_to(path, links)\\n return if links.empty?\\n redis.sadd path_links_to_key(path), links\\n end\",\n \"def reformat_link\\n reg = /^https?:\\\\/\\\\//\\n link = self.link\\n if link.present? && !link.match(reg)\\n link.insert(0,\\\"http://\\\")\\n end\\n self.link = link\\n end\",\n \"def fetch_and_store!\\n # Get links from page\\n # Download files from links concurrently\\n download self.extract!\\n end\",\n \"def write_pending_links(links = nil)\\n\\t\\tdebug.print(3, \\\"Saving links to file\\\", File.basename(__FILE__), __LINE__)\\n\\t\\t\\n\\t\\t#moverdatawriter.write_marshal_dump( fail_queue)\\n\\t\\tpending_links = links || get_unfinished_links()\\n\\t\\t###binding.pry\\n\\t\\tlinkw.write_array(pending_links)\\n\\n\\tend\",\n \"def store_path_linked_to_from(path, links)\\n return if links.empty?\\n redis.sadd path_linked_to_from_key(path), links\\n end\",\n \"def update_link\\n # if save\\n # true\\n # else\\n sr_clone = SitescanCommon::SearchResult.includes(:search_product)\\n .references(:search_product).where.not(id: id).find_by_link link\\n if sr_clone\\n if search_product and search_product.product\\n sr_clone.destroy\\n true\\n elsif search_product and sr_clone.search_product and\\n sr_clone.search_product.product or\\n not search_product and sr_clone.search_product\\n destroy\\n false\\n else\\n sr_clone.destroy\\n true\\n end\\n end\\n true\\n # end\\n end\",\n \"def write_urls_db()\\n end\",\n \"def save(path)\\n update\\n Zip::OutputStream.open(path) do |out|\\n zip.each do |entry|\\n out.put_next_entry(entry.name)\\n\\n if @replace[entry.name]\\n out.write(@replace[entry.name])\\n else\\n out.write(zip.read(entry.name))\\n end\\n end\\n end\\n zip.close\\n end\",\n \"def save\\n es = EsClient.new(YAML_CONFIG, nil)\\n es.write(type: 'email_link',\\n body_hash: self.as_hash)\\n end\",\n \"def save\\n es = EsClient.new(YAML_CONFIG, nil)\\n es.write(type: 'email_link',\\n body_hash: self.as_hash)\\n end\",\n \"def replace_asset_urls(content)\\n return '' if content.blank?\\n\\n _content = content.dup\\n\\n content.force_encoding('utf-8').scan(REGEX).map do |match|\\n url, type, filename = match[0], match[2], match[5]\\n folder = case type\\n when 'assets', 'pages' then File.join('samples', \\\"_#{env}\\\", type)\\n when 'theme' then $4\\n when /\\\\Acontent_entry/ then File.join('samples', \\\"_#{env}\\\", 'content_entries')\\n end\\n\\n Thread.new do\\n if filepath = write_asset(url, File.join(path, 'public', folder, filename))\\n [url, File.join('', folder, File.basename(filepath)).to_s]\\n else\\n [url, '']\\n end\\n end\\n end.map(&:value).each do |(url, replacement)|\\n _content.gsub!(url, replacement)\\n end\\n\\n _content\\n end\",\n \"def save\\n save_to_file(@output_file, @contents)\\n end\",\n \"def link(link, title, content)\\n \\\"#{content} (#{link})\\\"\\n end\",\n \"def cache_urls(doc, latex=false)\\n doc.tap do |text|\\n text.gsub!(/\\\\\\\\(href|url){(.*?)}/) do\\n command, url = $1, $2\\n key = digest(url)\\n literal_cache[key] = url\\n command == 'url' ? \\\"\\\\\\\\href{#{key}}{#{url}}\\\" : \\\"\\\\\\\\href{#{key}}\\\"\\n end\\n end\\n end\",\n \"def insert_link (fileArray, linkName, utilHash)\\n\\nend\",\n \"def update_hrefs(css_selector)\\n @doc.css(css_selector + ' a').each do |a|\\n\\n href = Flatfish::Url.absolutify(a['href'], @cd)\\n\\n # Create tokens for internal links and images/files\\n if href =~ /#{@accepted_domain}/\\n # NB: the brackets will be URL encoded, so we are flagging them here and gsubbing them before saving\\n if @file_whitelist.include?(File.extname(href))\\n media = get_media(href)\\n href = \\\"[FLATFISHmedia:#{media.id}FLATFISH]\\\"\\n elsif href !~ /mailto:/\\n link = Flatfish::Link.find_or_create_by(url: href)\\n href = \\\"[FLATFISHlink:#{link.id}FLATFISH]\\\"\\n end\\n end\\n a['href'] = href\\n end\\n end\",\n \"def save_to(path)\\n update\\n Zip::OutputStream.open(path) do |out|\\n zip.each do |entry|\\n next unless entry.file?\\n\\n out.put_next_entry(entry.name)\\n\\n if @replace[entry.name]\\n out.write(@replace[entry.name])\\n else\\n out.write(zip.read(entry.name))\\n end\\n end\\n end\\n end\",\n \"def convert _obj\\n if _obj.figures.length == 1 && _obj.figures.first.link.present?\\n _obj.figures.first.link = _obj.figures.first.link.gsub(\\\"http://\\\", \\\"https://\\\")\\n _obj.save!\\n end\\nend\",\n \"def update!\\n open(link)\\n end\",\n \"def link(link, title, content)\\n link = OodAppkit.files.api(path: @app_path.to_s + '/' + link).to_s if @app_path && relative?(link)\\n return \\\"#{content}\\\" unless id_link?(link)\\n return \\\"#{content}\\\"\\n end\",\n \"def inline_auto_link(text)\\n text.gsub!(AUTO_LINK_RE) do\\n all, leading, proto, url, post = $&, $1, $2, $3, $6\\n if leading =~ /=]?/\\n # don't replace URL's that are already linked\\n # and URL's prefixed with ! !> !< != (textile images)\\n all\\n else\\n # Idea below : an URL with unbalanced parethesis and\\n # ending by ')' is put into external parenthesis\\n if ( url[-1]==?) and ((url.count(\\\"(\\\") - url.count(\\\")\\\")) < 0 ) )\\n url=url[0..-2] # discard closing parenth from url\\n post = \\\")\\\"+post # add closing parenth to post\\n end\\n tag = content_tag('a', proto + url, :href => \\\"#{proto==\\\"www.\\\"?\\\"http://www.\\\":proto}#{url}\\\", :class => 'external')\\n %(#{leading}#{tag}#{post})\\n end\\n end\\n end\",\n \"def update_link\\n tree.new_branch_in available_folder\\n FileUtils.rm current_directory\\n link_target\\n end\",\n \"def parse_link; end\",\n \"def save_content(title, content)\\n File.open(\\\"pages/#{title}.txt\\\", \\\"w\\\") do |file|\\n file.print(content)\\n end\\nend\",\n \"def save_nonadword_urls(page)\\n\\t\\tnonadword_urls(page).each do |url|\\n\\t\\t\\tcreate_nonadword_url(url, \\\"center\\\")\\n\\t\\tend\\n\\tend\",\n \"def make_link( old ) File.link( old, expand_tilde ) end\",\n \"def handle_item item\\n separator item.link\\n file_handle.write(open(item.link).read)\\n file_handle.write(\\\"\\\\n\\\\n\\\")\\n end\",\n \"def save_and_open\\n return unless File.exist?(session.saved_page_dir)\\n\\n filename = \\\"#{session.saved_page_dir}/webrat-#{Time.now.to_i}.html\\\"\\n \\n File.open(filename, \\\"w\\\") do |f|\\n f.write rewrite_css_and_image_references(session.response_body)\\n end\\n\\n open_in_browser(filename)\\n end\",\n \"def update; @doc = get(link('self')); nil; end\",\n \"def update; @doc = get(link('self')); nil; end\",\n \"def save(seo)\\n @database.save_doc(seo.merge('_id' => seo[:url]))\\n seo\\n end\",\n \"def replace(entry, src_path); end\",\n \"def export_link(builder, link)\\n folders = []\\n folders << link.folder.name if link.folder\\n folders = folders + link.keywords if link.keywords.present?\\n builder.bookmarks << Markio::Bookmark.create({\\n title: link.name,\\n href: link.url,\\n folders: folders.present? ? folders : nil,\\n add_date: link.saved_at\\n })\\n end\",\n \"def update_paths_linked_to_from_path(document)\\n document.domain_specific_paths.each do |url|\\n link_uri_path = normalize_path Addressable::URI.parse(url.strip).path\\n document_uri_path = normalize_path document.uri.path\\n next if link_uri_path == document_uri_path\\n\\n store_path link_uri_path\\n store_path_linked_to_from(link_uri_path, [document_uri_path])\\n end\\n end\",\n \"def update_link(link)\\n if i = find_index { |l| l.rel.to_s == link.rel.to_s }\\n return self[i] = link\\n end\\n self << link\\n end\",\n \"def unlink!\\n parse \\n @tags.each do |tag|\\n @doc.xpath(\\\"//a[ends_with(@href,'#{tag}')]\\\", EndsWithFilter.new).each do |element|\\n element.swap(element.children)\\n end\\n end\\n output = @doc.xpath(\\\"/#{@wrap_tag}/body/p\\\").inner_html\\n output = @doc.xpath(\\\"/#{@wrap_tag}/body\\\").inner_html if output == \\\"\\\"\\n output\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.6567425","0.65585786","0.6447391","0.62871224","0.6237766","0.6236621","0.6172117","0.6146743","0.6080767","0.5930058","0.58878714","0.5820214","0.57773566","0.57765585","0.57738966","0.5754886","0.57368857","0.57165253","0.5712843","0.5709101","0.57053226","0.5687513","0.565624","0.5652494","0.5652494","0.56505394","0.56418085","0.56306064","0.56226385","0.5616625","0.5577995","0.55645007","0.55483365","0.55438626","0.5536009","0.55335844","0.55189556","0.551058","0.54894537","0.5430388","0.54217094","0.5393898","0.5392662","0.53832","0.5381454","0.53756166","0.536437","0.5363761","0.53608185","0.5340253","0.53089374","0.53024614","0.52945024","0.52945024","0.5287864","0.5284677","0.5283639","0.5282173","0.52804446","0.52738637","0.5252883","0.5224177","0.52174926","0.52157193","0.5210853","0.520816","0.52067506","0.5193431","0.5192524","0.5189517","0.51769996","0.516424","0.51590085","0.51537526","0.51537526","0.5135723","0.51272196","0.5120263","0.51141936","0.5111311","0.51108015","0.5099946","0.5098488","0.50917727","0.5087944","0.5081983","0.50817144","0.50760704","0.5068383","0.5065908","0.5061557","0.50585455","0.5058047","0.5048705","0.5048705","0.50436026","0.5039232","0.5038403","0.50308615","0.5027037","0.5021833"],"string":"[\n \"0.6567425\",\n \"0.65585786\",\n \"0.6447391\",\n \"0.62871224\",\n \"0.6237766\",\n \"0.6236621\",\n \"0.6172117\",\n \"0.6146743\",\n \"0.6080767\",\n \"0.5930058\",\n \"0.58878714\",\n \"0.5820214\",\n \"0.57773566\",\n \"0.57765585\",\n \"0.57738966\",\n \"0.5754886\",\n \"0.57368857\",\n \"0.57165253\",\n \"0.5712843\",\n \"0.5709101\",\n \"0.57053226\",\n \"0.5687513\",\n \"0.565624\",\n \"0.5652494\",\n \"0.5652494\",\n \"0.56505394\",\n \"0.56418085\",\n \"0.56306064\",\n \"0.56226385\",\n \"0.5616625\",\n \"0.5577995\",\n \"0.55645007\",\n \"0.55483365\",\n \"0.55438626\",\n \"0.5536009\",\n \"0.55335844\",\n \"0.55189556\",\n \"0.551058\",\n \"0.54894537\",\n \"0.5430388\",\n \"0.54217094\",\n \"0.5393898\",\n \"0.5392662\",\n \"0.53832\",\n \"0.5381454\",\n \"0.53756166\",\n \"0.536437\",\n \"0.5363761\",\n \"0.53608185\",\n \"0.5340253\",\n \"0.53089374\",\n \"0.53024614\",\n \"0.52945024\",\n \"0.52945024\",\n \"0.5287864\",\n \"0.5284677\",\n \"0.5283639\",\n \"0.5282173\",\n \"0.52804446\",\n \"0.52738637\",\n \"0.5252883\",\n \"0.5224177\",\n \"0.52174926\",\n \"0.52157193\",\n \"0.5210853\",\n \"0.520816\",\n \"0.52067506\",\n \"0.5193431\",\n \"0.5192524\",\n \"0.5189517\",\n \"0.51769996\",\n \"0.516424\",\n \"0.51590085\",\n \"0.51537526\",\n \"0.51537526\",\n \"0.5135723\",\n \"0.51272196\",\n \"0.5120263\",\n \"0.51141936\",\n \"0.5111311\",\n \"0.51108015\",\n \"0.5099946\",\n \"0.5098488\",\n \"0.50917727\",\n \"0.5087944\",\n \"0.5081983\",\n \"0.50817144\",\n \"0.50760704\",\n \"0.5068383\",\n \"0.5065908\",\n \"0.5061557\",\n \"0.50585455\",\n \"0.5058047\",\n \"0.5048705\",\n \"0.5048705\",\n \"0.50436026\",\n \"0.5039232\",\n \"0.5038403\",\n \"0.50308615\",\n \"0.5027037\",\n \"0.5021833\"\n]"},"document_score":{"kind":"string","value":"0.0"},"document_rank":{"kind":"string","value":"-1"}}},{"rowIdx":1876,"cells":{"query":{"kind":"string","value":"XXX this hasn't been tested thoroughly. most likely does the wrong thing for at least some inputs TODO should maintain a table of uri > path mappings for anything that gets changed or truncated so that we can choose unique paths when there is a collision. then all uris will be mapped uniquely and correctly"},"document":{"kind":"string","value":"def uri_to_filename(uri, abspath = false)\n filename = File.join($aliases[0], (uri.path[-1] == '/' ? uri.path + 'index.html' : uri.path).gsub(/[:*?\"<>|]/, '_'))\n filename = File.join(Dir.pwd, filename) if abspath\n filename = File.join(filename, 'index.html') if File.directory?(filename)\n filename += \"_#{uri.query.gsub(/[:*?\"<>|\\/\\\\]/, '_')}\" if uri.query\n\n # windows is stupid and call only handle paths <= 259 chars in length...\n # silently truncating causes potential problems but it's good enough for now\n filename = filename[0..258] if Utility.is_windows? and filename.length > 259\n\n filename\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def normalize_uri(*strs)\n new_str = strs * '/'\n new_str = new_str.gsub!('//', '/') while new_str.index('//')\n new_str\n end","def update_duplicate_uri\n # Checking if multiple content are present with the same uri the updating the uri\n duplicate_entries = Content.where(:uri=>self.uri)\n\n # Only change the uri if more than one entry is found for the current uri\n if duplicate_entries.length > 1\n old_uri = self.uri\n new_uri = old_uri+'_'+rand(100000).to_s\n\n # Updating the current uri with the newly generated uri\n self.update_attributes(:uri => new_uri)\n end\n # End of code for handling the content with same uri\n end","def normalize_uri(*strs)\n new_str = strs * \"/\"\n\n new_str = new_str.gsub!(\"//\", \"/\") while new_str.index(\"//\")\n\n # Makes sure there's a starting slash\n unless new_str[0,1] == '/'\n new_str = '/' + new_str\n end\n\n new_str\n end","def uri_normalizer; end","def normalize_path(url); end","def normalize_path(url); end","def paths_sequences_from_uri(uri)\n paths = uri.paths[0..-2]\n paths.sequences.uniq.map { |i| i.join('/') }\n end","def test_valid_unc_uris\n [\n ['file:////example.com/Share/dir/file.ext', '//example.com/Share/dir/file.ext', '\\\\\\\\example.com\\\\Share\\\\dir\\\\file.ext'],\n ['file://///example.com/Share/dir/file.ext', '//example.com/Share/dir/file.ext', '\\\\\\\\example.com\\\\Share\\\\dir\\\\file.ext'],\n\n ['file:////localhost/Share/dir/file.ext', '//localhost/Share/dir/file.ext', '\\\\\\\\localhost\\\\Share\\\\dir\\\\file.ext'],\n ['file://///localhost/Share/dir/file.ext', '//localhost/Share/dir/file.ext', '\\\\\\\\localhost\\\\Share\\\\dir\\\\file.ext'],\n ].each do |str, path, unc|\n uri = URI.parse(str)\n assert_kind_of( URI::FileCommon, uri )\n assert_equal( path, uri.path )\n\n assert_equal( false, uri.local?(localhost: false) )\n assert_equal( false, uri.local?(localhost: true) )\n assert_equal( false, uri.local? )\n assert_equal( false, uri.local?(localhost: :any) )\n\n assert_raise(RuntimeError) { uri.to_file_path(localhost: false) }\n assert_raise(RuntimeError) { uri.to_file_path(localhost: true) }\n assert_raise(RuntimeError) { uri.to_file_path }\n assert_raise(RuntimeError) { uri.to_file_path(localhost: :any) }\n\n assert_equal( unc, uri.to_unc(localhost: false) )\n assert_equal( unc, uri.to_unc(localhost: true) )\n assert_equal( unc, uri.to_unc )\n assert_equal( unc, uri.to_unc(localhost: :any) )\n end\n end","def normalize_uri\r\n self.link = Addressable::URI.heuristic_parse(self.link).normalize!.to_s if self.link\r\n end","def map *paths\n return if locked?\n @base_url = rootify_url(paths.shift.to_s).freeze\n @canonicals = paths.map { |p| rootify_url(p.to_s) }.freeze\n end","def normalize_uri\n \n # Don't do anything on blanks\n return if self.uri.blank?\n\n # Try to parse, and set to nil if it fails\n uri = Addressable::URI.heuristic_parse(self.uri) rescue nil\n\n # Seems like it's possible to get here with a non-blank URI\n return if uri.blank?\n\n # Normalize it!\n self.uri = uri.normalize.to_s\n\n end","def extract_uris(uri, uri_content)\n # file must be a directory\n if !File.directory?(uri) then\n return Array.new()\n end\n\n # creating the new uris container\n new_uris = Array.new()\n\n # getting the children of the 'uri' folder\n Dir.foreach(uri) do |f|\n # building the new uri path\n path = \"#{uri}/#{f}\"\n\n # appending the new uris values if they aren't the '.' and '..' directories\n if f != '.' and f != '..' then\n new_uris << path\n end\n end\n\n # returning the new uris\n return new_uris\n end","def normalize\n uri = dup\n uri.normalize!\n uri\n end","def normalize_url(path)\n @known_pairs ||= {}\n @public_directories_regex ||= Regexp.new(Bones.public_directories.join('|'))\n \n if v = @known_pairs[path]\n return v\n else\n value = case\n when path =~ /^(\\w{3,}:\\/\\/|mailto)/\n # don't do anything to this type of URL\n return path\n when path =~ @public_directories_regex\n path\n when File.directory?('pages' / path)\n path\n else\n # don't add .html if there's already an extension\n path =~ /\\..+/ ? path : path + '.html'\n end\n \n @known_pairs[path] = options.base / value\n end \n end","def update_paths_linked_to_from_path(document)\n document.domain_specific_paths.each do |url|\n link_uri_path = normalize_path Addressable::URI.parse(url.strip).path\n document_uri_path = normalize_path document.uri.path\n next if link_uri_path == document_uri_path\n\n store_path link_uri_path\n store_path_linked_to_from(link_uri_path, [document_uri_path])\n end\n end","def uri_normalize(uri)\n \treturn 'http://' + uri unless uri =~ /http:\\/\\//\n \turi\n\tend","def uri_normalize(uri)\n \treturn 'http://' + uri unless uri =~ /http:\\/\\//\n \turi\n\tend","def short_url_algorithm()\n \n unique_id_length = 3\n base64 = Base64.encode64(self.original_url)\n join_url = (base64.split('')).sample(unique_id_length).join()\n safe_url = join_url.gsub(\"+\", \"-\").gsub(\"/\",\"_\")\n \n loop do \n self.short_url = @@URL + safe_url\n \n if Url.find_by_short_url(self.short_url).nil?\n break\n else\n unique_id_length = unique_id_length + 1\n end\n \n end\n \n end","def fix_paths(doc, count, path)\n doc.xpath('//img').each do |x|\n if x['src'].start_with?('//') or x['src'].start_with?('media')\n next\n end\n if x['src'].start_with?('/')\n x['src'] = Array.new(count, \"../\").join + x['src']\n end\n end\n doc.xpath('//link[@rel=\"stylesheet\"]').each do |y|\n if y['href'].start_with?('/')\n y['href'] = Array.new(count, \"../\").join + y['href']\n end\n end\n doc.xpath('//a').each do |z|\n # Ignore links that only go to anchors.\n if !z['href']\n next\n end\n # Ignore links to anchors and real pages.\n if z['href'].start_with?('#') or z['href'].start_with?('http')\n next\n end\n\n # Actually rewrite the paths now.\n if z['href'] == '/'\n z['href'] = 'http://logstash.net/'\n end\n # Don't rewrite paths that already contain '.html'\n if z['href'] =~ /\\.html/\n next\n end\n\n url, hash = z['href'].split('#')\n url += '.html'\n url = \"#{url}\\##{hash}\" if hash\n z['href'] = url\n end\nend","def normalize_links!\n # TODO: normalize Array of Symbol, String, DM::Property 1-jump-away or DM::Query::Path\n end","def rebase_hrefs(input, base_uri)\n Utils.rebase_hrefs(input, base_uri) rescue input\n end","def check_uri_build\n\n end","def normalize_url\n return if self.url.blank?\n normalized = self.url.normalize\n if normalized.blank?\n self.errors.add(:url, \"is invalid\")\n return false\n elsif normalized.match(\"archiveofourown.org/users\")\n self.errors.add(:url, \"cannot be ao3 user\")\n return false\n elsif normalized.match(\"(.*)/collections/(.*)/works/(.*)\")\n normalized = $1 + \"/works/\" + $3\n elsif normalized.match(\"archiveofourown.org/collections\")\n self.errors.add(:url, \"cannot be an ao3 collection\")\n return false\n end\n self.url = normalized\n end","def process_uris(element, value, evaluation_context, base, **options)\n return [] if value.to_s.empty?\n add_debug(element) {\"process_uris: #{value}\"}\n value.to_s.split(/\\s+/).map {|v| process_uri(element, v, evaluation_context, base, **options)}.compact\n end","def path_set(path)\n absolute_path = (Pathname.new(uri.path) + path).to_s\n rebuild_uri :path => absolute_path\n end","def resolve\n\n uri_to_be_resolved = @uri.clone\n \n \n if script? uri_to_be_resolved\n full_path = replace_script_aliases(uri_to_be_resolved)\n elsif alias? uri_to_be_resolved\n full_path = replace_aliases(uri_to_be_resolved)\n else\n full_path = File.join(@conf.document_root,uri_to_be_resolved)\n @uri_without_doc_root = uri_to_be_resolved.clone\n end\n\n if (! File.file? full_path) && ( @http_method.casecmp(\"PUT\") != 0)\n full_path = File.join(full_path,get_directory_index)\n end \n \n @resolved_uri = full_path.clone\n full_path \n end","def comparable_uri(string)\n if uri?(string)\n uri = URI.parse(string)\n # Strip any \"www.\" from host\n host = uri.host.sub(/www\\./,'')\n # Treat an empty path as \"/\"\n path = (uri.path.nil? or uri.path.empty?) ? \"/\" : uri.path\n # If path doesn't end with a slash, add it\n path = path.end_with?(\"/\") ? path : path + \"/\"\n # Return [host]/[path]\n host + path\n else\n # If not a URI, just return empty string\n # We don't want to compare or keep around non-URIs\n \"\"\n end\nend","def update_file_paths \n if self.url_part_was && self.url_part && self.short_name_changed?\n old_url_part = self.url_part\n old_ref_path = self.assignment_reference_repository.git_path\n set_url_part\n \n if old_url_part == self.url_part\n # Nothing changes\n return\n end\n \n self.save\n \n # Move reference repository folder if necessary\n if File.directory?(old_ref_path) \n new_ref_path = String.new(old_ref_path)\n new_ref_path[new_ref_path.index(File.basename(new_ref_path))..-1] = self.url_part\n \n FileUtils.mv old_ref_path, new_ref_path\n end\n \n # Move assignment repositories if necessary\n self.assignment_offerings.each do |assignment_offering|\n old_assignment_repo_path = File.join(\n assignment_offering.course_offering.storage_path,\n 'assignments',\n old_url_part)\n \n if File.directory?(old_assignment_repo_path)\n new_assignment_repo_path = File.join(\n assignment_offering.course_offering.storage_path,\n 'assignments',\n self.url_part) \n \n FileUtils.mv old_assignment_repo_path, new_assignment_repo_path\n end \n \n end\n end\n end","def process_uri(uri)\n # empty --> this is like an abstract class method\n end","def get_possible_uris(page)\n\n @wiki_full_uri = getWikiRepositoryUrl\n\n @uri = URI.parse(@wiki_full_uri)\n\n pageName = page.data['wikiPageName'] # Page name\n\n @patterns = []\n\n # page name can have different working forms ranging from \"page name\" to \"Page-Name\"\n possible_name = [pageName]\n # normalize to lowercase and - as separator\n possible_name += [pageName.gsub(' ', '-').downcase] #page-name\n possible_name += camel_case(pageName, '-') #Page-name + Page name\n possible_name += camel_caps(pageName, '-') #Page-Name + Page Name\n possible_name += [pageName.gsub('-', ' ').downcase] #page name\n\n possible_name.uniq.each do |name|\n @patterns += [\n # possible WORKING internal links patterns that can be found in wiki pages\n # [link text](https://github.com/userName/RepositoryName/wiki/Page-name)\n @wiki_full_uri + '/' + name,\n # [link text](https://github.com/userName/RepositoryName/wiki/Page-name/) trailing slash\n @wiki_full_uri + '/' + name + '/',\n # [link text](/userName/RepositoryName/wiki/Page-name)\n @uri.path + '/' + name,\n # [link text](/userName/RepositoryName/wiki/Page-name/) trailing slash\n @uri.path + '/' + name + '/',\n # [link text](Page-name)\n name\n ]\n end\n\n # Home page has two other patterns that are the wiki root url with no page name\n # because Home is the default page\n if pageName.downcase == 'home'\n @patterns += [\n # home page direct uris\n # [link text](https://github.com/userName/RepositoryName/wiki)\n @wiki_full_uri,\n # [link text](https://github.com/userName/RepositoryName/wiki) trailing slash\n @wiki_full_uri + '/',\n # [link text](/userName/RepositoryName/wiki)\n @uri.path,\n # [link text](/userName/RepositoryName/wiki) trailing slash\n @uri.path + '/'\n ]\n end\n\n return @patterns\n end","def extract_uris(uri, uri_content)\n # empty --> this is like an abstract class method\n end","def extract_uris(uri, uri_content)\n # in our case, no new uri can be extracted from a web resource\n return Array.new()\n end","def normalize_path(path); end","def normalize_path(path); end","def more_general_uri?(uri1, uri2)\n ua1 = uri1.nil? ? [] : uri1.split('/')\n ua2 = uri2.nil? ? [] : uri2.split('/')\n ua1.each_with_index do |p, i|\n return false unless ua2[i] == p\n end\n true\n end","def normalize_uri(uri)\n (uri =~ /^(https?|ftp|file):/) ? uri : \"http://#{uri}\"\n end","def parse_uri(input)\n lines = parse_input input\n extract_uri lines\n end","def map_paths(orig = @orig, dest = @dest, path = [])\n\n\t\t# we have to duplicate each path array to its own object\n\t\t# to ensure it isn't contaminated by another iteration\n\t\tpath = path.dup\n\t\tpath << orig\n\n\t\tif orig == dest\n\t\t\tif !@successful_paths.include?(path)\n\t\t\t\t@successful_paths << path\n\t\t\t\treturn\n\t\t\tend\n\t\telse\n\t\t\t# get connections\n\t\t\tconnections = orig.connected\n\t\t\t# remove previous stops from possible connections list\n\t\t\tconnections = connections - path\n\t\t\tconnections.each do |c|\n\t\t\t\tmap_paths(c, dest, path)\n\t\t\tend\n\t\tend\n\tend","def hash_by_uri\n @hash_by_uri ||= begin\n result = {}\n flatten_hierarchy.each do |c|\n result[c.uri.to_s]=c\n end\n result\n end\n end","def extract_domain_specific_paths\n links.map do |link|\n uri = Addressable::URI.parse(link.strip)\n if uri.hostname.nil? || uri.hostname == @uri.hostname\n normalize_path uri.path\n end\n end.compact\n end","def normalize_uri(uri)\n (uri =~ /^(https?|ftp|file):/) ? uri : \"http://#{uri}\"\n end","def migrate_linked_file?(uri)\n host = uri.host.to_s\n path = uri.path.to_s\n if(host == 'www.ctcc.uio.no')\n if(path != '/' and path != '')\n return true\n else\n return false\n end\n elsif(host != '')\n return false\n end\n return super(uri)\n end","def update_uri(p)\n update_attribute(:uri_actual, p)\n end","def normalize_url(url); end","def normalize_paths(paths)\n paths = [paths] unless paths.is_a?(Array)\n paths.map(&:dup).map do |path|\n raise ArgumentError.new(\"Invalid path: #{path}\") unless valid_path?(path)\n # Strip leading slash from extension path\n path.gsub!(/^\\/(?=\\*.)/, '')\n # Escape some valid special characters\n path.gsub!(/[.+$\"]/) {|s| '\\\\' + s}\n # Replace * wildcards with .* regex fragment\n path.gsub!(/\\*/, '.*')\n \"^#{path}#{END_URL_REGEX}\"\n end\nend","def calculate_uri(uri)\n if uri[0] != '/' && uri.index('://') && uri.index('://') > 0\n uri = ::URI.split(uri)[5] # path component of uri\n end\n\n uri = Uri.normalize(uri.gsub('//', '/'))\n base_uri = Uri.normalize(self.base_uri)\n\n if uri.index(base_uri) == 0\n return Http::UrlUtil.decode_path(uri[base_uri.length..-1]).gsub(%r{^/+}, '').gsub(%r{/+$}, '')\n\n elsif \"#{uri}/\" == base_uri\n # A special case, if the baseUri was accessed without a trailing\n # slash, we'll accept it as well.\n return ''\n else\n fail Exception::Forbidden, \"Requested uri (#{uri}) is out of base uri (#{self.base_uri})\"\n end\n end","def test_valid_nonlocal_uris\n [\n ['file://example.com/Share/dir/file.ext', 'example.com', '/Share/dir/file.ext', '\\\\\\\\example.com\\\\Share\\\\dir\\\\file.ext'],\n ['file://example.com/Share/dir/file.ext', 'example.com', '/Share/dir/file.ext', '\\\\\\\\example.com\\\\Share\\\\dir\\\\file.ext'],\n ].each do |str, host, path, unc|\n uri = URI.parse(str)\n assert_kind_of( URI::FileCommon, uri )\n assert_equal( path, uri.path )\n assert_equal( host, uri.host )\n\n assert_equal( false, uri.local?(localhost: false) )\n assert_equal( false, uri.local?(localhost: true) )\n assert_equal( false, uri.local? )\n assert_equal( true, uri.local?(localhost: :any) )\n\n assert_raise(RuntimeError) { uri.to_file_path(localhost: false) }\n assert_raise(RuntimeError) { uri.to_file_path(localhost: true) }\n assert_raise(RuntimeError) { uri.to_file_path }\n assert_equal( path, uri.to_file_path(localhost: :any) )\n\n assert_equal( unc, uri.to_unc(localhost: false) )\n assert_equal( unc, uri.to_unc(localhost: true) )\n assert_equal( unc, uri.to_unc )\n assert_raise(RuntimeError) { uri.to_unc(localhost: :any) }\n end\n end","def build_url(url)\n # this will remove any of the blank spaces. There is no reason for blank space in the url or brake lines\n url = url.gsub(\" \", \"\").gsub(/\\n/, \"\").gsub(/\\r/, \"\")\n \n \n # Step one tells me that the uri does have a http or a https to use\n one = url.slice(/(https|http)/)\n if one.nil?\n request_response = \"http://\"\n uri_split = url.split(\".\")\n else\n request_response = url.split(\"//\")[0] + \"//\"\n uri_split = url.split(\"//\")[1].split(\".\")\n end\n \n # Step two and three check for the .com and www at the begging. \n # The count is to make sure that is it missing something and not just taking the place of a sub domain.\n if uri_split.count <= 2\n two = url.slice(/(com|gov|org|net|mobi)/)\n three = url.slice(/(www)/)\n # don't add if the thing is there\n if three.nil?\n uri_split.unshift(\"www\")\n end\n if two.nil?\n uri_split << \"com\"\n end\n end\n path_seperator = uri_split[uri_split.length - 1].split(/\\//)\n if path_seperator && path_seperator.length <= 1\n uri_split[uri_split.length - 1] = path_seperator\n end\n string = uri_split.map{ |split| split }.join(\".\").to_s\n # I can't figure this part out but it sucks\n path_thing = string.split(/\\//) \n unless url.blank?\n url = request_response + string\n end\n end","def normalize_options(uri_or_options)\n case uri_or_options\n when String, Addressable::URI then DataObjects::URI.parse(uri_or_options).attributes\n when DataObjects::URI then uri_or_options.attributes\n when Pathname then {:path => uri_or_options}\n else\n uri_or_options[:path] ||= uri_or_options.delete(:config) || uri_or_options.delete(:database)\n uri_or_options\n end\n end","def create_uri\n end","def fix_url\n self.url = UrlNormalizer.normalize_entry_url self.url, self\n end","def coerce_uri incoming_uri\n if incoming_uri.is_a? Hash\n Addressable::URI.new deep_hash_normalize(incoming_uri)\n elsif incoming_uri\n Addressable::URI.parse incoming_uri\n end\n end","def normalize_paths(paths)\n # do the hokey-pokey of path normalization...\n paths = paths.collect do |path|\n path = path.\n gsub(\"//\", \"/\"). # replace double / chars with a single\n gsub(\"\\\\\\\\\", \"\\\\\"). # replace double \\ chars with a single\n gsub(%r{(.)[\\\\/]$}, '\\1') # drop final / or \\ if path ends with it\n\n # eliminate .. paths where possible\n re = %r{[^/\\\\]+[/\\\\]\\.\\.[/\\\\]}\n path.gsub!(re, \"\") while path.match(re)\n path\n end\n\n # start with longest path, first\n paths = paths.uniq.sort_by { |path| - path.length }\n end","def normalize(sources)\n normalized = sources.map do |source|\n uri = URI.parse(source[:url])\n next unless uri.scheme =~ /\\Ahttps?\\z/\n\n s = {}\n s[:url] = \"#{uri.scheme}://#{uri.host}#{uri.path.gsub(/.git$/, '')}\"\n s[:token] = uri.user if uri.user\n s[:branch] = uri.fragment if uri.fragment\n source.merge(s)\n end\n normalized.compact\n end","def post_process_uri( val )\n\t\t\treturn URI.parse( val.to_s )\n\t\trescue URI::InvalidURIError => err\n\t\t\tself.log.error \"Error trying to parse URI %p: %s\" % [ val, err.message ]\n\t\t\treturn nil\n\t\trescue NoMethodError\n\t\t\tself.log.debug \"Ignoring bug in URI#parse\"\n\t\t\treturn nil\n\t\tend","def categorize_uri(str)\n regex = /\\.+/ # really simple host regex to thwart unwanted strings\n str = \"http://#{str}\" unless str.to_s =~ %r{\\Ahttps?://}\n uri = URI.parse(str.to_s)\n path = uri.path.chomp('/')\n return :unknown if (uri.host =~ regex).nil?\n\n path.empty? ? :host : :url\n rescue URI::InvalidURIError\n :unknown\n end","def remap! root, *given_canonicals\n return if mounted?\n new_base_url = rootify_url(root, base_url)\n new_canonicals = Array.new(canonicals + given_canonicals)\n canonicals.each do |ec|\n # each existing canonical should be prepended with new root\n new_canonicals << rootify_url(new_base_url, ec)\n # as well as with each given canonical\n given_canonicals.each do |gc|\n new_canonicals << rootify_url(gc, ec)\n end\n end\n map new_base_url, *new_canonicals.uniq\n end","def __build_path(entries)\n parts = entries[0][:path].split('/')\n parts.pop(entries[0][:chunks].length)\n parts.join('/') # stitch parts together to form a path\n end","def modify_uri\n uri = @request.uri\n @conf.aliases.each do |a|\n if uri.include? a\n uri = uri.sub(a, @conf.alias_path(a))\n end\n end\n if uri != @request.uri\n return uri\n end\n @conf.script_aliases.each do |a|\n if uri.include? a\n uri = uri.sub(a, @conf.script_alias_path(a))\n end\n end\n uri\n end","def update_photo_urls(records, subdirectories)\r\n\r\n updated_records = []\r\n\r\n records.each do |record_hash|\r\n\r\n urls_array = generate_image_urls(record_hash[\"photos\"], subdirectories)\r\n record_hash[\"photos\"] = urls_array\r\n updated_records.push(record_hash)\r\n\r\n end\r\n\r\n return updated_records \r\n\r\nend","def fix_oneoff url\n begin\n uri = URI.parse url\n return (\"\" == uri.path) ? url + '/' : url\n rescue\n #puts \"Ran into issue processing #{url}\"\n end\n end","def build_uri(uri)\n return uri if @region.nil? && @edge.nil?\n\n parsed_url = URI(uri)\n pieces = parsed_url.host.split('.')\n product = pieces[0]\n domain = pieces[-2, 2]\n new_edge = @edge\n new_region = @region\n\n case pieces.length\n when 4\n new_region ||= pieces[1]\n when 5\n new_edge ||= pieces[1]\n new_region ||= pieces[2]\n end\n\n new_region = @@default_region if !new_edge.nil? && new_region.nil?\n\n parsed_url.host = [product, new_edge, new_region, domain].reject(&:nil?).join('.')\n parsed_url.to_s\n end","def map(url, *args)\n #if the last element of args is a hash, take it off and set options\n #to it. Now, if that was there, it should be a hash containing key\n #'default', which, itself has a key of another hash\n #if it wasn't there, then sed options{:default} to the empty Hash\n options = {}\n options = args.pop if args[-1].is_a?(Hash)\n options[:default] ||= {}\n\n #set destintation to nil, and then set it to whatever is at\n #the last inddex of args. Which looks like should be 0 because\n #after that pop, if there's anything left, then we raise an error\n destination = nil\n destination = args.pop if args.size > 0\n raise \"Too many args!\" if args.size > 0\n\n #similar to how we did in controller_and_action get the parts of the\n #url split up into an array based on the forward slash, then take\n #out empty parts (so if the url contained \"//\")\n parts = url.split(\"/\")\n parts.reject! { |part| part.empty? }\n\n #vars and regex_parts are both set to the empty array\n vars, regex_parts = [], []\n\n #so now loop through each part of the array. Each of which is a\n #String\n parts.each do |part|\n #so we're looking at the first letter\n case part[0]\n #if it's a colon, add every following character to the next\n #index of vars. Then put in the next index of regex_parts\n #that the thing to match is any alphanumeric character\n #SO VARS WILL CONTAIN ALL OF OUR SYMBOLS - PATTERNS like\n #:controller, :action, :id\n when \":\"\n vars << part[1..-1]\n regex_parts << \"([a-zA-Z0-9]+)\"\n #if it's a star, add every following character to the next\n #index of vars. And regex_parts gets a /.*/ to match on\n when \"*\"\n vars << part[1..-1]\n regex_parts << \"(.*)\"\n #otherwise, regex_parts simple gets the string at this part of the\n #url (always ignoring \"/\" from the URL of course)\n else\n regex_parts << part\n end\n end\n\n #ok so now we're combining all of the regex parts into a single\n #string, which will be our total regex to match on later\n\n #vars is an array that contains all of the strings that had : or *\n #at the beginning\n\n #destination is either nil or what was at index 0 of args\n #options is either a blank hash or what was the hash at inded 1\n #of args\n regex = regex_parts.join(\"/\")\n @rules.push({ regex: Regexp.new(\"^/#{regex}$\"),\n vars: vars, destination: destination,\n options: options })\n end","def field_path_transform(s_share,s_path)\n src_path = @fields[s_path]\n return if src_path.nil? || src_path.empty?\n notify \"Spliting Path:#{s_path} to #{s_share}\"\n result = path_transform(@fields[s_path])\n return if result.values.any?{|val| val.nil?}\n @fields[s_path] = result[:path]\n @fields[s_share] = result[:share]\n patch_url_from_field([s_share,s_path])\n end","def normalize_uri(uri, parent_uri = nil)\n return nil if uri.nil?\n\n normalized = uri.is_a?(URI) ? uri : URI.parse(uri)\n\n if normalized.relative?\n return nil if !parent_uri\n normalized = URI.parse(parent_uri).merge(normalized)\n end\n\n scheme = normalized.scheme\n allowed_schemes = [ 'http' ]\n allowed_schemes << 'https' if @options[:allow_ssl]\n return nil unless allowed_schemes.include?(scheme)\n\n normalized = normalized.normalize\n\n query_string = normalized.select(:query)[0]\n normalized = normalized.select(:host, :path).join\n normalized += \"?#{query_string}\" if query_string\n\n normalized = CGI.unescape(normalized)\n normalized = \"#{scheme}://#{normalized}\"\n normalized = normalized.split('#').first\n \n return normalized\n end","def initialize_urls\n find(:all, :conditions => {self.url_attribute => nil}).each do |instance|\n instance.send :ensure_unique_url\n instance.save\n end\n end","def test_valid_localhost_uris\n [\n ['file://localhost/path/to/file', '/path/to/file', '\\\\\\\\localhost\\\\path\\\\to\\\\file'],\n ].each do |str, path, unc|\n uri = URI.parse(str)\n assert_kind_of( URI::FileCommon, uri )\n assert_equal( path, uri.path )\n\n assert_equal( false, uri.local?(localhost: false) )\n assert_equal( true, uri.local?(localhost: true) )\n assert_equal( true, uri.local? )\n assert_equal( true, uri.local?(localhost: :any) )\n\n assert_raise(RuntimeError) { uri.to_file_path(localhost: false) }\n assert_equal( path, uri.to_file_path(localhost: true) )\n assert_equal( path, uri.to_file_path )\n assert_equal( path, uri.to_file_path(localhost: :any) )\n\n assert_equal( unc, uri.to_unc(localhost: false) )\n assert_raise(RuntimeError) { uri.to_unc(localhost: true) }\n assert_raise(RuntimeError) { uri.to_unc }\n assert_raise(RuntimeError) { uri.to_unc(localhost: :any) }\n end\n end","def dedupe_by_uri(records)\n result = []\n seen = {}\n\n records.reverse.each do |record|\n if !seen[record['uri']]\n result << record\n seen[record['uri']] = true\n end\n end\n\n result.reverse\n end","def dedupe_by_uri(records)\n result = []\n seen = {}\n\n records.reverse.each do |record|\n if !seen[record['uri']]\n result << record\n seen[record['uri']] = true\n end\n end\n\n result.reverse\n end","def process_url(ancestors_path, item)\n default_urlname = (ancestors_path.blank? ? \"\" : \"#{ancestors_path}/\") + item['slug'].to_s\n\n pair = {my_urlname: default_urlname, children_path: default_urlname}\n\n if item['external'] == true || item['visible'] == false\n # children ignore an ancestor in their path if external or invisible\n pair[:children_path] = ancestors_path\n end\n\n pair\n end","def setup_uri_path\n self.uri_path = self.class.scope_from_uri(self.uri)\n end","def normalize_uri uri\n (uri =~ /^https?:/) ? uri : \"http://#{uri}\"\n end","def fix_relative_path(entry)\n feed_url = Addressable::URI.parse(url)\n entry.url = feed_url.scheme + '://' + feed_url.host + entry.url\n end","def validate_relative_uri( uri, dir, doc )\n return validate_anchor(uri, doc) if uri.path.empty?\n\n path = if uri.path =~ %r/^\\//\n ::File.join(::Webby.site.output_dir, uri.path)\n else\n ::File.join(dir, uri.path)\n end\n path = ::File.join(path, 'index.html') if ::File.extname(path).empty?\n\n uri_str = path.dup\n (uri_str << '#' << uri.fragment) if uri.fragment\n return if @valid_uris.include? uri_str\n\n if test ?f, path\n valid = if uri.fragment\n validate_anchor(uri, Hpricot(::File.read(path)))\n else true end\n @valid_uris << uri_str if valid\n else\n @log.error \"invalid URI '#{uri.to_s}'\"\n end\n end","def uri=(_arg0); end","def uri=(_arg0); end","def uri=(_arg0); end","def uri=(_arg0); end","def change_hrefs(html)\n DOM.walk(html) do |node|\n for attr_name in %w{href src}\n attr_obj = node.attributes[attr_name]\n\n # Ignore if its blank\n next if !attr_obj\n\n # URL encode any spaces\n orig_href = attr_obj.to_s.gsub(\" \", \"%20\")\n\n begin\n src = URI(orig_href)\n rescue\n log \"#{orig_href} not a valid URI\"\n next\n end\n\n if internal_link?(src.to_s)\n linked_item = nil\n\n if src.path == \"\"\n # If its just an anchor like '#this' just set to the current file\n linked_item = self\n else\n # Match on the unescaped href\n unescaped_path = URI::unescape(src.path)\n linked_item = get_item(unescaped_path)\n end\n\n # Change link\n if linked_item\n new_path = linked_item.normalized_hashed_path(:relative_to => self)\n new_path = URI(new_path)\n\n if src.fragment\n new_path.fragment = src.fragment\n end\n\n log \"Changing #{src.to_s} to #{new_path.to_s}\"\n attr_obj.content = new_path.to_s\n else\n log \"No item in manifest for #{src}\"\n end\n end\n end\n end\n end","def uri\n @uri ||= select { |type,value| type == :uri }.map do |(type,value)|\n URI.parse(value)\n end\n end","def parse(uri); end","def uri (name,default=\"\")\n \n name=name.to_s\n #FIXME: bad urls (for example just www.example.com will produce an endless-loop\n if name.try(:include?, \"://\")\n return name[0..name.length-2] if name[-1,1]==\"/\"\n return name[0..name.length]\n else\n name +=\"/\" unless (name[name.length-1..name.length-1] == (\"/\" || \"#\")) || name.try(:include?, \":\")\n\n if name.index(\":\") \n t= @object_namespaces[name.split(\":\")[0].to_sym]\n t ||=\"\"\n t += \"/\" unless (t[t.length-1..t.length-1] == (\"/\" || \"#\") || t.blank?) || name.try(:include?, \":\")\n return uri( t+ normalize_local_name(name.split(\":\")[1])+\"/\")\n else \n t= default.blank? ? @base_uri : default\n t += \"/\" unless t[t.length-1..t.length-1]==\"/\"\n return uri( t + normalize_local_name(name))\n end\n end\n end","def build_uri\n unless title.blank?\n self.uri = title.mb_chars.normalize(:d).split(//u).reject { |e| e.length > 1\n }.join.gsub(\"\\n\", \" \").gsub(/[^a-z0-9\\-_ \\.]+/i, '').squeeze(' '\n ).gsub(/ |\\.|_/, '-').gsub(/\\-+/, '-').gsub(/(^\\-)|(\\-$)/, '').downcase\n end\n end","def normalize\n Wgit::Url.new(@uri.normalize.to_s)\n end","def join(*uris)\n joined_parts = object.dup.delete_if {|k, v| %i(user password host port).include?(k)}\n\n uris.each do |uri|\n uri = RDF::URI.new(uri) unless uri.is_a?(RDF::URI)\n next if uri.to_s.empty? # Don't mess with base URI\n\n case\n when uri.scheme\n joined_parts = uri.object.merge(path: self.class.normalize_path(uri.path))\n when uri.authority\n joined_parts[:authority] = uri.authority\n joined_parts[:path] = self.class.normalize_path(uri.path)\n joined_parts[:query] = uri.query\n when uri.path.to_s.empty?\n joined_parts[:query] = uri.query if uri.query\n when uri.path[0,1] == '/'\n joined_parts[:path] = self.class.normalize_path(uri.path)\n joined_parts[:query] = uri.query\n else\n # Merge path segments from section 5.2.3\n # Note that if the path includes no segments, the entire path is removed\n # > return a string consisting of the reference's path component appended to all but the last segment of the base URI's path (i.e., excluding any characters after the right-most \"/\" in the base URI path, or excluding the entire base URI path if it does not contain any \"/\" characters).\n base_path = path.to_s.include?('/') ? path.to_s.sub(/\\/[^\\/]*$/, '/') : ''\n joined_parts[:path] = self.class.normalize_path(base_path + uri.path)\n joined_parts[:query] = uri.query\n end\n joined_parts[:fragment] = uri.fragment\n end\n\n # Return joined URI\n RDF::URI.new(**joined_parts)\n end","def normalize_uri\n if @uri.start_with? '/api/'\n return @uri\n else\n return \"/api/#{@uri}\"\n end\n end","def merge(oth)\n rel = parser.send(:convert_to_uri, oth)\n\n if rel.absolute?\n #raise BadURIError, \"both URI are absolute\" if absolute?\n # hmm... should return oth for usability?\n return rel\n end\n\n unless self.absolute?\n raise BadURIError, \"both URI are relative\"\n end\n\n base = self.dup\n\n authority = rel.userinfo || rel.host || rel.port\n\n # RFC2396, Section 5.2, 2)\n if (rel.path.nil? || rel.path.empty?) && !authority && !rel.query\n base.fragment=(rel.fragment) if rel.fragment\n return base\n end\n\n base.query = nil\n base.fragment=(nil)\n\n # RFC2396, Section 5.2, 4)\n if !authority\n # Difference from URI::Generic -- handle drive letter\n base_path = base.path\n rel_path = rel.path\n if base_path && rel_path\n if rel_path =~ %r[\\A(\\.\\.(?=/|\\z)|/(?![A-Z]:(/|\\z)))]i && base_path.sub!(%r[\\A/?[A-Z]:(?=/|\\z)]i, '')\n base.set_path($~[0] + merge_path(base_path, rel_path))\n else\n base.set_path(merge_path(base_path, rel_path))\n end\n end\n else\n # RFC2396, Section 5.2, 4)\n base.set_path(rel.path) if rel.path\n end\n\n # RFC2396, Section 5.2, 7)\n base.set_userinfo(rel.userinfo) if rel.userinfo\n base.set_host(rel.host) if rel.host\n base.set_port(rel.port) if rel.port\n base.query = rel.query if rel.query\n base.fragment=(rel.fragment) if rel.fragment\n\n return base\n end","def normalize_route_configuration(uri_path, position, configuration_data)\n uri_path = uri_path[1..-1] if uri_path.start_with?('/')\n uri_path = uri_path.chomp('/').split('/')\n recursive_traverse_uri(regex_to_data = {}, position, uri_path, configuration_data)\n end","def test_equality\n uri_string = \"http://foobar.com/xyz/\"\n uri = N::URI.new(uri_string)\n uri_2 = N::URI.new(uri_string)\n uri_other = N::URI.new(\"http://otheruri.com/\")\n \n assert_equal(uri, uri_string)\n assert_equal(uri, uri)\n assert_equal(uri, uri_2)\n assert_not_equal(\"http://something.org\", uri)\n assert_not_equal(uri, uri_other)\n assert_not_equal(uri, Hash.new)\n end","def clean_uri(uri)\n uri = uri.dup\n uri.path = \"\"\n uri.query = nil\n uri.fragment = nil\n uri\n end","def test_normalizes_both_delegate_urls\n p = create('julik', DOMAIN, \n :openid_server => 'xxx.com', :openid_delegate => 'xyz.org/x')\n assert_equal 'xxx.com', p.openid_server, \n \"The URL should be normalized with HTTP scheme and trailing slash\"\n assert_equal 'xyz.org/x', p.openid_delegate, \n \"The URL should be normalized with HTTP scheme\"\n end","def populate_handle\n return unless !self.handle.present? || self.generate_handle\n\n self.handle = handle_base.\n gsub(/[^a-zA-Z0-9]/,'-').\n squeeze('-').\n chomp('-')\n \n self.handle = rand(1000000) if self.handle.empty?\n\n\n base = self.handle\n tries = 1\n\n # Create uniqueness\n while(true)\n match = handle_uniqueness_query(base)\n break unless match.present? && match.id != self.id\n\n base = self.handle + '-' + tries.to_s\n tries += 1\n end\n\n self.handle = base\n end","def initialize(uris=DefaultFile)\n @domain_index ||= {}\n @name_hash ||= {}\n\n update(uris)\n end","def cleanup_urls\n self.url = self.url.to_s.downcase\n end","def normalize_url(url)\n\t\tbegin\n\t\t\turl.strip!\n\t\t\t# Converting the scheme and host to lower case in the process, i.e. 'HTTP://www.Example.com/' => 'http://www.example.com/' \n\t\t\t# Normalize the base\n\t\t\tbase=url_2_site(url) \n\t\t\t# Case#1, remove the trailing dot after the hostname, i.e, 'http://www.yahoo.com./' => 'http://www.yahoo.com/'\n\t\t\tbase=base.sub(/\\.\\/$/,'/')\n\t\t\t# Normalize the relative path, case#1\n\t\t\t# retrieve the file path and remove the first '/' or '.', \n\t\t\t# i.e. 'http://www.example.com/mypath' or 'http://www.example.com/./mypath' => 'mypath'\n\t\t\tpath=url_2_path(url).sub(/^(\\/|\\.)*/,'')\n\t\t\t# Normalize the relative path, case#2\n\t\t\t# Replace dot-segments. \"/../\" and \"/./\" with \"/\", i.e. 'http://www.example.com/../a/b/../c/./d.html\" => 'http://www.example.com/a/c/d.html'\n\t\t\tpath=path.gsub(/\\/\\.{1,2}\\//,'/')\n\t\t\tif path.nil?\n\t\t\t\treturn base\n\t\t\telse\n\t\t\t\treturn base+path\n\t\t\tend\n\t\trescue => ee\n\t\t\tputs \"Exception on method #{__method__} for #{url}: #{ee}\" if @verbose\n\t\t\treturn url\n\t\tend\n\tend","def normalize!\n u = normalize\n @url = URI.parse(u)\n self\n end","def url_shortener(full_uri)\n mapper = UrlMapper.find_by_original_url(full_uri)\n \n if mapper\n string = mapper.short_url\n else\n string = \"/\"\n 5.times { string << (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }\n begin\n UrlMapper.create!({:short_url => string, :original_url => full_uri})\n rescue\n end\n end\n \"#{APP_CONFIG['url_shortener']}#{string}\"\n end","def method_missing_with_named_uri_setting(method_name, *args, &block)\n if uri_name = method_name.to_s[/.*(?=_uri=$)/] and 1 == args.size\n @uris[uri_name.to_sym] = args.first\n else\n method_missing_without_named_uri_setting(method_name, *args, &block)\n end\n end","def process_uri(uri)\n require 'open-uri'\n require 'open_uri_redirections'\n open(uri, :allow_redirections => :safe) do |r|\n r.base_uri.to_s\n end\n end","def build_uri(uri = nil)\n if uri.nil?\n \"#{@path}\"\n else\n [\"#{@path}\", uri].join(\"/\")\n end\n end","def initialize_urls\n find_each(:conditions => {acts_as_url_configuration.url_attribute => nil}) do |instance|\n instance.send :ensure_unique_url\n instance.save\n end\n end"],"string":"[\n \"def normalize_uri(*strs)\\n new_str = strs * '/'\\n new_str = new_str.gsub!('//', '/') while new_str.index('//')\\n new_str\\n end\",\n \"def update_duplicate_uri\\n # Checking if multiple content are present with the same uri the updating the uri\\n duplicate_entries = Content.where(:uri=>self.uri)\\n\\n # Only change the uri if more than one entry is found for the current uri\\n if duplicate_entries.length > 1\\n old_uri = self.uri\\n new_uri = old_uri+'_'+rand(100000).to_s\\n\\n # Updating the current uri with the newly generated uri\\n self.update_attributes(:uri => new_uri)\\n end\\n # End of code for handling the content with same uri\\n end\",\n \"def normalize_uri(*strs)\\n new_str = strs * \\\"/\\\"\\n\\n new_str = new_str.gsub!(\\\"//\\\", \\\"/\\\") while new_str.index(\\\"//\\\")\\n\\n # Makes sure there's a starting slash\\n unless new_str[0,1] == '/'\\n new_str = '/' + new_str\\n end\\n\\n new_str\\n end\",\n \"def uri_normalizer; end\",\n \"def normalize_path(url); end\",\n \"def normalize_path(url); end\",\n \"def paths_sequences_from_uri(uri)\\n paths = uri.paths[0..-2]\\n paths.sequences.uniq.map { |i| i.join('/') }\\n end\",\n \"def test_valid_unc_uris\\n [\\n ['file:////example.com/Share/dir/file.ext', '//example.com/Share/dir/file.ext', '\\\\\\\\\\\\\\\\example.com\\\\\\\\Share\\\\\\\\dir\\\\\\\\file.ext'],\\n ['file://///example.com/Share/dir/file.ext', '//example.com/Share/dir/file.ext', '\\\\\\\\\\\\\\\\example.com\\\\\\\\Share\\\\\\\\dir\\\\\\\\file.ext'],\\n\\n ['file:////localhost/Share/dir/file.ext', '//localhost/Share/dir/file.ext', '\\\\\\\\\\\\\\\\localhost\\\\\\\\Share\\\\\\\\dir\\\\\\\\file.ext'],\\n ['file://///localhost/Share/dir/file.ext', '//localhost/Share/dir/file.ext', '\\\\\\\\\\\\\\\\localhost\\\\\\\\Share\\\\\\\\dir\\\\\\\\file.ext'],\\n ].each do |str, path, unc|\\n uri = URI.parse(str)\\n assert_kind_of( URI::FileCommon, uri )\\n assert_equal( path, uri.path )\\n\\n assert_equal( false, uri.local?(localhost: false) )\\n assert_equal( false, uri.local?(localhost: true) )\\n assert_equal( false, uri.local? )\\n assert_equal( false, uri.local?(localhost: :any) )\\n\\n assert_raise(RuntimeError) { uri.to_file_path(localhost: false) }\\n assert_raise(RuntimeError) { uri.to_file_path(localhost: true) }\\n assert_raise(RuntimeError) { uri.to_file_path }\\n assert_raise(RuntimeError) { uri.to_file_path(localhost: :any) }\\n\\n assert_equal( unc, uri.to_unc(localhost: false) )\\n assert_equal( unc, uri.to_unc(localhost: true) )\\n assert_equal( unc, uri.to_unc )\\n assert_equal( unc, uri.to_unc(localhost: :any) )\\n end\\n end\",\n \"def normalize_uri\\r\\n self.link = Addressable::URI.heuristic_parse(self.link).normalize!.to_s if self.link\\r\\n end\",\n \"def map *paths\\n return if locked?\\n @base_url = rootify_url(paths.shift.to_s).freeze\\n @canonicals = paths.map { |p| rootify_url(p.to_s) }.freeze\\n end\",\n \"def normalize_uri\\n \\n # Don't do anything on blanks\\n return if self.uri.blank?\\n\\n # Try to parse, and set to nil if it fails\\n uri = Addressable::URI.heuristic_parse(self.uri) rescue nil\\n\\n # Seems like it's possible to get here with a non-blank URI\\n return if uri.blank?\\n\\n # Normalize it!\\n self.uri = uri.normalize.to_s\\n\\n end\",\n \"def extract_uris(uri, uri_content)\\n # file must be a directory\\n if !File.directory?(uri) then\\n return Array.new()\\n end\\n\\n # creating the new uris container\\n new_uris = Array.new()\\n\\n # getting the children of the 'uri' folder\\n Dir.foreach(uri) do |f|\\n # building the new uri path\\n path = \\\"#{uri}/#{f}\\\"\\n\\n # appending the new uris values if they aren't the '.' and '..' directories\\n if f != '.' and f != '..' then\\n new_uris << path\\n end\\n end\\n\\n # returning the new uris\\n return new_uris\\n end\",\n \"def normalize\\n uri = dup\\n uri.normalize!\\n uri\\n end\",\n \"def normalize_url(path)\\n @known_pairs ||= {}\\n @public_directories_regex ||= Regexp.new(Bones.public_directories.join('|'))\\n \\n if v = @known_pairs[path]\\n return v\\n else\\n value = case\\n when path =~ /^(\\\\w{3,}:\\\\/\\\\/|mailto)/\\n # don't do anything to this type of URL\\n return path\\n when path =~ @public_directories_regex\\n path\\n when File.directory?('pages' / path)\\n path\\n else\\n # don't add .html if there's already an extension\\n path =~ /\\\\..+/ ? path : path + '.html'\\n end\\n \\n @known_pairs[path] = options.base / value\\n end \\n end\",\n \"def update_paths_linked_to_from_path(document)\\n document.domain_specific_paths.each do |url|\\n link_uri_path = normalize_path Addressable::URI.parse(url.strip).path\\n document_uri_path = normalize_path document.uri.path\\n next if link_uri_path == document_uri_path\\n\\n store_path link_uri_path\\n store_path_linked_to_from(link_uri_path, [document_uri_path])\\n end\\n end\",\n \"def uri_normalize(uri)\\n \\treturn 'http://' + uri unless uri =~ /http:\\\\/\\\\//\\n \\turi\\n\\tend\",\n \"def uri_normalize(uri)\\n \\treturn 'http://' + uri unless uri =~ /http:\\\\/\\\\//\\n \\turi\\n\\tend\",\n \"def short_url_algorithm()\\n \\n unique_id_length = 3\\n base64 = Base64.encode64(self.original_url)\\n join_url = (base64.split('')).sample(unique_id_length).join()\\n safe_url = join_url.gsub(\\\"+\\\", \\\"-\\\").gsub(\\\"/\\\",\\\"_\\\")\\n \\n loop do \\n self.short_url = @@URL + safe_url\\n \\n if Url.find_by_short_url(self.short_url).nil?\\n break\\n else\\n unique_id_length = unique_id_length + 1\\n end\\n \\n end\\n \\n end\",\n \"def fix_paths(doc, count, path)\\n doc.xpath('//img').each do |x|\\n if x['src'].start_with?('//') or x['src'].start_with?('media')\\n next\\n end\\n if x['src'].start_with?('/')\\n x['src'] = Array.new(count, \\\"../\\\").join + x['src']\\n end\\n end\\n doc.xpath('//link[@rel=\\\"stylesheet\\\"]').each do |y|\\n if y['href'].start_with?('/')\\n y['href'] = Array.new(count, \\\"../\\\").join + y['href']\\n end\\n end\\n doc.xpath('//a').each do |z|\\n # Ignore links that only go to anchors.\\n if !z['href']\\n next\\n end\\n # Ignore links to anchors and real pages.\\n if z['href'].start_with?('#') or z['href'].start_with?('http')\\n next\\n end\\n\\n # Actually rewrite the paths now.\\n if z['href'] == '/'\\n z['href'] = 'http://logstash.net/'\\n end\\n # Don't rewrite paths that already contain '.html'\\n if z['href'] =~ /\\\\.html/\\n next\\n end\\n\\n url, hash = z['href'].split('#')\\n url += '.html'\\n url = \\\"#{url}\\\\##{hash}\\\" if hash\\n z['href'] = url\\n end\\nend\",\n \"def normalize_links!\\n # TODO: normalize Array of Symbol, String, DM::Property 1-jump-away or DM::Query::Path\\n end\",\n \"def rebase_hrefs(input, base_uri)\\n Utils.rebase_hrefs(input, base_uri) rescue input\\n end\",\n \"def check_uri_build\\n\\n end\",\n \"def normalize_url\\n return if self.url.blank?\\n normalized = self.url.normalize\\n if normalized.blank?\\n self.errors.add(:url, \\\"is invalid\\\")\\n return false\\n elsif normalized.match(\\\"archiveofourown.org/users\\\")\\n self.errors.add(:url, \\\"cannot be ao3 user\\\")\\n return false\\n elsif normalized.match(\\\"(.*)/collections/(.*)/works/(.*)\\\")\\n normalized = $1 + \\\"/works/\\\" + $3\\n elsif normalized.match(\\\"archiveofourown.org/collections\\\")\\n self.errors.add(:url, \\\"cannot be an ao3 collection\\\")\\n return false\\n end\\n self.url = normalized\\n end\",\n \"def process_uris(element, value, evaluation_context, base, **options)\\n return [] if value.to_s.empty?\\n add_debug(element) {\\\"process_uris: #{value}\\\"}\\n value.to_s.split(/\\\\s+/).map {|v| process_uri(element, v, evaluation_context, base, **options)}.compact\\n end\",\n \"def path_set(path)\\n absolute_path = (Pathname.new(uri.path) + path).to_s\\n rebuild_uri :path => absolute_path\\n end\",\n \"def resolve\\n\\n uri_to_be_resolved = @uri.clone\\n \\n \\n if script? uri_to_be_resolved\\n full_path = replace_script_aliases(uri_to_be_resolved)\\n elsif alias? uri_to_be_resolved\\n full_path = replace_aliases(uri_to_be_resolved)\\n else\\n full_path = File.join(@conf.document_root,uri_to_be_resolved)\\n @uri_without_doc_root = uri_to_be_resolved.clone\\n end\\n\\n if (! File.file? full_path) && ( @http_method.casecmp(\\\"PUT\\\") != 0)\\n full_path = File.join(full_path,get_directory_index)\\n end \\n \\n @resolved_uri = full_path.clone\\n full_path \\n end\",\n \"def comparable_uri(string)\\n if uri?(string)\\n uri = URI.parse(string)\\n # Strip any \\\"www.\\\" from host\\n host = uri.host.sub(/www\\\\./,'')\\n # Treat an empty path as \\\"/\\\"\\n path = (uri.path.nil? or uri.path.empty?) ? \\\"/\\\" : uri.path\\n # If path doesn't end with a slash, add it\\n path = path.end_with?(\\\"/\\\") ? path : path + \\\"/\\\"\\n # Return [host]/[path]\\n host + path\\n else\\n # If not a URI, just return empty string\\n # We don't want to compare or keep around non-URIs\\n \\\"\\\"\\n end\\nend\",\n \"def update_file_paths \\n if self.url_part_was && self.url_part && self.short_name_changed?\\n old_url_part = self.url_part\\n old_ref_path = self.assignment_reference_repository.git_path\\n set_url_part\\n \\n if old_url_part == self.url_part\\n # Nothing changes\\n return\\n end\\n \\n self.save\\n \\n # Move reference repository folder if necessary\\n if File.directory?(old_ref_path) \\n new_ref_path = String.new(old_ref_path)\\n new_ref_path[new_ref_path.index(File.basename(new_ref_path))..-1] = self.url_part\\n \\n FileUtils.mv old_ref_path, new_ref_path\\n end\\n \\n # Move assignment repositories if necessary\\n self.assignment_offerings.each do |assignment_offering|\\n old_assignment_repo_path = File.join(\\n assignment_offering.course_offering.storage_path,\\n 'assignments',\\n old_url_part)\\n \\n if File.directory?(old_assignment_repo_path)\\n new_assignment_repo_path = File.join(\\n assignment_offering.course_offering.storage_path,\\n 'assignments',\\n self.url_part) \\n \\n FileUtils.mv old_assignment_repo_path, new_assignment_repo_path\\n end \\n \\n end\\n end\\n end\",\n \"def process_uri(uri)\\n # empty --> this is like an abstract class method\\n end\",\n \"def get_possible_uris(page)\\n\\n @wiki_full_uri = getWikiRepositoryUrl\\n\\n @uri = URI.parse(@wiki_full_uri)\\n\\n pageName = page.data['wikiPageName'] # Page name\\n\\n @patterns = []\\n\\n # page name can have different working forms ranging from \\\"page name\\\" to \\\"Page-Name\\\"\\n possible_name = [pageName]\\n # normalize to lowercase and - as separator\\n possible_name += [pageName.gsub(' ', '-').downcase] #page-name\\n possible_name += camel_case(pageName, '-') #Page-name + Page name\\n possible_name += camel_caps(pageName, '-') #Page-Name + Page Name\\n possible_name += [pageName.gsub('-', ' ').downcase] #page name\\n\\n possible_name.uniq.each do |name|\\n @patterns += [\\n # possible WORKING internal links patterns that can be found in wiki pages\\n # [link text](https://github.com/userName/RepositoryName/wiki/Page-name)\\n @wiki_full_uri + '/' + name,\\n # [link text](https://github.com/userName/RepositoryName/wiki/Page-name/) trailing slash\\n @wiki_full_uri + '/' + name + '/',\\n # [link text](/userName/RepositoryName/wiki/Page-name)\\n @uri.path + '/' + name,\\n # [link text](/userName/RepositoryName/wiki/Page-name/) trailing slash\\n @uri.path + '/' + name + '/',\\n # [link text](Page-name)\\n name\\n ]\\n end\\n\\n # Home page has two other patterns that are the wiki root url with no page name\\n # because Home is the default page\\n if pageName.downcase == 'home'\\n @patterns += [\\n # home page direct uris\\n # [link text](https://github.com/userName/RepositoryName/wiki)\\n @wiki_full_uri,\\n # [link text](https://github.com/userName/RepositoryName/wiki) trailing slash\\n @wiki_full_uri + '/',\\n # [link text](/userName/RepositoryName/wiki)\\n @uri.path,\\n # [link text](/userName/RepositoryName/wiki) trailing slash\\n @uri.path + '/'\\n ]\\n end\\n\\n return @patterns\\n end\",\n \"def extract_uris(uri, uri_content)\\n # empty --> this is like an abstract class method\\n end\",\n \"def extract_uris(uri, uri_content)\\n # in our case, no new uri can be extracted from a web resource\\n return Array.new()\\n end\",\n \"def normalize_path(path); end\",\n \"def normalize_path(path); end\",\n \"def more_general_uri?(uri1, uri2)\\n ua1 = uri1.nil? ? [] : uri1.split('/')\\n ua2 = uri2.nil? ? [] : uri2.split('/')\\n ua1.each_with_index do |p, i|\\n return false unless ua2[i] == p\\n end\\n true\\n end\",\n \"def normalize_uri(uri)\\n (uri =~ /^(https?|ftp|file):/) ? uri : \\\"http://#{uri}\\\"\\n end\",\n \"def parse_uri(input)\\n lines = parse_input input\\n extract_uri lines\\n end\",\n \"def map_paths(orig = @orig, dest = @dest, path = [])\\n\\n\\t\\t# we have to duplicate each path array to its own object\\n\\t\\t# to ensure it isn't contaminated by another iteration\\n\\t\\tpath = path.dup\\n\\t\\tpath << orig\\n\\n\\t\\tif orig == dest\\n\\t\\t\\tif !@successful_paths.include?(path)\\n\\t\\t\\t\\t@successful_paths << path\\n\\t\\t\\t\\treturn\\n\\t\\t\\tend\\n\\t\\telse\\n\\t\\t\\t# get connections\\n\\t\\t\\tconnections = orig.connected\\n\\t\\t\\t# remove previous stops from possible connections list\\n\\t\\t\\tconnections = connections - path\\n\\t\\t\\tconnections.each do |c|\\n\\t\\t\\t\\tmap_paths(c, dest, path)\\n\\t\\t\\tend\\n\\t\\tend\\n\\tend\",\n \"def hash_by_uri\\n @hash_by_uri ||= begin\\n result = {}\\n flatten_hierarchy.each do |c|\\n result[c.uri.to_s]=c\\n end\\n result\\n end\\n end\",\n \"def extract_domain_specific_paths\\n links.map do |link|\\n uri = Addressable::URI.parse(link.strip)\\n if uri.hostname.nil? || uri.hostname == @uri.hostname\\n normalize_path uri.path\\n end\\n end.compact\\n end\",\n \"def normalize_uri(uri)\\n (uri =~ /^(https?|ftp|file):/) ? uri : \\\"http://#{uri}\\\"\\n end\",\n \"def migrate_linked_file?(uri)\\n host = uri.host.to_s\\n path = uri.path.to_s\\n if(host == 'www.ctcc.uio.no')\\n if(path != '/' and path != '')\\n return true\\n else\\n return false\\n end\\n elsif(host != '')\\n return false\\n end\\n return super(uri)\\n end\",\n \"def update_uri(p)\\n update_attribute(:uri_actual, p)\\n end\",\n \"def normalize_url(url); end\",\n \"def normalize_paths(paths)\\n paths = [paths] unless paths.is_a?(Array)\\n paths.map(&:dup).map do |path|\\n raise ArgumentError.new(\\\"Invalid path: #{path}\\\") unless valid_path?(path)\\n # Strip leading slash from extension path\\n path.gsub!(/^\\\\/(?=\\\\*.)/, '')\\n # Escape some valid special characters\\n path.gsub!(/[.+$\\\"]/) {|s| '\\\\\\\\' + s}\\n # Replace * wildcards with .* regex fragment\\n path.gsub!(/\\\\*/, '.*')\\n \\\"^#{path}#{END_URL_REGEX}\\\"\\n end\\nend\",\n \"def calculate_uri(uri)\\n if uri[0] != '/' && uri.index('://') && uri.index('://') > 0\\n uri = ::URI.split(uri)[5] # path component of uri\\n end\\n\\n uri = Uri.normalize(uri.gsub('//', '/'))\\n base_uri = Uri.normalize(self.base_uri)\\n\\n if uri.index(base_uri) == 0\\n return Http::UrlUtil.decode_path(uri[base_uri.length..-1]).gsub(%r{^/+}, '').gsub(%r{/+$}, '')\\n\\n elsif \\\"#{uri}/\\\" == base_uri\\n # A special case, if the baseUri was accessed without a trailing\\n # slash, we'll accept it as well.\\n return ''\\n else\\n fail Exception::Forbidden, \\\"Requested uri (#{uri}) is out of base uri (#{self.base_uri})\\\"\\n end\\n end\",\n \"def test_valid_nonlocal_uris\\n [\\n ['file://example.com/Share/dir/file.ext', 'example.com', '/Share/dir/file.ext', '\\\\\\\\\\\\\\\\example.com\\\\\\\\Share\\\\\\\\dir\\\\\\\\file.ext'],\\n ['file://example.com/Share/dir/file.ext', 'example.com', '/Share/dir/file.ext', '\\\\\\\\\\\\\\\\example.com\\\\\\\\Share\\\\\\\\dir\\\\\\\\file.ext'],\\n ].each do |str, host, path, unc|\\n uri = URI.parse(str)\\n assert_kind_of( URI::FileCommon, uri )\\n assert_equal( path, uri.path )\\n assert_equal( host, uri.host )\\n\\n assert_equal( false, uri.local?(localhost: false) )\\n assert_equal( false, uri.local?(localhost: true) )\\n assert_equal( false, uri.local? )\\n assert_equal( true, uri.local?(localhost: :any) )\\n\\n assert_raise(RuntimeError) { uri.to_file_path(localhost: false) }\\n assert_raise(RuntimeError) { uri.to_file_path(localhost: true) }\\n assert_raise(RuntimeError) { uri.to_file_path }\\n assert_equal( path, uri.to_file_path(localhost: :any) )\\n\\n assert_equal( unc, uri.to_unc(localhost: false) )\\n assert_equal( unc, uri.to_unc(localhost: true) )\\n assert_equal( unc, uri.to_unc )\\n assert_raise(RuntimeError) { uri.to_unc(localhost: :any) }\\n end\\n end\",\n \"def build_url(url)\\n # this will remove any of the blank spaces. There is no reason for blank space in the url or brake lines\\n url = url.gsub(\\\" \\\", \\\"\\\").gsub(/\\\\n/, \\\"\\\").gsub(/\\\\r/, \\\"\\\")\\n \\n \\n # Step one tells me that the uri does have a http or a https to use\\n one = url.slice(/(https|http)/)\\n if one.nil?\\n request_response = \\\"http://\\\"\\n uri_split = url.split(\\\".\\\")\\n else\\n request_response = url.split(\\\"//\\\")[0] + \\\"//\\\"\\n uri_split = url.split(\\\"//\\\")[1].split(\\\".\\\")\\n end\\n \\n # Step two and three check for the .com and www at the begging. \\n # The count is to make sure that is it missing something and not just taking the place of a sub domain.\\n if uri_split.count <= 2\\n two = url.slice(/(com|gov|org|net|mobi)/)\\n three = url.slice(/(www)/)\\n # don't add if the thing is there\\n if three.nil?\\n uri_split.unshift(\\\"www\\\")\\n end\\n if two.nil?\\n uri_split << \\\"com\\\"\\n end\\n end\\n path_seperator = uri_split[uri_split.length - 1].split(/\\\\//)\\n if path_seperator && path_seperator.length <= 1\\n uri_split[uri_split.length - 1] = path_seperator\\n end\\n string = uri_split.map{ |split| split }.join(\\\".\\\").to_s\\n # I can't figure this part out but it sucks\\n path_thing = string.split(/\\\\//) \\n unless url.blank?\\n url = request_response + string\\n end\\n end\",\n \"def normalize_options(uri_or_options)\\n case uri_or_options\\n when String, Addressable::URI then DataObjects::URI.parse(uri_or_options).attributes\\n when DataObjects::URI then uri_or_options.attributes\\n when Pathname then {:path => uri_or_options}\\n else\\n uri_or_options[:path] ||= uri_or_options.delete(:config) || uri_or_options.delete(:database)\\n uri_or_options\\n end\\n end\",\n \"def create_uri\\n end\",\n \"def fix_url\\n self.url = UrlNormalizer.normalize_entry_url self.url, self\\n end\",\n \"def coerce_uri incoming_uri\\n if incoming_uri.is_a? Hash\\n Addressable::URI.new deep_hash_normalize(incoming_uri)\\n elsif incoming_uri\\n Addressable::URI.parse incoming_uri\\n end\\n end\",\n \"def normalize_paths(paths)\\n # do the hokey-pokey of path normalization...\\n paths = paths.collect do |path|\\n path = path.\\n gsub(\\\"//\\\", \\\"/\\\"). # replace double / chars with a single\\n gsub(\\\"\\\\\\\\\\\\\\\\\\\", \\\"\\\\\\\\\\\"). # replace double \\\\ chars with a single\\n gsub(%r{(.)[\\\\\\\\/]$}, '\\\\1') # drop final / or \\\\ if path ends with it\\n\\n # eliminate .. paths where possible\\n re = %r{[^/\\\\\\\\]+[/\\\\\\\\]\\\\.\\\\.[/\\\\\\\\]}\\n path.gsub!(re, \\\"\\\") while path.match(re)\\n path\\n end\\n\\n # start with longest path, first\\n paths = paths.uniq.sort_by { |path| - path.length }\\n end\",\n \"def normalize(sources)\\n normalized = sources.map do |source|\\n uri = URI.parse(source[:url])\\n next unless uri.scheme =~ /\\\\Ahttps?\\\\z/\\n\\n s = {}\\n s[:url] = \\\"#{uri.scheme}://#{uri.host}#{uri.path.gsub(/.git$/, '')}\\\"\\n s[:token] = uri.user if uri.user\\n s[:branch] = uri.fragment if uri.fragment\\n source.merge(s)\\n end\\n normalized.compact\\n end\",\n \"def post_process_uri( val )\\n\\t\\t\\treturn URI.parse( val.to_s )\\n\\t\\trescue URI::InvalidURIError => err\\n\\t\\t\\tself.log.error \\\"Error trying to parse URI %p: %s\\\" % [ val, err.message ]\\n\\t\\t\\treturn nil\\n\\t\\trescue NoMethodError\\n\\t\\t\\tself.log.debug \\\"Ignoring bug in URI#parse\\\"\\n\\t\\t\\treturn nil\\n\\t\\tend\",\n \"def categorize_uri(str)\\n regex = /\\\\.+/ # really simple host regex to thwart unwanted strings\\n str = \\\"http://#{str}\\\" unless str.to_s =~ %r{\\\\Ahttps?://}\\n uri = URI.parse(str.to_s)\\n path = uri.path.chomp('/')\\n return :unknown if (uri.host =~ regex).nil?\\n\\n path.empty? ? :host : :url\\n rescue URI::InvalidURIError\\n :unknown\\n end\",\n \"def remap! root, *given_canonicals\\n return if mounted?\\n new_base_url = rootify_url(root, base_url)\\n new_canonicals = Array.new(canonicals + given_canonicals)\\n canonicals.each do |ec|\\n # each existing canonical should be prepended with new root\\n new_canonicals << rootify_url(new_base_url, ec)\\n # as well as with each given canonical\\n given_canonicals.each do |gc|\\n new_canonicals << rootify_url(gc, ec)\\n end\\n end\\n map new_base_url, *new_canonicals.uniq\\n end\",\n \"def __build_path(entries)\\n parts = entries[0][:path].split('/')\\n parts.pop(entries[0][:chunks].length)\\n parts.join('/') # stitch parts together to form a path\\n end\",\n \"def modify_uri\\n uri = @request.uri\\n @conf.aliases.each do |a|\\n if uri.include? a\\n uri = uri.sub(a, @conf.alias_path(a))\\n end\\n end\\n if uri != @request.uri\\n return uri\\n end\\n @conf.script_aliases.each do |a|\\n if uri.include? a\\n uri = uri.sub(a, @conf.script_alias_path(a))\\n end\\n end\\n uri\\n end\",\n \"def update_photo_urls(records, subdirectories)\\r\\n\\r\\n updated_records = []\\r\\n\\r\\n records.each do |record_hash|\\r\\n\\r\\n urls_array = generate_image_urls(record_hash[\\\"photos\\\"], subdirectories)\\r\\n record_hash[\\\"photos\\\"] = urls_array\\r\\n updated_records.push(record_hash)\\r\\n\\r\\n end\\r\\n\\r\\n return updated_records \\r\\n\\r\\nend\",\n \"def fix_oneoff url\\n begin\\n uri = URI.parse url\\n return (\\\"\\\" == uri.path) ? url + '/' : url\\n rescue\\n #puts \\\"Ran into issue processing #{url}\\\"\\n end\\n end\",\n \"def build_uri(uri)\\n return uri if @region.nil? && @edge.nil?\\n\\n parsed_url = URI(uri)\\n pieces = parsed_url.host.split('.')\\n product = pieces[0]\\n domain = pieces[-2, 2]\\n new_edge = @edge\\n new_region = @region\\n\\n case pieces.length\\n when 4\\n new_region ||= pieces[1]\\n when 5\\n new_edge ||= pieces[1]\\n new_region ||= pieces[2]\\n end\\n\\n new_region = @@default_region if !new_edge.nil? && new_region.nil?\\n\\n parsed_url.host = [product, new_edge, new_region, domain].reject(&:nil?).join('.')\\n parsed_url.to_s\\n end\",\n \"def map(url, *args)\\n #if the last element of args is a hash, take it off and set options\\n #to it. Now, if that was there, it should be a hash containing key\\n #'default', which, itself has a key of another hash\\n #if it wasn't there, then sed options{:default} to the empty Hash\\n options = {}\\n options = args.pop if args[-1].is_a?(Hash)\\n options[:default] ||= {}\\n\\n #set destintation to nil, and then set it to whatever is at\\n #the last inddex of args. Which looks like should be 0 because\\n #after that pop, if there's anything left, then we raise an error\\n destination = nil\\n destination = args.pop if args.size > 0\\n raise \\\"Too many args!\\\" if args.size > 0\\n\\n #similar to how we did in controller_and_action get the parts of the\\n #url split up into an array based on the forward slash, then take\\n #out empty parts (so if the url contained \\\"//\\\")\\n parts = url.split(\\\"/\\\")\\n parts.reject! { |part| part.empty? }\\n\\n #vars and regex_parts are both set to the empty array\\n vars, regex_parts = [], []\\n\\n #so now loop through each part of the array. Each of which is a\\n #String\\n parts.each do |part|\\n #so we're looking at the first letter\\n case part[0]\\n #if it's a colon, add every following character to the next\\n #index of vars. Then put in the next index of regex_parts\\n #that the thing to match is any alphanumeric character\\n #SO VARS WILL CONTAIN ALL OF OUR SYMBOLS - PATTERNS like\\n #:controller, :action, :id\\n when \\\":\\\"\\n vars << part[1..-1]\\n regex_parts << \\\"([a-zA-Z0-9]+)\\\"\\n #if it's a star, add every following character to the next\\n #index of vars. And regex_parts gets a /.*/ to match on\\n when \\\"*\\\"\\n vars << part[1..-1]\\n regex_parts << \\\"(.*)\\\"\\n #otherwise, regex_parts simple gets the string at this part of the\\n #url (always ignoring \\\"/\\\" from the URL of course)\\n else\\n regex_parts << part\\n end\\n end\\n\\n #ok so now we're combining all of the regex parts into a single\\n #string, which will be our total regex to match on later\\n\\n #vars is an array that contains all of the strings that had : or *\\n #at the beginning\\n\\n #destination is either nil or what was at index 0 of args\\n #options is either a blank hash or what was the hash at inded 1\\n #of args\\n regex = regex_parts.join(\\\"/\\\")\\n @rules.push({ regex: Regexp.new(\\\"^/#{regex}$\\\"),\\n vars: vars, destination: destination,\\n options: options })\\n end\",\n \"def field_path_transform(s_share,s_path)\\n src_path = @fields[s_path]\\n return if src_path.nil? || src_path.empty?\\n notify \\\"Spliting Path:#{s_path} to #{s_share}\\\"\\n result = path_transform(@fields[s_path])\\n return if result.values.any?{|val| val.nil?}\\n @fields[s_path] = result[:path]\\n @fields[s_share] = result[:share]\\n patch_url_from_field([s_share,s_path])\\n end\",\n \"def normalize_uri(uri, parent_uri = nil)\\n return nil if uri.nil?\\n\\n normalized = uri.is_a?(URI) ? uri : URI.parse(uri)\\n\\n if normalized.relative?\\n return nil if !parent_uri\\n normalized = URI.parse(parent_uri).merge(normalized)\\n end\\n\\n scheme = normalized.scheme\\n allowed_schemes = [ 'http' ]\\n allowed_schemes << 'https' if @options[:allow_ssl]\\n return nil unless allowed_schemes.include?(scheme)\\n\\n normalized = normalized.normalize\\n\\n query_string = normalized.select(:query)[0]\\n normalized = normalized.select(:host, :path).join\\n normalized += \\\"?#{query_string}\\\" if query_string\\n\\n normalized = CGI.unescape(normalized)\\n normalized = \\\"#{scheme}://#{normalized}\\\"\\n normalized = normalized.split('#').first\\n \\n return normalized\\n end\",\n \"def initialize_urls\\n find(:all, :conditions => {self.url_attribute => nil}).each do |instance|\\n instance.send :ensure_unique_url\\n instance.save\\n end\\n end\",\n \"def test_valid_localhost_uris\\n [\\n ['file://localhost/path/to/file', '/path/to/file', '\\\\\\\\\\\\\\\\localhost\\\\\\\\path\\\\\\\\to\\\\\\\\file'],\\n ].each do |str, path, unc|\\n uri = URI.parse(str)\\n assert_kind_of( URI::FileCommon, uri )\\n assert_equal( path, uri.path )\\n\\n assert_equal( false, uri.local?(localhost: false) )\\n assert_equal( true, uri.local?(localhost: true) )\\n assert_equal( true, uri.local? )\\n assert_equal( true, uri.local?(localhost: :any) )\\n\\n assert_raise(RuntimeError) { uri.to_file_path(localhost: false) }\\n assert_equal( path, uri.to_file_path(localhost: true) )\\n assert_equal( path, uri.to_file_path )\\n assert_equal( path, uri.to_file_path(localhost: :any) )\\n\\n assert_equal( unc, uri.to_unc(localhost: false) )\\n assert_raise(RuntimeError) { uri.to_unc(localhost: true) }\\n assert_raise(RuntimeError) { uri.to_unc }\\n assert_raise(RuntimeError) { uri.to_unc(localhost: :any) }\\n end\\n end\",\n \"def dedupe_by_uri(records)\\n result = []\\n seen = {}\\n\\n records.reverse.each do |record|\\n if !seen[record['uri']]\\n result << record\\n seen[record['uri']] = true\\n end\\n end\\n\\n result.reverse\\n end\",\n \"def dedupe_by_uri(records)\\n result = []\\n seen = {}\\n\\n records.reverse.each do |record|\\n if !seen[record['uri']]\\n result << record\\n seen[record['uri']] = true\\n end\\n end\\n\\n result.reverse\\n end\",\n \"def process_url(ancestors_path, item)\\n default_urlname = (ancestors_path.blank? ? \\\"\\\" : \\\"#{ancestors_path}/\\\") + item['slug'].to_s\\n\\n pair = {my_urlname: default_urlname, children_path: default_urlname}\\n\\n if item['external'] == true || item['visible'] == false\\n # children ignore an ancestor in their path if external or invisible\\n pair[:children_path] = ancestors_path\\n end\\n\\n pair\\n end\",\n \"def setup_uri_path\\n self.uri_path = self.class.scope_from_uri(self.uri)\\n end\",\n \"def normalize_uri uri\\n (uri =~ /^https?:/) ? uri : \\\"http://#{uri}\\\"\\n end\",\n \"def fix_relative_path(entry)\\n feed_url = Addressable::URI.parse(url)\\n entry.url = feed_url.scheme + '://' + feed_url.host + entry.url\\n end\",\n \"def validate_relative_uri( uri, dir, doc )\\n return validate_anchor(uri, doc) if uri.path.empty?\\n\\n path = if uri.path =~ %r/^\\\\//\\n ::File.join(::Webby.site.output_dir, uri.path)\\n else\\n ::File.join(dir, uri.path)\\n end\\n path = ::File.join(path, 'index.html') if ::File.extname(path).empty?\\n\\n uri_str = path.dup\\n (uri_str << '#' << uri.fragment) if uri.fragment\\n return if @valid_uris.include? uri_str\\n\\n if test ?f, path\\n valid = if uri.fragment\\n validate_anchor(uri, Hpricot(::File.read(path)))\\n else true end\\n @valid_uris << uri_str if valid\\n else\\n @log.error \\\"invalid URI '#{uri.to_s}'\\\"\\n end\\n end\",\n \"def uri=(_arg0); end\",\n \"def uri=(_arg0); end\",\n \"def uri=(_arg0); end\",\n \"def uri=(_arg0); end\",\n \"def change_hrefs(html)\\n DOM.walk(html) do |node|\\n for attr_name in %w{href src}\\n attr_obj = node.attributes[attr_name]\\n\\n # Ignore if its blank\\n next if !attr_obj\\n\\n # URL encode any spaces\\n orig_href = attr_obj.to_s.gsub(\\\" \\\", \\\"%20\\\")\\n\\n begin\\n src = URI(orig_href)\\n rescue\\n log \\\"#{orig_href} not a valid URI\\\"\\n next\\n end\\n\\n if internal_link?(src.to_s)\\n linked_item = nil\\n\\n if src.path == \\\"\\\"\\n # If its just an anchor like '#this' just set to the current file\\n linked_item = self\\n else\\n # Match on the unescaped href\\n unescaped_path = URI::unescape(src.path)\\n linked_item = get_item(unescaped_path)\\n end\\n\\n # Change link\\n if linked_item\\n new_path = linked_item.normalized_hashed_path(:relative_to => self)\\n new_path = URI(new_path)\\n\\n if src.fragment\\n new_path.fragment = src.fragment\\n end\\n\\n log \\\"Changing #{src.to_s} to #{new_path.to_s}\\\"\\n attr_obj.content = new_path.to_s\\n else\\n log \\\"No item in manifest for #{src}\\\"\\n end\\n end\\n end\\n end\\n end\",\n \"def uri\\n @uri ||= select { |type,value| type == :uri }.map do |(type,value)|\\n URI.parse(value)\\n end\\n end\",\n \"def parse(uri); end\",\n \"def uri (name,default=\\\"\\\")\\n \\n name=name.to_s\\n #FIXME: bad urls (for example just www.example.com will produce an endless-loop\\n if name.try(:include?, \\\"://\\\")\\n return name[0..name.length-2] if name[-1,1]==\\\"/\\\"\\n return name[0..name.length]\\n else\\n name +=\\\"/\\\" unless (name[name.length-1..name.length-1] == (\\\"/\\\" || \\\"#\\\")) || name.try(:include?, \\\":\\\")\\n\\n if name.index(\\\":\\\") \\n t= @object_namespaces[name.split(\\\":\\\")[0].to_sym]\\n t ||=\\\"\\\"\\n t += \\\"/\\\" unless (t[t.length-1..t.length-1] == (\\\"/\\\" || \\\"#\\\") || t.blank?) || name.try(:include?, \\\":\\\")\\n return uri( t+ normalize_local_name(name.split(\\\":\\\")[1])+\\\"/\\\")\\n else \\n t= default.blank? ? @base_uri : default\\n t += \\\"/\\\" unless t[t.length-1..t.length-1]==\\\"/\\\"\\n return uri( t + normalize_local_name(name))\\n end\\n end\\n end\",\n \"def build_uri\\n unless title.blank?\\n self.uri = title.mb_chars.normalize(:d).split(//u).reject { |e| e.length > 1\\n }.join.gsub(\\\"\\\\n\\\", \\\" \\\").gsub(/[^a-z0-9\\\\-_ \\\\.]+/i, '').squeeze(' '\\n ).gsub(/ |\\\\.|_/, '-').gsub(/\\\\-+/, '-').gsub(/(^\\\\-)|(\\\\-$)/, '').downcase\\n end\\n end\",\n \"def normalize\\n Wgit::Url.new(@uri.normalize.to_s)\\n end\",\n \"def join(*uris)\\n joined_parts = object.dup.delete_if {|k, v| %i(user password host port).include?(k)}\\n\\n uris.each do |uri|\\n uri = RDF::URI.new(uri) unless uri.is_a?(RDF::URI)\\n next if uri.to_s.empty? # Don't mess with base URI\\n\\n case\\n when uri.scheme\\n joined_parts = uri.object.merge(path: self.class.normalize_path(uri.path))\\n when uri.authority\\n joined_parts[:authority] = uri.authority\\n joined_parts[:path] = self.class.normalize_path(uri.path)\\n joined_parts[:query] = uri.query\\n when uri.path.to_s.empty?\\n joined_parts[:query] = uri.query if uri.query\\n when uri.path[0,1] == '/'\\n joined_parts[:path] = self.class.normalize_path(uri.path)\\n joined_parts[:query] = uri.query\\n else\\n # Merge path segments from section 5.2.3\\n # Note that if the path includes no segments, the entire path is removed\\n # > return a string consisting of the reference's path component appended to all but the last segment of the base URI's path (i.e., excluding any characters after the right-most \\\"/\\\" in the base URI path, or excluding the entire base URI path if it does not contain any \\\"/\\\" characters).\\n base_path = path.to_s.include?('/') ? path.to_s.sub(/\\\\/[^\\\\/]*$/, '/') : ''\\n joined_parts[:path] = self.class.normalize_path(base_path + uri.path)\\n joined_parts[:query] = uri.query\\n end\\n joined_parts[:fragment] = uri.fragment\\n end\\n\\n # Return joined URI\\n RDF::URI.new(**joined_parts)\\n end\",\n \"def normalize_uri\\n if @uri.start_with? '/api/'\\n return @uri\\n else\\n return \\\"/api/#{@uri}\\\"\\n end\\n end\",\n \"def merge(oth)\\n rel = parser.send(:convert_to_uri, oth)\\n\\n if rel.absolute?\\n #raise BadURIError, \\\"both URI are absolute\\\" if absolute?\\n # hmm... should return oth for usability?\\n return rel\\n end\\n\\n unless self.absolute?\\n raise BadURIError, \\\"both URI are relative\\\"\\n end\\n\\n base = self.dup\\n\\n authority = rel.userinfo || rel.host || rel.port\\n\\n # RFC2396, Section 5.2, 2)\\n if (rel.path.nil? || rel.path.empty?) && !authority && !rel.query\\n base.fragment=(rel.fragment) if rel.fragment\\n return base\\n end\\n\\n base.query = nil\\n base.fragment=(nil)\\n\\n # RFC2396, Section 5.2, 4)\\n if !authority\\n # Difference from URI::Generic -- handle drive letter\\n base_path = base.path\\n rel_path = rel.path\\n if base_path && rel_path\\n if rel_path =~ %r[\\\\A(\\\\.\\\\.(?=/|\\\\z)|/(?![A-Z]:(/|\\\\z)))]i && base_path.sub!(%r[\\\\A/?[A-Z]:(?=/|\\\\z)]i, '')\\n base.set_path($~[0] + merge_path(base_path, rel_path))\\n else\\n base.set_path(merge_path(base_path, rel_path))\\n end\\n end\\n else\\n # RFC2396, Section 5.2, 4)\\n base.set_path(rel.path) if rel.path\\n end\\n\\n # RFC2396, Section 5.2, 7)\\n base.set_userinfo(rel.userinfo) if rel.userinfo\\n base.set_host(rel.host) if rel.host\\n base.set_port(rel.port) if rel.port\\n base.query = rel.query if rel.query\\n base.fragment=(rel.fragment) if rel.fragment\\n\\n return base\\n end\",\n \"def normalize_route_configuration(uri_path, position, configuration_data)\\n uri_path = uri_path[1..-1] if uri_path.start_with?('/')\\n uri_path = uri_path.chomp('/').split('/')\\n recursive_traverse_uri(regex_to_data = {}, position, uri_path, configuration_data)\\n end\",\n \"def test_equality\\n uri_string = \\\"http://foobar.com/xyz/\\\"\\n uri = N::URI.new(uri_string)\\n uri_2 = N::URI.new(uri_string)\\n uri_other = N::URI.new(\\\"http://otheruri.com/\\\")\\n \\n assert_equal(uri, uri_string)\\n assert_equal(uri, uri)\\n assert_equal(uri, uri_2)\\n assert_not_equal(\\\"http://something.org\\\", uri)\\n assert_not_equal(uri, uri_other)\\n assert_not_equal(uri, Hash.new)\\n end\",\n \"def clean_uri(uri)\\n uri = uri.dup\\n uri.path = \\\"\\\"\\n uri.query = nil\\n uri.fragment = nil\\n uri\\n end\",\n \"def test_normalizes_both_delegate_urls\\n p = create('julik', DOMAIN, \\n :openid_server => 'xxx.com', :openid_delegate => 'xyz.org/x')\\n assert_equal 'xxx.com', p.openid_server, \\n \\\"The URL should be normalized with HTTP scheme and trailing slash\\\"\\n assert_equal 'xyz.org/x', p.openid_delegate, \\n \\\"The URL should be normalized with HTTP scheme\\\"\\n end\",\n \"def populate_handle\\n return unless !self.handle.present? || self.generate_handle\\n\\n self.handle = handle_base.\\n gsub(/[^a-zA-Z0-9]/,'-').\\n squeeze('-').\\n chomp('-')\\n \\n self.handle = rand(1000000) if self.handle.empty?\\n\\n\\n base = self.handle\\n tries = 1\\n\\n # Create uniqueness\\n while(true)\\n match = handle_uniqueness_query(base)\\n break unless match.present? && match.id != self.id\\n\\n base = self.handle + '-' + tries.to_s\\n tries += 1\\n end\\n\\n self.handle = base\\n end\",\n \"def initialize(uris=DefaultFile)\\n @domain_index ||= {}\\n @name_hash ||= {}\\n\\n update(uris)\\n end\",\n \"def cleanup_urls\\n self.url = self.url.to_s.downcase\\n end\",\n \"def normalize_url(url)\\n\\t\\tbegin\\n\\t\\t\\turl.strip!\\n\\t\\t\\t# Converting the scheme and host to lower case in the process, i.e. 'HTTP://www.Example.com/' => 'http://www.example.com/' \\n\\t\\t\\t# Normalize the base\\n\\t\\t\\tbase=url_2_site(url) \\n\\t\\t\\t# Case#1, remove the trailing dot after the hostname, i.e, 'http://www.yahoo.com./' => 'http://www.yahoo.com/'\\n\\t\\t\\tbase=base.sub(/\\\\.\\\\/$/,'/')\\n\\t\\t\\t# Normalize the relative path, case#1\\n\\t\\t\\t# retrieve the file path and remove the first '/' or '.', \\n\\t\\t\\t# i.e. 'http://www.example.com/mypath' or 'http://www.example.com/./mypath' => 'mypath'\\n\\t\\t\\tpath=url_2_path(url).sub(/^(\\\\/|\\\\.)*/,'')\\n\\t\\t\\t# Normalize the relative path, case#2\\n\\t\\t\\t# Replace dot-segments. \\\"/../\\\" and \\\"/./\\\" with \\\"/\\\", i.e. 'http://www.example.com/../a/b/../c/./d.html\\\" => 'http://www.example.com/a/c/d.html'\\n\\t\\t\\tpath=path.gsub(/\\\\/\\\\.{1,2}\\\\//,'/')\\n\\t\\t\\tif path.nil?\\n\\t\\t\\t\\treturn base\\n\\t\\t\\telse\\n\\t\\t\\t\\treturn base+path\\n\\t\\t\\tend\\n\\t\\trescue => ee\\n\\t\\t\\tputs \\\"Exception on method #{__method__} for #{url}: #{ee}\\\" if @verbose\\n\\t\\t\\treturn url\\n\\t\\tend\\n\\tend\",\n \"def normalize!\\n u = normalize\\n @url = URI.parse(u)\\n self\\n end\",\n \"def url_shortener(full_uri)\\n mapper = UrlMapper.find_by_original_url(full_uri)\\n \\n if mapper\\n string = mapper.short_url\\n else\\n string = \\\"/\\\"\\n 5.times { string << (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }\\n begin\\n UrlMapper.create!({:short_url => string, :original_url => full_uri})\\n rescue\\n end\\n end\\n \\\"#{APP_CONFIG['url_shortener']}#{string}\\\"\\n end\",\n \"def method_missing_with_named_uri_setting(method_name, *args, &block)\\n if uri_name = method_name.to_s[/.*(?=_uri=$)/] and 1 == args.size\\n @uris[uri_name.to_sym] = args.first\\n else\\n method_missing_without_named_uri_setting(method_name, *args, &block)\\n end\\n end\",\n \"def process_uri(uri)\\n require 'open-uri'\\n require 'open_uri_redirections'\\n open(uri, :allow_redirections => :safe) do |r|\\n r.base_uri.to_s\\n end\\n end\",\n \"def build_uri(uri = nil)\\n if uri.nil?\\n \\\"#{@path}\\\"\\n else\\n [\\\"#{@path}\\\", uri].join(\\\"/\\\")\\n end\\n end\",\n \"def initialize_urls\\n find_each(:conditions => {acts_as_url_configuration.url_attribute => nil}) do |instance|\\n instance.send :ensure_unique_url\\n instance.save\\n end\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.6556938","0.63961816","0.63835734","0.62619084","0.6094695","0.6094695","0.6003296","0.5844179","0.5820089","0.57403195","0.56830937","0.5653757","0.56386137","0.5622774","0.5588163","0.5544093","0.5544093","0.54867285","0.54861665","0.54801816","0.5473902","0.5450981","0.5434704","0.5421626","0.53944796","0.5381238","0.5371845","0.5355574","0.5325146","0.53159106","0.5311244","0.53107","0.53071535","0.53071535","0.52974635","0.5291279","0.52845925","0.52839464","0.5273694","0.5269883","0.5268871","0.5267297","0.5264129","0.52631104","0.52609295","0.5255308","0.5243094","0.5242492","0.52407694","0.5228783","0.5220878","0.52197516","0.5217272","0.52119476","0.51893973","0.51807183","0.5180683","0.51648825","0.51564485","0.51447934","0.51387066","0.51369214","0.5134358","0.51275414","0.5123351","0.51216346","0.51151836","0.5112872","0.5112872","0.5107825","0.51068705","0.5093049","0.5091381","0.5088813","0.5082137","0.5082137","0.5082137","0.5082137","0.50813705","0.5073744","0.5060825","0.5059702","0.5058067","0.5056161","0.5050814","0.5048391","0.50483584","0.50450885","0.503785","0.503611","0.5034209","0.5032984","0.50254756","0.50209427","0.50208807","0.5017471","0.50172275","0.50171","0.501577","0.50080717","0.50040835"],"string":"[\n \"0.6556938\",\n \"0.63961816\",\n \"0.63835734\",\n \"0.62619084\",\n \"0.6094695\",\n \"0.6094695\",\n \"0.6003296\",\n \"0.5844179\",\n \"0.5820089\",\n \"0.57403195\",\n \"0.56830937\",\n \"0.5653757\",\n \"0.56386137\",\n \"0.5622774\",\n \"0.5588163\",\n \"0.5544093\",\n \"0.5544093\",\n \"0.54867285\",\n \"0.54861665\",\n \"0.54801816\",\n \"0.5473902\",\n \"0.5450981\",\n \"0.5434704\",\n \"0.5421626\",\n \"0.53944796\",\n \"0.5381238\",\n \"0.5371845\",\n \"0.5355574\",\n \"0.5325146\",\n \"0.53159106\",\n \"0.5311244\",\n \"0.53107\",\n \"0.53071535\",\n \"0.53071535\",\n \"0.52974635\",\n \"0.5291279\",\n \"0.52845925\",\n \"0.52839464\",\n \"0.5273694\",\n \"0.5269883\",\n \"0.5268871\",\n \"0.5267297\",\n \"0.5264129\",\n \"0.52631104\",\n \"0.52609295\",\n \"0.5255308\",\n \"0.5243094\",\n \"0.5242492\",\n \"0.52407694\",\n \"0.5228783\",\n \"0.5220878\",\n \"0.52197516\",\n \"0.5217272\",\n \"0.52119476\",\n \"0.51893973\",\n \"0.51807183\",\n \"0.5180683\",\n \"0.51648825\",\n \"0.51564485\",\n \"0.51447934\",\n \"0.51387066\",\n \"0.51369214\",\n \"0.5134358\",\n \"0.51275414\",\n \"0.5123351\",\n \"0.51216346\",\n \"0.51151836\",\n \"0.5112872\",\n \"0.5112872\",\n \"0.5107825\",\n \"0.51068705\",\n \"0.5093049\",\n \"0.5091381\",\n \"0.5088813\",\n \"0.5082137\",\n \"0.5082137\",\n \"0.5082137\",\n \"0.5082137\",\n \"0.50813705\",\n \"0.5073744\",\n \"0.5060825\",\n \"0.5059702\",\n \"0.5058067\",\n \"0.5056161\",\n \"0.5050814\",\n \"0.5048391\",\n \"0.50483584\",\n \"0.50450885\",\n \"0.503785\",\n \"0.503611\",\n \"0.5034209\",\n \"0.5032984\",\n \"0.50254756\",\n \"0.50209427\",\n \"0.50208807\",\n \"0.5017471\",\n \"0.50172275\",\n \"0.50171\",\n \"0.501577\",\n \"0.50080717\",\n \"0.50040835\"\n]"},"document_score":{"kind":"string","value":"0.0"},"document_rank":{"kind":"string","value":"-1"}}},{"rowIdx":1877,"cells":{"query":{"kind":"string","value":"get or prompt for a given proxy's username and password"},"document":{"kind":"string","value":"def proxy_userpass(proxies = [proxy[0]])\n proxies = [proxies] if proxies.class != Array\n proxies.map! {|p| p.downcase }\n userpass = (@@proxy_userpass[proxies[0]] || LinkToLoad.ask_for_userpass('proxy'))\n proxies.each {|p| @@proxy_userpass[p] = userpass }\n userpass\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def get_password(username)\n password = ask(\"password for #{username}:\") { |q| q.echo = false }\n password\nend","def get_password host,username\n print \"Password for \"+username+\"@\"+host+\": \"\n system \"stty -echo\"\n pw = gets.delete(\"\\n\")\n system \"stty echo\"\n puts\n pw\n end","def get_user_input\n print \"username: \"\n username = STDIN.gets.chomp\n\n print \"password: \"\n password = STDIN.noecho(&:gets).chomp\n end","def ask_for_password(prompt)\n ui.ask_for_password prompt\n end","def get_password(prompt='Password: ')\n print prompt\n STDIN.noecho(&:gets).chomp\nend","def ask_credentials\n self.username = cli.prompt \"Your GitHub username: \"\n self.password = cli.prompt_secret \"Your GitHub password (never stored): \"\n end","def ask_for_password\n echo_off\n password = ask\n puts\n echo_on\n return password\n end","def ask_credentials\n self.email = cli.prompt \"Your Pivotal Tracker email: \"\n self.password = cli.prompt_secret \"Your Pivotal Tracker password (never stored): \"\n end","def get_username(prompt = 'Enter Nexpose username: ')\r\n ask(prompt) { |query| query.echo = true }\r\nend","def http_proxy addr, opts={}\n return Net::HTTP unless addr\n\n host, port = addr.split \":\"\n port ||= opts[:port] || 8080\n\n user = opts[:username]\n pass = opts[:password]\n\n Kronk::Cmd.verbose \"Using proxy #{addr}\\n\" if host\n\n Net::HTTP::Proxy host, port, user, pass\n end","def login(options, password = nil) # :yield: recvdata\n login_prompt = /[Ll]ogin[: ]*\\z/n\n password_prompt = /[Pp]ass(?:word|phrase)[: ]*\\z/n\n if options.kind_of?(Hash)\n username = options[\"Name\"]\n password = options[\"Password\"]\n login_prompt = options[\"LoginPrompt\"] if options[\"LoginPrompt\"]\n password_prompt = options[\"PasswordPrompt\"] if options[\"PasswordPrompt\"]\n else\n username = options\n end\n\n if block_given?\n line = waitfor(login_prompt){|c| yield c }\n if password\n line += cmd({\"String\" => username,\n \"Match\" => password_prompt}){|c| yield c }\n line += cmd(password){|c| yield c }\n else\n line += cmd(username){|c| yield c }\n end\n else\n line = waitfor(login_prompt)\n if password\n line += cmd({\"String\" => username,\n \"Match\" => password_prompt})\n line += cmd(password)\n else\n line += cmd(username)\n end\n end\n line\n end","def authentication_prompt( )\n puts \"Username:\"\n username = $stdin.gets.chomp\n puts \"Password:\"\n password = $stdin.gets.chomp\n raise NotAuthorized unless username.match(/\\S/)\n raise NotAuthorized unless password.match(/\\S/)\n return {:u => username, :p => password}\n end","def parse_proxy_info\r\n raw = @env[\"HTTP_PROXY\"] || @env[\"http_proxy\"]\r\n return {} unless raw\r\n\r\n main_str = raw\r\n .strip\r\n .sub(/^http:\\/\\//, \"\")\r\n .sub(/\\/+$/, \"\")\r\n\r\n auth_str = main_str.match(/(.*)@/).to_a[1].to_s\r\n host_str = main_str.sub(/^.*@/, \"\")\r\n {\r\n host: host_str.sub(/:.*$/, \"\"),\r\n port: host_str.match(/:(.*)/).to_a[1].try(:to_i), # int or nil\r\n user: auth_str.sub(/:.*$/, \"\"),\r\n pass: auth_str.sub(/^.*:/, \"\")\r\n }.select { |_, value| value.present? }\r\n end","def askPassword(prompt=\"Enter Password : \")\n ask(prompt) {|q| q.echo = false}\nend","def get_user_details\n prompt = prompt_instance\n system(\"clear\")\n username = prompt.ask(\"Please enter username:\") do |q|\n end\n password = prompt.mask(\"Please enter password:\") do |q|\n end\n return username, password\nend","def fetch(password)\r\n end","def proxyuserpwd=(value)\n Curl.set_option(:proxyuserpwd, value_for(value, :string), handle)\n end","def create_pw_client(opts = {})\n usr = opts[:user] || user()\n pw = opts[:password] || password()\n remote = opts[:remote_name] || self.remote_name\n\n logger.info(\"Authorizing #{usr} to work with #{remote}.\")\n\n configure_octokit(opts)\n\n Octokit::Client.new(:login => usr, :password => pw)\n end","def set_proxy(address, port, user = T.unsafe(nil), password = T.unsafe(nil)); end","def password_prompt(prompt=\"Password: \")\n ui.ask(prompt) { |q| q.echo = false }\n end","def ask_for_creds(user=nil)\n if user\n @username = user\n else\n print \"Enter your GApps email address: \"\n @username = gets.chomp.strip.downcase \n # using highline for input on more than one run of a loop causes intermittent errors\n # in Ruby 1.8.7 on Mac OS X 10.8 for some reason. Changed from the highline 'ask' below\n # to the 'print/gets' above.\n #@username = ask(\"Enter your GApps email address: \").strip.downcase if @username == nil\n end\n @password = ask(\"Enter your password: \") { |q| q.echo = \"x\" }\n end","def question_prompt(field, opts = {})\n trap(\"INT\") { exit 1 }\n begin\n print \"Please input #{field}: \"\n response = opts[:password] ? STDIN.noecho(&:gets).strip : STDIN.gets.strip\n end until not response.empty?\n response\nend","def proxyauth=(value)\n Curl.set_option(:proxyauth, value_for(value, :string), handle)\n end","def setup_credentials\n\n cmd = @config[:path] + @command_line_tool + \" \" + @@login_command\n\n Open3.popen3( cmd ) { |input, output, error|\n input.puts @config[:url]\n input.puts @config[:user]\n input.puts @config[:password]\n input.close\n } \n\n end","def server\n reply = json_get(target, '/login', key_style)\n return reply if reply && (reply[:prompts] || reply['prompts'])\n raise BadResponse, \"Invalid response from target #{target}\"\n end","def set_proxy proxy, port=nil, user=nil, pwd=nil\n\t\t\n\t\t\n\t\tif !proxy\t\n\t\t\t@proxy_host=@proxy_port=@proxy_user=@proxy_pwd=nil \n\t\t\treturn\n\t\tend\n\n\t\tif proxy.class == String \n\t\t\tif !port && !user && !pwd\n\t\t\t\tproxy = URI.parse(proxy)\n\t\t\telse \n\t\t\t\t@proxy_host= host\n\t\t\t\t@proxy_port= port\n\t\t\t\t@proxy_user= user\n\t\t\t\t@proxy_pwd = pwd\n\t\t\tend\n\t\tend\n\t\t\n\t\tif proxy.class == URI::HTTP \n\t\t\t@proxy_host= proxy.host\n\t\t\t@proxy_port= proxy.port\n\t\t\t@proxy_user= proxy.user\n\t\t\t@proxy_pwd = proxy.password\n\t\tend\n\tend","def proxy(to)\n response = connection.post(\"/v1/auth/proxy?to=#{to}\")\n case response.status\n when 200\n Success(response.body)\n else\n Failure(\"Status: #{response.status}\\n#{response.body}\")\n end\n end","def main\n #generate a table of coutries with proxies and the url to find them\n selTable = getCountries(\"https://proxynova.com\")\n selection = []\n url = \"\"\n command = \"gsettings set org.gnome.system.proxy\"\n #generate menu selection based on the selTable output of getCountries\n selTable.each_with_index do |sel, index|\n selection.push(\"#{index + 1}. #{sel[0]}\")\n end #do\n selection.push(\"#{selection.length + 1}. No proxy\")\n options = HighLine.new\n puts options.list(selection, :columns_across)\n chosen = ask(\"Pick your proxy location: \", Integer){|resp| resp.in = 1..selection.length}\n #if you chose the last option, disable the proxy\n if(chosen.eql? selection.length)\n puts \"Proxy disabled.\"\n system \"#{command} mode 'none'\"\n exit\n else #obtain proxy address and port values according to user choice and update system proxy settings\n puts \"#{selection[chosen - 1].split('(')[0].split('.')[1].strip} it is...\"\n proxy = getProxy(selTable[chosen - 1][1])\n system \"#{command}.http host '#{proxy[0]}'\"\n system \"#{command}.http port '#{proxy[1]}'\"\n system \"#{command}.https host '#{proxy[0]}'\"\n system \"#{command}.https port '#{proxy[1]}'\"\n system \"#{command}.socks host '#{proxy[0]}'\"\n system \"#{command}.socks port '#{proxy[1]}'\"\n system \"#{command} mode 'manual'\"\n puts \"Proxy set to #{proxy[0]}:#{proxy[1]}\"\n exit\n end\nend","def using_authenticated_proxy?; end","def proxy_pass; end","def getproxy\n proxy = (ENV['HTTP_PROXY'] == nil)? ENV['http_proxy'] : ENV['HTTP_PROXY']\n return proxy\n end","def ask_for_user_input(msg=nil, opts={})\n print msg if msg\n print \": \"\n STDOUT.flush\n if opts[:password]\n system \"stty -echo\"\n result = STDIN.gets\n system \"stty echo\"\n puts\n else\n result = STDIN.gets\n end\n result.chomp\nend","def login opts={}\n opts = @telnet_options.merge opts\n\n # don't log in if username is not set\n if opts[:username].nil?\n @logged_in = Time.now\n return\n end\n\n begin\n output = waitfor opts[:login_prompt]\n\n if opts[:password]\n # login with username and password\n output << cmd(opts[:username], prompt: opts[:password_prompt])\n output << cmd(opts[:password], hide: true)\n else\n # login with username only\n output << cmd(opts[:username])\n end\n rescue Timeout::Error\n e = LoginFailed.new(\"Timed out while expecting some kind of prompt.\")\n e.set_backtrace $!.backtrace\n raise e\n end\n\n @logged_in = Time.now\n output\n end","def proxy_command\n !config.proxy_user and log_and_raise(SSHError, \"You must specify an proxy user in order to SSH proxy.\")\n !config.proxy_host_name and log_and_raise(SSHError, \"You must specify an proxy host_name in order to SSH proxy.\")\n\n process_keys\n verbosity = ((ENV['LOG_LEVEL'] == \"DEBUG\") ? '-vv' : '-q')\n\n command = Array.new\n # command << [ %(sshpass -p '#{config.proxy_password}') ] if config.proxy_password\n command << [ %(ssh) ]\n command << [ verbosity ]\n command << [ \"-x\" ]\n command << [ \"-a\" ]\n command << [ \"-o\", \"UserKnownHostsFile=/dev/null\" ]\n command << [ \"-o\", \"StrictHostKeyChecking=no\" ]\n command << [ \"-o\", \"KeepAlive=yes\" ]\n command << [ \"-o\", \"ServerAliveInterval=60\" ]\n !config.proxy_keys.nil? and !config.proxy_keys.empty? and [config.proxy_keys].flatten.compact.each do |proxy_key|\n command << [ \"-i\", proxy_key ]\n end\n command << [ \"-p\", config.proxy_port ] if config.proxy_port\n command << \"#{config.proxy_user}@#{config.proxy_host_name}\"\n command << \"'/usr/bin/env nc %h %p'\"\n command = command.flatten.compact.join(' ')\n config.ui.logger.debug { \"proxy_command(#{command.inspect})\" }\n command\n end","def signup # demande un mot de passe sans l'afficher\r\n prompt = \"Définis ton mot de passe, stp > \"\r\n print prompt\r\n $password = STDIN.noecho(&:gets).chomp # mot de passe caché\r\n puts \"\"\r\nend","def prompt_username\n TTY::Prompt.new.ask(\"Redacted username?\", required: true, modify: :strip)\n end","def get_username_and_password_diligently\n while true\n credentials = get_username_and_password_and_authenticate\n if credentials == false\n puts \"Could not authenticate, try again?\"\n puts \"y/n\"\n\n again = STDIN.gets.strip\n case again.downcase\n when \"y\"\n when \"n\"\n return false\n end\n else\n return credentials\n end\n end\n end","def pipproxyarg\n proxy = getproxy\n return ((proxy != nil) ? [\"--proxy\", proxy] : [])\n end","def http_proxy\n @http_proxy ||= begin\n proxy = get_env('HTTP_PROXY') || return\n proxy = \"http://#{proxy}\" unless proxy =~ /^https?:/\n uri = URI.parse(proxy)\n uri.user ||= get_env('HTTP_PROXY_USER')\n uri.password ||= get_env('HTTP_PROXY_PASS')\n uri\n end\n end","def request_config(config)\n cliio = HighLine.new\n config.login ||= cliio.ask(\"login: \")\n config.password ||= cliio.ask(\"password: \") {|q| q.echo = '*' }\n end","def password_request\n password_input = @prompt.mask(\"Please enter your password, or type quit.\")\n if password_input == @user.password\n puts \"Successful login!\"\n @user\n user_menu_runner\n #user can quit this process\n elsif password_input == \"quit\" || password_input == \"exit\"\n exit\n else\n #try again\n puts \"Sorry, incorrect password. Try again.\" # add esscape option\n password_request\n end\n end","def credz\n return @target, @port, @user, @pass, @domain, @hashpass, @hostname\nend","def open( host, port )\n connect_string = \"CONNECT #{host}:#{port} HTTP/1.0\"\n\n socket = TCPSocket.new( @proxy_host, @proxy_port )\n socket.puts connect_string\n socket.puts\n\n resp = parse_response( socket )\n\n return socket if resp[:code] == 200\n\n socket.shutdown\n raise ConnectError, resp.inspect unless resp[:code] == 407\n\n user = proxy_user\n passwd = proxy_password\n\n raise UnauthorizedError, \"no proxy user given\" unless user\n\n auth = resp[:headers][\"Proxy-Authenticate\"]\n scheme, parms = auth.split( / /, 2 )\n\n case scheme\n when \"Basic\"\n credentials =\n Base64.encode64( \"#{user}:#{passwd}\" ).gsub( /\\n/, \"\" )\n else\n raise NotImplementedError,\n \"authorization scheme #{scheme.inspect} is not supported\"\n end\n\n socket = TCPSocket.new( @proxy_host, @proxy_port )\n socket.puts connect_string\n socket.puts \"Proxy-Authorization: #{scheme} #{credentials}\"\n socket.puts\n\n resp = parse_response( socket )\n\n raise ConnectError, resp.inspect if resp[:code] != 200\n\n return socket\n end","def proxy_user; end","def ask_github_password(username = nil)\n username ||= github_username\n print \"Github password for #{username} (never stored): \"\n if $stdin.tty?\n password = askpass\n puts ''\n password\n else\n # in testing\n $stdin.gets.chomp\n end\n rescue Interrupt\n abort\n end","def get_proxy_from_env\n env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']\n\n return nil if env_proxy.nil? or env_proxy.empty?\n\n uri = URI.parse env_proxy\n\n if uri and uri.user.nil? and uri.password.nil? then\n # Probably we have http_proxy_* variables?\n uri.user = escape(ENV['http_proxy_user'] || ENV['HTTP_PROXY_USER'])\n uri.password = escape(ENV['http_proxy_pass'] || ENV['HTTP_PROXY_PASS'])\n end\n\n uri\n end","def prompt_password\n TTY::Prompt.new.mask(\"Redacted password?\", required: true)\n end","def load_credentials(username, password)\n\n if username.empty? || password.empty?\n # unused feature, for now \n\t #@username, @password = RLCredentials.load(\"lb\")\n print \"username: \"\n @username = STDIN.gets.chomp\n print \"password: \"\n @password = STDIN.noecho(&:gets).chomp\n print \"\\n\"\n else\n @username = username\n @password = password\n end\n\n # we'll want to test the credentials here by calling the rest_login\n call_rest_login\n\n end","def setup_proxy(proxy_server, port, user_name = nil, password = nil)\n self.http_proxy_setting = {\n http: {\n server: proxy_server,\n port: port\n }\n }\n if user_name and password\n self.http_proxy_setting[:http][:user_name] = user_name\n self.http_proxy_setting[:http][:password] = password\n end\n end","def prompt_for_password(message: nil)\n prompt_for_text(echo: :off, message: message)\nend","def getproxy\n proxy = (ENV['HTTP_PROXY'] == nil)? ENV['http_proxy'] : ENV['HTTP_PROXY']\n return proxy\n end","def proxy_password\n ENV[\"CHEF_API_PROXY_PASSWORD\"] || config[\"CHEF_API_PROXY_PASSWORD\"]\n end","def password(prompt)\n STDIN.noecho do\n begin\n ask(prompt)\n ensure\n puts\n end\n end\n end","def setProxy(host, port, user_name, password)\n @helper.setProxy(host, port, user_name, password)\n self\n end","def setProxy(host, port, user_name, password)\n @helper.setProxy(host, port, user_name, password)\n self\n end","def setProxy(host, port, user_name, password)\n @helper.setProxy(host, port, user_name, password)\n self\n end","def setProxy(host, port, user_name, password)\n @helper.setProxy(host, port, user_name, password)\n self\n end","def setProxy(host, port, user_name, password)\n @helper.setProxy(host, port, user_name, password)\n self\n end","def setProxy(host, port, user_name, password)\n @helper.setProxy(host, port, user_name, password)\n self\n end","def setProxy(host, port, user_name, password)\n @helper.setProxy(host, port, user_name, password)\n self\n end","def http_basic_authenticate\n authenticate_or_request_with_http_basic do |username, password|\n username == \"mustang\" && password == 'mustang' #\"must@ngs0undm3l0n\"\n end\n end","def proxy_params\n params[:proxy]\n end","def send_credentials\n dputs __method__.to_s\n login_req = setup_http_request($ident, @cookie, {:arg => [$CONF['user'], CGI.escape($CONF['pass'])]})\n res = @http.request(login_req)\n get_cookie(res)\n end","def sftptrialpwget( host, username, password )\n require 'net/ssh'\n require 'net/http'\n require 'net/sftp'\n\n @trialpw = nil\n uri = URI.parse(\"http://#{host}\")\n\n begin\n # Check if the server is up first for four minutes\n # Using HTTP\n Timeout::timeout(240) do\n begin\n while ( Net::HTTP.get_response(uri).code != \"200\" ) do\n sleep 2\n end\n rescue Errno::ECONNREFUSED\n # Connection refused means the server is coming up\n # But the SnapLogic server is not up yet\n retry\n end\n end\n\n Net::SFTP.start(host, username, :password => password) do |sftp|\n begin\n @data = sftp.download!(\"/opt/snaplogic/config/textpasswords\").split('\\n')\n rescue RuntimeError\n # File not found maybe a earlier version of snaplogic\n @data = nil\n @trialpw = 'thinkcloud'\n end\n\n @data.each do |entry|\n entry = entry.split(' ')\n if (entry.first == \"admin:\")\n @trialpw = entry.second\n break\n end\n end\n end\n\n rescue Timeout::Error\n # This means that the server didn't come up, timeout\n raise\n rescue Net::SSH::AuthenticationFailed\n # Do nothing \"Authentication failed\"\n rescue SocketError\n # Do nothing the hostname is bogus\n end # end of rescue\n @trialpw\n end","def prompt_for_password( prompt=\"Password: \" )\n\trval = nil\n\tnoecho( true ) do\n\t\t$stderr.print( prompt )\n\t\trval = ($stdin.gets || '').chomp\n\tend\n\t$stderr.puts\n\treturn rval\nend","def authenticate\n authenticate_or_request_with_http_basic(\"algo\") do |username, password|\n username == \"dupa\" && password == \"dupa\"\n end\n end","def fiddler_proxy()\n '--proxy=127.0.0.1:8888'\n end","def prompt_for_user_password!\n e.execute_as_user('')\n end","def find_or_prompt_for_credentials\n client_id = Google::Auth::ClientId.from_hash(CLIENT_SECRET_HASH)\n token_store = Google::Auth::Stores::RedisTokenStore.new(:prefix => REDIS_KEY_PREFIX)\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\n\n user_id = 'default'\n credentials = authorizer.get_credentials(user_id)\n\n if credentials.nil?\n url = authorizer.get_authorization_url(base_url: OOB_URI)\n puts \"Open the following URL in the browser and enter the \" +\n \"resulting code after authorization:\"\n puts url\n\n code = gets\n credentials = authorizer.get_and_store_credentials_from_code(\n user_id: user_id, code: code, base_url: OOB_URI\n )\n end\n\n credentials\n end","def proxy\n ENV['BETTERY_PROXY']\n end","def login(user = \"anonymous\", passwd = nil, acct = nil)\n if user == \"anonymous\" and passwd == nil\n passwd = getaddress\n end\n\n resp = \"\"\n synchronize do\n\t resp = sendcmd('USER ' + user)\n\t if resp[0] == ?3\n\t resp = sendcmd('PASS ' + passwd)\n end\n end\n\n @welcome = resp\n\n end","def setup()\n # simulate a \"startup\" function (not available in my Test Unit version)\n if @@cmptr.nil?\n @@cmptr = 0 # Set to 0 at first run to make confiuration only once\n print \"Do you need a HTTP proxy to connect to internet? (y/n) [n]: \"\n conf_proxy = gets.chomp()\n @@prox_ip = @@prox_port = @@prox_login = @@prox_pwd = nil\n if conf_proxy.downcase() == 'y'\n print \"Please enter the HTTP proxy IP: \"\n @@prox_ip = gets.chomp()\n print \"Please enter the HTTP proxy port: \"\n @@prox_port = gets.chomp()\n print \"Please enter the HTTP proxy login (if any): \"\n @@prox_login = gets.chomp()\n if @@prox_login.length == 0\n @@prox_login = nil\n else\n print \"Please enter the HTTP proxy password (if any): \"\n @@prox_pwd = gets.chomp()\n end\n end\n end\n end","def netrc_credentials(host)\n # Don't crash just b/c the gem is not installed\n return nil if !use_netrc\n obj = Net::Netrc.locate(host)\n obj ? [obj.login, obj.password] : nil\n end","def proxy\n ENV['HYPERKIT_PROXY']\n end","def proxy\n return @proxy if @proxy\n return if not Utility.is_windows?\n\n handle = WinProxy.open(@@HTTP_header['User-Agent'], 1, nil, nil, 0)\n return @proxy if handle.null?\n\n options = WinProxy::Options.new\n options[:flags] = 1\n options[:auto_detect_flags] = 2\n options[:auto_logon] = 1\n info = WinProxy::Info.new\n res = WinProxy.get_proxy(handle, (uri.to_s + \"\\0\").encode('utf-16le'), options, info)\n return @proxy if res == 0 # the call failed so return default proxy\n return unless info.proxy?\n\n puts \"TODO: handle proxy bypass - #{info[:bypass].read_16bit_c_string}\" unless info[:bypass].null?\n\n proxies = info[:proxy].read_16bit_c_string.strip.split(';').select {|p| not p.empty? }.map {|p| p.split(':') }\n @proxy = proxies[0]\n @proxy << '80' if @proxy.length == 1\n @proxy += proxy_userpass(proxies.map {|p| p[0] })\n\n WinProxy.free(info[:proxy])\n WinProxy.free(info[:bypass]) unless info[:bypass].null?\n\n @proxy\n end","def authenticate\n authenticate_or_request_with_http_basic do |username, password|\n username == ENV['USERNAMEV'] && password == ENV['PASSWORDV'] \n end \n end","def authenticate\n authenticate_or_request_with_http_basic do |user_name, password|\n # Change these to username and password required\n user_name == \"shitlister\" && password == \"letmein\"\n end\n end","def open(host, port, connection_options)\n socket = Socket.tcp(proxy_host, proxy_port, nil, nil,\n connect_timeout: connection_options[:timeout])\n\n methods = [METHOD_NO_AUTH]\n methods << METHOD_PASSWD if options[:user]\n\n packet = [VERSION, methods.size, *methods].pack(\"C*\")\n socket.send packet, 0\n\n version, method = socket.recv(2).unpack(\"CC\")\n if version != VERSION\n socket.close\n raise Net::SSH::Proxy::Error, \"invalid SOCKS version (#{version})\"\n end\n\n if method == METHOD_NONE\n socket.close\n raise Net::SSH::Proxy::Error, \"no supported authorization methods\"\n end\n\n negotiate_password(socket) if method == METHOD_PASSWD\n\n packet = [VERSION, CMD_CONNECT, 0].pack(\"C*\")\n\n if host =~ /^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$/\n packet << [ATYP_IPV4, $1.to_i, $2.to_i, $3.to_i, $4.to_i].pack(\"C*\")\n else\n packet << [ATYP_DOMAIN, host.length, host].pack(\"CCA*\")\n end\n\n packet << [port].pack(\"n\")\n socket.send packet, 0\n\n version, reply, = socket.recv(2).unpack(\"C*\")\n socket.recv(1)\n address_type = socket.recv(1).getbyte(0)\n case address_type\n when 1\n socket.recv(4) # get four bytes for IPv4 address\n when 3\n len = socket.recv(1).getbyte(0)\n hostname = socket.recv(len)\n when 4\n ipv6addr hostname = socket.recv(16)\n else\n socket.close\n raise ConnectError, \"Illegal response type\"\n end\n portnum = socket.recv(2)\n\n unless reply == SUCCESS\n socket.close\n raise ConnectError, \"#{reply}\"\n end\n\n return socket\n end","def get_login_info\n username = ask(\"Acunote Login name:\")\n password = ask(\"Acunote(LDAP) Password:\") {|q| q.echo = false}\n {:username => username, :password => password}\n end","def password\n conf['api']['password']\n end","def telnet_connect(ip,login,pswd)\r\n prompt_type=/[ftpusr:~>]*\\z/n\r\n puts\"ip,=#{ip},login=#{login},password=#{pswd}\"\r\n telnet = Net::Telnet.new('Host' => ip,'Prompt' =>prompt_type ,\"Output_log\" => \"dump_log.txt\" )\r\n\r\n #The prompt should be the real prompt while you entered your system\r\n telnet.cmd(''){|c| print c}\r\n telnet.waitfor(/[Ll]ogin[: ]*\\z/n) {|c| print c}\r\n telnet.cmd(login) {|c| print c}\r\n telnet.waitfor(/Password[: ]*\\z/n) {|c| print c}\r\n telnet.cmd(pswd) {|c| print c}\r\n\r\n # the following sentence can wrok for unity and webAdapt.\r\n telnet.waitfor(/[>]|Enter selection\\:/n) {|c| print c}\r\n\r\n sleep 5\r\n return telnet\r\n end","def set_proxy(addr, port = T.unsafe(nil), user = T.unsafe(nil), pass = T.unsafe(nil)); end","def http_proxy_uri\n @http_proxy_uri ||= begin\n keys = %w( HTTP_PROXY HTTP_PROXY_USER HTTP_PROXY_PASS )\n env = Hash[ENV.\n map{|k, v| [k.upcase, v]}.\n select{|k, v| keys.include?(k)}.\n reject{|k, v| v.nil? || v.empty?}]\n\n uri = env[\"HTTP_PROXY\"] or return\n uri = \"http://#{uri}\" unless uri =~ /^(https?|ftp|file):/\n uri = URI.parse(uri)\n uri.user ||= env[\"HTTP_PROXY_USER\"]\n uri.password ||= env[\"HTTP_PROXY_PASS\"]\n uri\n end\n end","def connect_using_proxy(socket); end","def credentials\n return nil if username.nil? || password.nil?\n \"#{username}:#{password}\"\n end","def getpass(prompt)\n STDERR.print prompt\n system('stty -echo') or STDERR.puts('+ stty -echo failed')\n pass = STDIN.readline.chomp\n system('stty echo') or STDERR.puts('+ stty echo failed')\n STDERR.puts\n return pass\n end","def proxy_address\n proxy? ? @options['proxy_address'] || '127.0.0.1' : nil\n end","def get_password(host)\n # Retrieve password from OS X KeyChain.\n osx = (RUBY_PLATFORM =~ /darwin/)\n if(osx)then\n\n require 'osx_keychain'\n keychain = OSXKeychain.new\n user = ENV['USER']\n pass = keychain[host, user ]\n\n if(pass == nil) then\n puts \"Password for '#{host}' not found on OS X KeyChain. \"\n puts \"Enter password to store new password on OS X KeyChain.\"\n require 'highline/import'\n\n pass = ask(\"Password: \") {|q| q.echo = \"*\"} # false => no echo\n keychain[host, user] = pass\n puts \"Password for '#{user}' on '#{host}' stored on OS X KeyChain.\"\n end\n return pass\n\n else\n puts \"Warning: Not running on OS X.\"\n end\n\nend","def password\n @password ||= ENV['RUBYFORGE_PASSWORD']\n @password ||= (\n $stdout << \"Password for #{username}: \"\n $stdout.flush\n until inp = $stdin.gets ; sleep 1 ; end ; puts\n inp.strip\n )\n end","def authenticate\n authenticate_or_request_with_http_basic do |username, password|\n self.username == username && self.password == password\n end\n end","def proxy\n ENV['RANCHER_PROXY']\n end","def login\n puts 'Vui long dang nhap'\n puts 'Username: '\n $user_name = gets.chomp.to_s\n puts 'Password'\n $pass_word = gets.chomp.to_s\nend","def ask_for_password(prompt = 'new password', *colors)\n print Paint[\"#{prompt}:\".capitalize, *colors] + \" \"\n system 'stty -echo' if $stdin.tty? # no more terminal output\n pw_plaintext = ($stdin.gets||'').chop # gets without $stdin would mistakenly read_safe from ARGV\n system 'stty echo' if $stdin.tty? # restore terminal output\n puts \"\\e[999D\\e[K\\e[1A\" if $stdin.tty? # re-use prompt line in terminal\n \n pw_plaintext\n end","def find_http_proxy\n ret = [nil, nil]\n\n # check the platform. If we're running in windows then we need to \n # check the registry\n if @opt['use_proxy'] || @opt['proxy_url']\n if @opt['proxy_url'] && @opt['proxy_url'].size > 0\n uri = parse_url(@opt['proxy_url'], 'proxy URL')\n ret = [uri.host, uri.port]\n elsif RUBY_PLATFORM =~ /win32/i\n # Find a proxy in Windows by checking the registry.\n # this code shamelessly copied from Raggle :D\n\n require 'win32/registry'\n\n Win32::Registry::open(\n Win32::Registry::HKEY_CURRENT_USER,\n 'Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings'\n ) do |reg|\n # check and see if proxy is enabled\n if reg.read('ProxyEnable')[1] != 0\n # get server, port, and no_proxy (overrides)\n server = reg.read('ProxyServer')[1]\n np = reg.read('ProxyOverride')[1]\n\n server =~ /^([^:]+):(.+)$/\n ret = [$1, $2]\n\n # don't bother with no_proxy support\n # ret['no_proxy'] = np.gsub(/;/, ',') if np && np.length > 0\n end\n end\n else\n # handle UNIX systems\n PROXY_ENV_VARS.each do |env_var|\n if ENV[env_var]\n # if we found a proxy, then parse it\n ret = ENV[env_var].sub(/^http:\\/\\/([^\\/]+)\\/?$/, '\\1').split(':')\n ret[1] = ret[1].to_i if ret[1]\n break\n end\n end\n # $stderr.puts \"DEBUG: http_proxy = #{ENV['http_proxy']}, ret = [#{ret.join(',')}]\"\n end\n else \n # proxy is disabled\n ret = [nil, nil]\n end\n\n # return host and port\n ret\n end","def get_keychain_password(username, server)\n if result = `security 2>&1 > /dev/null find-internet-password -ga #{username} -s #{server}`\n result.match(/\\\"(\\w+)\\\"/).to_a.last\n end\nend","def _auth_loop_request(url)\n begin\n $stdout.puts \"Enter your credentials (Control-C to quit).\"\n user = ask(\"Enter username for #{api_url}: \")\n pass = ask(\"Enter password for #{api_url}: \") { |q| q.echo = '*' }\n\n response = request(url) do |u|\n yield(u).tap {|request| request.basic_auth(user, pass) }\n end\n\n break if response.kind_of? Net::HTTPOK\n $stderr.puts \"Authentication failed: #{response.code} #{response.message}\"\n end while true\n\n [user, pass, response ]\n end","def authenticate\n @shoonga = authenticate_or_request_with_http_basic do |username, password|\n username == \"4vght\" && password == \"we8vds\"\n end\nend","def get(username, password, user, transport = :net_http)\n return net_http(username, password, user) if transport == :net_http\n return curl(username,password,user) if transport == :curl\n \"\"\n end","def password\n @password || raise(Communicator::MissingCredentials.new(\"No Password specified for HTTP AUTH. Please configure using Communicator.password='xyz'\"))\n end","def login(username:, password:)\n if password == 'test'\n print username, 'ALLOWED'\n else\n print username, 'DENIED'\n end\nend"],"string":"[\n \"def get_password(username)\\n password = ask(\\\"password for #{username}:\\\") { |q| q.echo = false }\\n password\\nend\",\n \"def get_password host,username\\n print \\\"Password for \\\"+username+\\\"@\\\"+host+\\\": \\\"\\n system \\\"stty -echo\\\"\\n pw = gets.delete(\\\"\\\\n\\\")\\n system \\\"stty echo\\\"\\n puts\\n pw\\n end\",\n \"def get_user_input\\n print \\\"username: \\\"\\n username = STDIN.gets.chomp\\n\\n print \\\"password: \\\"\\n password = STDIN.noecho(&:gets).chomp\\n end\",\n \"def ask_for_password(prompt)\\n ui.ask_for_password prompt\\n end\",\n \"def get_password(prompt='Password: ')\\n print prompt\\n STDIN.noecho(&:gets).chomp\\nend\",\n \"def ask_credentials\\n self.username = cli.prompt \\\"Your GitHub username: \\\"\\n self.password = cli.prompt_secret \\\"Your GitHub password (never stored): \\\"\\n end\",\n \"def ask_for_password\\n echo_off\\n password = ask\\n puts\\n echo_on\\n return password\\n end\",\n \"def ask_credentials\\n self.email = cli.prompt \\\"Your Pivotal Tracker email: \\\"\\n self.password = cli.prompt_secret \\\"Your Pivotal Tracker password (never stored): \\\"\\n end\",\n \"def get_username(prompt = 'Enter Nexpose username: ')\\r\\n ask(prompt) { |query| query.echo = true }\\r\\nend\",\n \"def http_proxy addr, opts={}\\n return Net::HTTP unless addr\\n\\n host, port = addr.split \\\":\\\"\\n port ||= opts[:port] || 8080\\n\\n user = opts[:username]\\n pass = opts[:password]\\n\\n Kronk::Cmd.verbose \\\"Using proxy #{addr}\\\\n\\\" if host\\n\\n Net::HTTP::Proxy host, port, user, pass\\n end\",\n \"def login(options, password = nil) # :yield: recvdata\\n login_prompt = /[Ll]ogin[: ]*\\\\z/n\\n password_prompt = /[Pp]ass(?:word|phrase)[: ]*\\\\z/n\\n if options.kind_of?(Hash)\\n username = options[\\\"Name\\\"]\\n password = options[\\\"Password\\\"]\\n login_prompt = options[\\\"LoginPrompt\\\"] if options[\\\"LoginPrompt\\\"]\\n password_prompt = options[\\\"PasswordPrompt\\\"] if options[\\\"PasswordPrompt\\\"]\\n else\\n username = options\\n end\\n\\n if block_given?\\n line = waitfor(login_prompt){|c| yield c }\\n if password\\n line += cmd({\\\"String\\\" => username,\\n \\\"Match\\\" => password_prompt}){|c| yield c }\\n line += cmd(password){|c| yield c }\\n else\\n line += cmd(username){|c| yield c }\\n end\\n else\\n line = waitfor(login_prompt)\\n if password\\n line += cmd({\\\"String\\\" => username,\\n \\\"Match\\\" => password_prompt})\\n line += cmd(password)\\n else\\n line += cmd(username)\\n end\\n end\\n line\\n end\",\n \"def authentication_prompt( )\\n puts \\\"Username:\\\"\\n username = $stdin.gets.chomp\\n puts \\\"Password:\\\"\\n password = $stdin.gets.chomp\\n raise NotAuthorized unless username.match(/\\\\S/)\\n raise NotAuthorized unless password.match(/\\\\S/)\\n return {:u => username, :p => password}\\n end\",\n \"def parse_proxy_info\\r\\n raw = @env[\\\"HTTP_PROXY\\\"] || @env[\\\"http_proxy\\\"]\\r\\n return {} unless raw\\r\\n\\r\\n main_str = raw\\r\\n .strip\\r\\n .sub(/^http:\\\\/\\\\//, \\\"\\\")\\r\\n .sub(/\\\\/+$/, \\\"\\\")\\r\\n\\r\\n auth_str = main_str.match(/(.*)@/).to_a[1].to_s\\r\\n host_str = main_str.sub(/^.*@/, \\\"\\\")\\r\\n {\\r\\n host: host_str.sub(/:.*$/, \\\"\\\"),\\r\\n port: host_str.match(/:(.*)/).to_a[1].try(:to_i), # int or nil\\r\\n user: auth_str.sub(/:.*$/, \\\"\\\"),\\r\\n pass: auth_str.sub(/^.*:/, \\\"\\\")\\r\\n }.select { |_, value| value.present? }\\r\\n end\",\n \"def askPassword(prompt=\\\"Enter Password : \\\")\\n ask(prompt) {|q| q.echo = false}\\nend\",\n \"def get_user_details\\n prompt = prompt_instance\\n system(\\\"clear\\\")\\n username = prompt.ask(\\\"Please enter username:\\\") do |q|\\n end\\n password = prompt.mask(\\\"Please enter password:\\\") do |q|\\n end\\n return username, password\\nend\",\n \"def fetch(password)\\r\\n end\",\n \"def proxyuserpwd=(value)\\n Curl.set_option(:proxyuserpwd, value_for(value, :string), handle)\\n end\",\n \"def create_pw_client(opts = {})\\n usr = opts[:user] || user()\\n pw = opts[:password] || password()\\n remote = opts[:remote_name] || self.remote_name\\n\\n logger.info(\\\"Authorizing #{usr} to work with #{remote}.\\\")\\n\\n configure_octokit(opts)\\n\\n Octokit::Client.new(:login => usr, :password => pw)\\n end\",\n \"def set_proxy(address, port, user = T.unsafe(nil), password = T.unsafe(nil)); end\",\n \"def password_prompt(prompt=\\\"Password: \\\")\\n ui.ask(prompt) { |q| q.echo = false }\\n end\",\n \"def ask_for_creds(user=nil)\\n if user\\n @username = user\\n else\\n print \\\"Enter your GApps email address: \\\"\\n @username = gets.chomp.strip.downcase \\n # using highline for input on more than one run of a loop causes intermittent errors\\n # in Ruby 1.8.7 on Mac OS X 10.8 for some reason. Changed from the highline 'ask' below\\n # to the 'print/gets' above.\\n #@username = ask(\\\"Enter your GApps email address: \\\").strip.downcase if @username == nil\\n end\\n @password = ask(\\\"Enter your password: \\\") { |q| q.echo = \\\"x\\\" }\\n end\",\n \"def question_prompt(field, opts = {})\\n trap(\\\"INT\\\") { exit 1 }\\n begin\\n print \\\"Please input #{field}: \\\"\\n response = opts[:password] ? STDIN.noecho(&:gets).strip : STDIN.gets.strip\\n end until not response.empty?\\n response\\nend\",\n \"def proxyauth=(value)\\n Curl.set_option(:proxyauth, value_for(value, :string), handle)\\n end\",\n \"def setup_credentials\\n\\n cmd = @config[:path] + @command_line_tool + \\\" \\\" + @@login_command\\n\\n Open3.popen3( cmd ) { |input, output, error|\\n input.puts @config[:url]\\n input.puts @config[:user]\\n input.puts @config[:password]\\n input.close\\n } \\n\\n end\",\n \"def server\\n reply = json_get(target, '/login', key_style)\\n return reply if reply && (reply[:prompts] || reply['prompts'])\\n raise BadResponse, \\\"Invalid response from target #{target}\\\"\\n end\",\n \"def set_proxy proxy, port=nil, user=nil, pwd=nil\\n\\t\\t\\n\\t\\t\\n\\t\\tif !proxy\\t\\n\\t\\t\\t@proxy_host=@proxy_port=@proxy_user=@proxy_pwd=nil \\n\\t\\t\\treturn\\n\\t\\tend\\n\\n\\t\\tif proxy.class == String \\n\\t\\t\\tif !port && !user && !pwd\\n\\t\\t\\t\\tproxy = URI.parse(proxy)\\n\\t\\t\\telse \\n\\t\\t\\t\\t@proxy_host= host\\n\\t\\t\\t\\t@proxy_port= port\\n\\t\\t\\t\\t@proxy_user= user\\n\\t\\t\\t\\t@proxy_pwd = pwd\\n\\t\\t\\tend\\n\\t\\tend\\n\\t\\t\\n\\t\\tif proxy.class == URI::HTTP \\n\\t\\t\\t@proxy_host= proxy.host\\n\\t\\t\\t@proxy_port= proxy.port\\n\\t\\t\\t@proxy_user= proxy.user\\n\\t\\t\\t@proxy_pwd = proxy.password\\n\\t\\tend\\n\\tend\",\n \"def proxy(to)\\n response = connection.post(\\\"/v1/auth/proxy?to=#{to}\\\")\\n case response.status\\n when 200\\n Success(response.body)\\n else\\n Failure(\\\"Status: #{response.status}\\\\n#{response.body}\\\")\\n end\\n end\",\n \"def main\\n #generate a table of coutries with proxies and the url to find them\\n selTable = getCountries(\\\"https://proxynova.com\\\")\\n selection = []\\n url = \\\"\\\"\\n command = \\\"gsettings set org.gnome.system.proxy\\\"\\n #generate menu selection based on the selTable output of getCountries\\n selTable.each_with_index do |sel, index|\\n selection.push(\\\"#{index + 1}. #{sel[0]}\\\")\\n end #do\\n selection.push(\\\"#{selection.length + 1}. No proxy\\\")\\n options = HighLine.new\\n puts options.list(selection, :columns_across)\\n chosen = ask(\\\"Pick your proxy location: \\\", Integer){|resp| resp.in = 1..selection.length}\\n #if you chose the last option, disable the proxy\\n if(chosen.eql? selection.length)\\n puts \\\"Proxy disabled.\\\"\\n system \\\"#{command} mode 'none'\\\"\\n exit\\n else #obtain proxy address and port values according to user choice and update system proxy settings\\n puts \\\"#{selection[chosen - 1].split('(')[0].split('.')[1].strip} it is...\\\"\\n proxy = getProxy(selTable[chosen - 1][1])\\n system \\\"#{command}.http host '#{proxy[0]}'\\\"\\n system \\\"#{command}.http port '#{proxy[1]}'\\\"\\n system \\\"#{command}.https host '#{proxy[0]}'\\\"\\n system \\\"#{command}.https port '#{proxy[1]}'\\\"\\n system \\\"#{command}.socks host '#{proxy[0]}'\\\"\\n system \\\"#{command}.socks port '#{proxy[1]}'\\\"\\n system \\\"#{command} mode 'manual'\\\"\\n puts \\\"Proxy set to #{proxy[0]}:#{proxy[1]}\\\"\\n exit\\n end\\nend\",\n \"def using_authenticated_proxy?; end\",\n \"def proxy_pass; end\",\n \"def getproxy\\n proxy = (ENV['HTTP_PROXY'] == nil)? ENV['http_proxy'] : ENV['HTTP_PROXY']\\n return proxy\\n end\",\n \"def ask_for_user_input(msg=nil, opts={})\\n print msg if msg\\n print \\\": \\\"\\n STDOUT.flush\\n if opts[:password]\\n system \\\"stty -echo\\\"\\n result = STDIN.gets\\n system \\\"stty echo\\\"\\n puts\\n else\\n result = STDIN.gets\\n end\\n result.chomp\\nend\",\n \"def login opts={}\\n opts = @telnet_options.merge opts\\n\\n # don't log in if username is not set\\n if opts[:username].nil?\\n @logged_in = Time.now\\n return\\n end\\n\\n begin\\n output = waitfor opts[:login_prompt]\\n\\n if opts[:password]\\n # login with username and password\\n output << cmd(opts[:username], prompt: opts[:password_prompt])\\n output << cmd(opts[:password], hide: true)\\n else\\n # login with username only\\n output << cmd(opts[:username])\\n end\\n rescue Timeout::Error\\n e = LoginFailed.new(\\\"Timed out while expecting some kind of prompt.\\\")\\n e.set_backtrace $!.backtrace\\n raise e\\n end\\n\\n @logged_in = Time.now\\n output\\n end\",\n \"def proxy_command\\n !config.proxy_user and log_and_raise(SSHError, \\\"You must specify an proxy user in order to SSH proxy.\\\")\\n !config.proxy_host_name and log_and_raise(SSHError, \\\"You must specify an proxy host_name in order to SSH proxy.\\\")\\n\\n process_keys\\n verbosity = ((ENV['LOG_LEVEL'] == \\\"DEBUG\\\") ? '-vv' : '-q')\\n\\n command = Array.new\\n # command << [ %(sshpass -p '#{config.proxy_password}') ] if config.proxy_password\\n command << [ %(ssh) ]\\n command << [ verbosity ]\\n command << [ \\\"-x\\\" ]\\n command << [ \\\"-a\\\" ]\\n command << [ \\\"-o\\\", \\\"UserKnownHostsFile=/dev/null\\\" ]\\n command << [ \\\"-o\\\", \\\"StrictHostKeyChecking=no\\\" ]\\n command << [ \\\"-o\\\", \\\"KeepAlive=yes\\\" ]\\n command << [ \\\"-o\\\", \\\"ServerAliveInterval=60\\\" ]\\n !config.proxy_keys.nil? and !config.proxy_keys.empty? and [config.proxy_keys].flatten.compact.each do |proxy_key|\\n command << [ \\\"-i\\\", proxy_key ]\\n end\\n command << [ \\\"-p\\\", config.proxy_port ] if config.proxy_port\\n command << \\\"#{config.proxy_user}@#{config.proxy_host_name}\\\"\\n command << \\\"'/usr/bin/env nc %h %p'\\\"\\n command = command.flatten.compact.join(' ')\\n config.ui.logger.debug { \\\"proxy_command(#{command.inspect})\\\" }\\n command\\n end\",\n \"def signup # demande un mot de passe sans l'afficher\\r\\n prompt = \\\"Définis ton mot de passe, stp > \\\"\\r\\n print prompt\\r\\n $password = STDIN.noecho(&:gets).chomp # mot de passe caché\\r\\n puts \\\"\\\"\\r\\nend\",\n \"def prompt_username\\n TTY::Prompt.new.ask(\\\"Redacted username?\\\", required: true, modify: :strip)\\n end\",\n \"def get_username_and_password_diligently\\n while true\\n credentials = get_username_and_password_and_authenticate\\n if credentials == false\\n puts \\\"Could not authenticate, try again?\\\"\\n puts \\\"y/n\\\"\\n\\n again = STDIN.gets.strip\\n case again.downcase\\n when \\\"y\\\"\\n when \\\"n\\\"\\n return false\\n end\\n else\\n return credentials\\n end\\n end\\n end\",\n \"def pipproxyarg\\n proxy = getproxy\\n return ((proxy != nil) ? [\\\"--proxy\\\", proxy] : [])\\n end\",\n \"def http_proxy\\n @http_proxy ||= begin\\n proxy = get_env('HTTP_PROXY') || return\\n proxy = \\\"http://#{proxy}\\\" unless proxy =~ /^https?:/\\n uri = URI.parse(proxy)\\n uri.user ||= get_env('HTTP_PROXY_USER')\\n uri.password ||= get_env('HTTP_PROXY_PASS')\\n uri\\n end\\n end\",\n \"def request_config(config)\\n cliio = HighLine.new\\n config.login ||= cliio.ask(\\\"login: \\\")\\n config.password ||= cliio.ask(\\\"password: \\\") {|q| q.echo = '*' }\\n end\",\n \"def password_request\\n password_input = @prompt.mask(\\\"Please enter your password, or type quit.\\\")\\n if password_input == @user.password\\n puts \\\"Successful login!\\\"\\n @user\\n user_menu_runner\\n #user can quit this process\\n elsif password_input == \\\"quit\\\" || password_input == \\\"exit\\\"\\n exit\\n else\\n #try again\\n puts \\\"Sorry, incorrect password. Try again.\\\" # add esscape option\\n password_request\\n end\\n end\",\n \"def credz\\n return @target, @port, @user, @pass, @domain, @hashpass, @hostname\\nend\",\n \"def open( host, port )\\n connect_string = \\\"CONNECT #{host}:#{port} HTTP/1.0\\\"\\n\\n socket = TCPSocket.new( @proxy_host, @proxy_port )\\n socket.puts connect_string\\n socket.puts\\n\\n resp = parse_response( socket )\\n\\n return socket if resp[:code] == 200\\n\\n socket.shutdown\\n raise ConnectError, resp.inspect unless resp[:code] == 407\\n\\n user = proxy_user\\n passwd = proxy_password\\n\\n raise UnauthorizedError, \\\"no proxy user given\\\" unless user\\n\\n auth = resp[:headers][\\\"Proxy-Authenticate\\\"]\\n scheme, parms = auth.split( / /, 2 )\\n\\n case scheme\\n when \\\"Basic\\\"\\n credentials =\\n Base64.encode64( \\\"#{user}:#{passwd}\\\" ).gsub( /\\\\n/, \\\"\\\" )\\n else\\n raise NotImplementedError,\\n \\\"authorization scheme #{scheme.inspect} is not supported\\\"\\n end\\n\\n socket = TCPSocket.new( @proxy_host, @proxy_port )\\n socket.puts connect_string\\n socket.puts \\\"Proxy-Authorization: #{scheme} #{credentials}\\\"\\n socket.puts\\n\\n resp = parse_response( socket )\\n\\n raise ConnectError, resp.inspect if resp[:code] != 200\\n\\n return socket\\n end\",\n \"def proxy_user; end\",\n \"def ask_github_password(username = nil)\\n username ||= github_username\\n print \\\"Github password for #{username} (never stored): \\\"\\n if $stdin.tty?\\n password = askpass\\n puts ''\\n password\\n else\\n # in testing\\n $stdin.gets.chomp\\n end\\n rescue Interrupt\\n abort\\n end\",\n \"def get_proxy_from_env\\n env_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']\\n\\n return nil if env_proxy.nil? or env_proxy.empty?\\n\\n uri = URI.parse env_proxy\\n\\n if uri and uri.user.nil? and uri.password.nil? then\\n # Probably we have http_proxy_* variables?\\n uri.user = escape(ENV['http_proxy_user'] || ENV['HTTP_PROXY_USER'])\\n uri.password = escape(ENV['http_proxy_pass'] || ENV['HTTP_PROXY_PASS'])\\n end\\n\\n uri\\n end\",\n \"def prompt_password\\n TTY::Prompt.new.mask(\\\"Redacted password?\\\", required: true)\\n end\",\n \"def load_credentials(username, password)\\n\\n if username.empty? || password.empty?\\n # unused feature, for now \\n\\t #@username, @password = RLCredentials.load(\\\"lb\\\")\\n print \\\"username: \\\"\\n @username = STDIN.gets.chomp\\n print \\\"password: \\\"\\n @password = STDIN.noecho(&:gets).chomp\\n print \\\"\\\\n\\\"\\n else\\n @username = username\\n @password = password\\n end\\n\\n # we'll want to test the credentials here by calling the rest_login\\n call_rest_login\\n\\n end\",\n \"def setup_proxy(proxy_server, port, user_name = nil, password = nil)\\n self.http_proxy_setting = {\\n http: {\\n server: proxy_server,\\n port: port\\n }\\n }\\n if user_name and password\\n self.http_proxy_setting[:http][:user_name] = user_name\\n self.http_proxy_setting[:http][:password] = password\\n end\\n end\",\n \"def prompt_for_password(message: nil)\\n prompt_for_text(echo: :off, message: message)\\nend\",\n \"def getproxy\\n proxy = (ENV['HTTP_PROXY'] == nil)? ENV['http_proxy'] : ENV['HTTP_PROXY']\\n return proxy\\n end\",\n \"def proxy_password\\n ENV[\\\"CHEF_API_PROXY_PASSWORD\\\"] || config[\\\"CHEF_API_PROXY_PASSWORD\\\"]\\n end\",\n \"def password(prompt)\\n STDIN.noecho do\\n begin\\n ask(prompt)\\n ensure\\n puts\\n end\\n end\\n end\",\n \"def setProxy(host, port, user_name, password)\\n @helper.setProxy(host, port, user_name, password)\\n self\\n end\",\n \"def setProxy(host, port, user_name, password)\\n @helper.setProxy(host, port, user_name, password)\\n self\\n end\",\n \"def setProxy(host, port, user_name, password)\\n @helper.setProxy(host, port, user_name, password)\\n self\\n end\",\n \"def setProxy(host, port, user_name, password)\\n @helper.setProxy(host, port, user_name, password)\\n self\\n end\",\n \"def setProxy(host, port, user_name, password)\\n @helper.setProxy(host, port, user_name, password)\\n self\\n end\",\n \"def setProxy(host, port, user_name, password)\\n @helper.setProxy(host, port, user_name, password)\\n self\\n end\",\n \"def setProxy(host, port, user_name, password)\\n @helper.setProxy(host, port, user_name, password)\\n self\\n end\",\n \"def http_basic_authenticate\\n authenticate_or_request_with_http_basic do |username, password|\\n username == \\\"mustang\\\" && password == 'mustang' #\\\"must@ngs0undm3l0n\\\"\\n end\\n end\",\n \"def proxy_params\\n params[:proxy]\\n end\",\n \"def send_credentials\\n dputs __method__.to_s\\n login_req = setup_http_request($ident, @cookie, {:arg => [$CONF['user'], CGI.escape($CONF['pass'])]})\\n res = @http.request(login_req)\\n get_cookie(res)\\n end\",\n \"def sftptrialpwget( host, username, password )\\n require 'net/ssh'\\n require 'net/http'\\n require 'net/sftp'\\n\\n @trialpw = nil\\n uri = URI.parse(\\\"http://#{host}\\\")\\n\\n begin\\n # Check if the server is up first for four minutes\\n # Using HTTP\\n Timeout::timeout(240) do\\n begin\\n while ( Net::HTTP.get_response(uri).code != \\\"200\\\" ) do\\n sleep 2\\n end\\n rescue Errno::ECONNREFUSED\\n # Connection refused means the server is coming up\\n # But the SnapLogic server is not up yet\\n retry\\n end\\n end\\n\\n Net::SFTP.start(host, username, :password => password) do |sftp|\\n begin\\n @data = sftp.download!(\\\"/opt/snaplogic/config/textpasswords\\\").split('\\\\n')\\n rescue RuntimeError\\n # File not found maybe a earlier version of snaplogic\\n @data = nil\\n @trialpw = 'thinkcloud'\\n end\\n\\n @data.each do |entry|\\n entry = entry.split(' ')\\n if (entry.first == \\\"admin:\\\")\\n @trialpw = entry.second\\n break\\n end\\n end\\n end\\n\\n rescue Timeout::Error\\n # This means that the server didn't come up, timeout\\n raise\\n rescue Net::SSH::AuthenticationFailed\\n # Do nothing \\\"Authentication failed\\\"\\n rescue SocketError\\n # Do nothing the hostname is bogus\\n end # end of rescue\\n @trialpw\\n end\",\n \"def prompt_for_password( prompt=\\\"Password: \\\" )\\n\\trval = nil\\n\\tnoecho( true ) do\\n\\t\\t$stderr.print( prompt )\\n\\t\\trval = ($stdin.gets || '').chomp\\n\\tend\\n\\t$stderr.puts\\n\\treturn rval\\nend\",\n \"def authenticate\\n authenticate_or_request_with_http_basic(\\\"algo\\\") do |username, password|\\n username == \\\"dupa\\\" && password == \\\"dupa\\\"\\n end\\n end\",\n \"def fiddler_proxy()\\n '--proxy=127.0.0.1:8888'\\n end\",\n \"def prompt_for_user_password!\\n e.execute_as_user('')\\n end\",\n \"def find_or_prompt_for_credentials\\n client_id = Google::Auth::ClientId.from_hash(CLIENT_SECRET_HASH)\\n token_store = Google::Auth::Stores::RedisTokenStore.new(:prefix => REDIS_KEY_PREFIX)\\n authorizer = Google::Auth::UserAuthorizer.new(client_id, SCOPE, token_store)\\n\\n user_id = 'default'\\n credentials = authorizer.get_credentials(user_id)\\n\\n if credentials.nil?\\n url = authorizer.get_authorization_url(base_url: OOB_URI)\\n puts \\\"Open the following URL in the browser and enter the \\\" +\\n \\\"resulting code after authorization:\\\"\\n puts url\\n\\n code = gets\\n credentials = authorizer.get_and_store_credentials_from_code(\\n user_id: user_id, code: code, base_url: OOB_URI\\n )\\n end\\n\\n credentials\\n end\",\n \"def proxy\\n ENV['BETTERY_PROXY']\\n end\",\n \"def login(user = \\\"anonymous\\\", passwd = nil, acct = nil)\\n if user == \\\"anonymous\\\" and passwd == nil\\n passwd = getaddress\\n end\\n\\n resp = \\\"\\\"\\n synchronize do\\n\\t resp = sendcmd('USER ' + user)\\n\\t if resp[0] == ?3\\n\\t resp = sendcmd('PASS ' + passwd)\\n end\\n end\\n\\n @welcome = resp\\n\\n end\",\n \"def setup()\\n # simulate a \\\"startup\\\" function (not available in my Test Unit version)\\n if @@cmptr.nil?\\n @@cmptr = 0 # Set to 0 at first run to make confiuration only once\\n print \\\"Do you need a HTTP proxy to connect to internet? (y/n) [n]: \\\"\\n conf_proxy = gets.chomp()\\n @@prox_ip = @@prox_port = @@prox_login = @@prox_pwd = nil\\n if conf_proxy.downcase() == 'y'\\n print \\\"Please enter the HTTP proxy IP: \\\"\\n @@prox_ip = gets.chomp()\\n print \\\"Please enter the HTTP proxy port: \\\"\\n @@prox_port = gets.chomp()\\n print \\\"Please enter the HTTP proxy login (if any): \\\"\\n @@prox_login = gets.chomp()\\n if @@prox_login.length == 0\\n @@prox_login = nil\\n else\\n print \\\"Please enter the HTTP proxy password (if any): \\\"\\n @@prox_pwd = gets.chomp()\\n end\\n end\\n end\\n end\",\n \"def netrc_credentials(host)\\n # Don't crash just b/c the gem is not installed\\n return nil if !use_netrc\\n obj = Net::Netrc.locate(host)\\n obj ? [obj.login, obj.password] : nil\\n end\",\n \"def proxy\\n ENV['HYPERKIT_PROXY']\\n end\",\n \"def proxy\\n return @proxy if @proxy\\n return if not Utility.is_windows?\\n\\n handle = WinProxy.open(@@HTTP_header['User-Agent'], 1, nil, nil, 0)\\n return @proxy if handle.null?\\n\\n options = WinProxy::Options.new\\n options[:flags] = 1\\n options[:auto_detect_flags] = 2\\n options[:auto_logon] = 1\\n info = WinProxy::Info.new\\n res = WinProxy.get_proxy(handle, (uri.to_s + \\\"\\\\0\\\").encode('utf-16le'), options, info)\\n return @proxy if res == 0 # the call failed so return default proxy\\n return unless info.proxy?\\n\\n puts \\\"TODO: handle proxy bypass - #{info[:bypass].read_16bit_c_string}\\\" unless info[:bypass].null?\\n\\n proxies = info[:proxy].read_16bit_c_string.strip.split(';').select {|p| not p.empty? }.map {|p| p.split(':') }\\n @proxy = proxies[0]\\n @proxy << '80' if @proxy.length == 1\\n @proxy += proxy_userpass(proxies.map {|p| p[0] })\\n\\n WinProxy.free(info[:proxy])\\n WinProxy.free(info[:bypass]) unless info[:bypass].null?\\n\\n @proxy\\n end\",\n \"def authenticate\\n authenticate_or_request_with_http_basic do |username, password|\\n username == ENV['USERNAMEV'] && password == ENV['PASSWORDV'] \\n end \\n end\",\n \"def authenticate\\n authenticate_or_request_with_http_basic do |user_name, password|\\n # Change these to username and password required\\n user_name == \\\"shitlister\\\" && password == \\\"letmein\\\"\\n end\\n end\",\n \"def open(host, port, connection_options)\\n socket = Socket.tcp(proxy_host, proxy_port, nil, nil,\\n connect_timeout: connection_options[:timeout])\\n\\n methods = [METHOD_NO_AUTH]\\n methods << METHOD_PASSWD if options[:user]\\n\\n packet = [VERSION, methods.size, *methods].pack(\\\"C*\\\")\\n socket.send packet, 0\\n\\n version, method = socket.recv(2).unpack(\\\"CC\\\")\\n if version != VERSION\\n socket.close\\n raise Net::SSH::Proxy::Error, \\\"invalid SOCKS version (#{version})\\\"\\n end\\n\\n if method == METHOD_NONE\\n socket.close\\n raise Net::SSH::Proxy::Error, \\\"no supported authorization methods\\\"\\n end\\n\\n negotiate_password(socket) if method == METHOD_PASSWD\\n\\n packet = [VERSION, CMD_CONNECT, 0].pack(\\\"C*\\\")\\n\\n if host =~ /^(\\\\d+)\\\\.(\\\\d+)\\\\.(\\\\d+)\\\\.(\\\\d+)$/\\n packet << [ATYP_IPV4, $1.to_i, $2.to_i, $3.to_i, $4.to_i].pack(\\\"C*\\\")\\n else\\n packet << [ATYP_DOMAIN, host.length, host].pack(\\\"CCA*\\\")\\n end\\n\\n packet << [port].pack(\\\"n\\\")\\n socket.send packet, 0\\n\\n version, reply, = socket.recv(2).unpack(\\\"C*\\\")\\n socket.recv(1)\\n address_type = socket.recv(1).getbyte(0)\\n case address_type\\n when 1\\n socket.recv(4) # get four bytes for IPv4 address\\n when 3\\n len = socket.recv(1).getbyte(0)\\n hostname = socket.recv(len)\\n when 4\\n ipv6addr hostname = socket.recv(16)\\n else\\n socket.close\\n raise ConnectError, \\\"Illegal response type\\\"\\n end\\n portnum = socket.recv(2)\\n\\n unless reply == SUCCESS\\n socket.close\\n raise ConnectError, \\\"#{reply}\\\"\\n end\\n\\n return socket\\n end\",\n \"def get_login_info\\n username = ask(\\\"Acunote Login name:\\\")\\n password = ask(\\\"Acunote(LDAP) Password:\\\") {|q| q.echo = false}\\n {:username => username, :password => password}\\n end\",\n \"def password\\n conf['api']['password']\\n end\",\n \"def telnet_connect(ip,login,pswd)\\r\\n prompt_type=/[ftpusr:~>]*\\\\z/n\\r\\n puts\\\"ip,=#{ip},login=#{login},password=#{pswd}\\\"\\r\\n telnet = Net::Telnet.new('Host' => ip,'Prompt' =>prompt_type ,\\\"Output_log\\\" => \\\"dump_log.txt\\\" )\\r\\n\\r\\n #The prompt should be the real prompt while you entered your system\\r\\n telnet.cmd(''){|c| print c}\\r\\n telnet.waitfor(/[Ll]ogin[: ]*\\\\z/n) {|c| print c}\\r\\n telnet.cmd(login) {|c| print c}\\r\\n telnet.waitfor(/Password[: ]*\\\\z/n) {|c| print c}\\r\\n telnet.cmd(pswd) {|c| print c}\\r\\n\\r\\n # the following sentence can wrok for unity and webAdapt.\\r\\n telnet.waitfor(/[>]|Enter selection\\\\:/n) {|c| print c}\\r\\n\\r\\n sleep 5\\r\\n return telnet\\r\\n end\",\n \"def set_proxy(addr, port = T.unsafe(nil), user = T.unsafe(nil), pass = T.unsafe(nil)); end\",\n \"def http_proxy_uri\\n @http_proxy_uri ||= begin\\n keys = %w( HTTP_PROXY HTTP_PROXY_USER HTTP_PROXY_PASS )\\n env = Hash[ENV.\\n map{|k, v| [k.upcase, v]}.\\n select{|k, v| keys.include?(k)}.\\n reject{|k, v| v.nil? || v.empty?}]\\n\\n uri = env[\\\"HTTP_PROXY\\\"] or return\\n uri = \\\"http://#{uri}\\\" unless uri =~ /^(https?|ftp|file):/\\n uri = URI.parse(uri)\\n uri.user ||= env[\\\"HTTP_PROXY_USER\\\"]\\n uri.password ||= env[\\\"HTTP_PROXY_PASS\\\"]\\n uri\\n end\\n end\",\n \"def connect_using_proxy(socket); end\",\n \"def credentials\\n return nil if username.nil? || password.nil?\\n \\\"#{username}:#{password}\\\"\\n end\",\n \"def getpass(prompt)\\n STDERR.print prompt\\n system('stty -echo') or STDERR.puts('+ stty -echo failed')\\n pass = STDIN.readline.chomp\\n system('stty echo') or STDERR.puts('+ stty echo failed')\\n STDERR.puts\\n return pass\\n end\",\n \"def proxy_address\\n proxy? ? @options['proxy_address'] || '127.0.0.1' : nil\\n end\",\n \"def get_password(host)\\n # Retrieve password from OS X KeyChain.\\n osx = (RUBY_PLATFORM =~ /darwin/)\\n if(osx)then\\n\\n require 'osx_keychain'\\n keychain = OSXKeychain.new\\n user = ENV['USER']\\n pass = keychain[host, user ]\\n\\n if(pass == nil) then\\n puts \\\"Password for '#{host}' not found on OS X KeyChain. \\\"\\n puts \\\"Enter password to store new password on OS X KeyChain.\\\"\\n require 'highline/import'\\n\\n pass = ask(\\\"Password: \\\") {|q| q.echo = \\\"*\\\"} # false => no echo\\n keychain[host, user] = pass\\n puts \\\"Password for '#{user}' on '#{host}' stored on OS X KeyChain.\\\"\\n end\\n return pass\\n\\n else\\n puts \\\"Warning: Not running on OS X.\\\"\\n end\\n\\nend\",\n \"def password\\n @password ||= ENV['RUBYFORGE_PASSWORD']\\n @password ||= (\\n $stdout << \\\"Password for #{username}: \\\"\\n $stdout.flush\\n until inp = $stdin.gets ; sleep 1 ; end ; puts\\n inp.strip\\n )\\n end\",\n \"def authenticate\\n authenticate_or_request_with_http_basic do |username, password|\\n self.username == username && self.password == password\\n end\\n end\",\n \"def proxy\\n ENV['RANCHER_PROXY']\\n end\",\n \"def login\\n puts 'Vui long dang nhap'\\n puts 'Username: '\\n $user_name = gets.chomp.to_s\\n puts 'Password'\\n $pass_word = gets.chomp.to_s\\nend\",\n \"def ask_for_password(prompt = 'new password', *colors)\\n print Paint[\\\"#{prompt}:\\\".capitalize, *colors] + \\\" \\\"\\n system 'stty -echo' if $stdin.tty? # no more terminal output\\n pw_plaintext = ($stdin.gets||'').chop # gets without $stdin would mistakenly read_safe from ARGV\\n system 'stty echo' if $stdin.tty? # restore terminal output\\n puts \\\"\\\\e[999D\\\\e[K\\\\e[1A\\\" if $stdin.tty? # re-use prompt line in terminal\\n \\n pw_plaintext\\n end\",\n \"def find_http_proxy\\n ret = [nil, nil]\\n\\n # check the platform. If we're running in windows then we need to \\n # check the registry\\n if @opt['use_proxy'] || @opt['proxy_url']\\n if @opt['proxy_url'] && @opt['proxy_url'].size > 0\\n uri = parse_url(@opt['proxy_url'], 'proxy URL')\\n ret = [uri.host, uri.port]\\n elsif RUBY_PLATFORM =~ /win32/i\\n # Find a proxy in Windows by checking the registry.\\n # this code shamelessly copied from Raggle :D\\n\\n require 'win32/registry'\\n\\n Win32::Registry::open(\\n Win32::Registry::HKEY_CURRENT_USER,\\n 'Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Internet Settings'\\n ) do |reg|\\n # check and see if proxy is enabled\\n if reg.read('ProxyEnable')[1] != 0\\n # get server, port, and no_proxy (overrides)\\n server = reg.read('ProxyServer')[1]\\n np = reg.read('ProxyOverride')[1]\\n\\n server =~ /^([^:]+):(.+)$/\\n ret = [$1, $2]\\n\\n # don't bother with no_proxy support\\n # ret['no_proxy'] = np.gsub(/;/, ',') if np && np.length > 0\\n end\\n end\\n else\\n # handle UNIX systems\\n PROXY_ENV_VARS.each do |env_var|\\n if ENV[env_var]\\n # if we found a proxy, then parse it\\n ret = ENV[env_var].sub(/^http:\\\\/\\\\/([^\\\\/]+)\\\\/?$/, '\\\\1').split(':')\\n ret[1] = ret[1].to_i if ret[1]\\n break\\n end\\n end\\n # $stderr.puts \\\"DEBUG: http_proxy = #{ENV['http_proxy']}, ret = [#{ret.join(',')}]\\\"\\n end\\n else \\n # proxy is disabled\\n ret = [nil, nil]\\n end\\n\\n # return host and port\\n ret\\n end\",\n \"def get_keychain_password(username, server)\\n if result = `security 2>&1 > /dev/null find-internet-password -ga #{username} -s #{server}`\\n result.match(/\\\\\\\"(\\\\w+)\\\\\\\"/).to_a.last\\n end\\nend\",\n \"def _auth_loop_request(url)\\n begin\\n $stdout.puts \\\"Enter your credentials (Control-C to quit).\\\"\\n user = ask(\\\"Enter username for #{api_url}: \\\")\\n pass = ask(\\\"Enter password for #{api_url}: \\\") { |q| q.echo = '*' }\\n\\n response = request(url) do |u|\\n yield(u).tap {|request| request.basic_auth(user, pass) }\\n end\\n\\n break if response.kind_of? Net::HTTPOK\\n $stderr.puts \\\"Authentication failed: #{response.code} #{response.message}\\\"\\n end while true\\n\\n [user, pass, response ]\\n end\",\n \"def authenticate\\n @shoonga = authenticate_or_request_with_http_basic do |username, password|\\n username == \\\"4vght\\\" && password == \\\"we8vds\\\"\\n end\\nend\",\n \"def get(username, password, user, transport = :net_http)\\n return net_http(username, password, user) if transport == :net_http\\n return curl(username,password,user) if transport == :curl\\n \\\"\\\"\\n end\",\n \"def password\\n @password || raise(Communicator::MissingCredentials.new(\\\"No Password specified for HTTP AUTH. Please configure using Communicator.password='xyz'\\\"))\\n end\",\n \"def login(username:, password:)\\n if password == 'test'\\n print username, 'ALLOWED'\\n else\\n print username, 'DENIED'\\n end\\nend\"\n]"},"negative_scores":{"kind":"list like","value":["0.67717135","0.65416163","0.6259683","0.6256776","0.6227258","0.6202245","0.6157576","0.6105552","0.6069566","0.60599804","0.604003","0.6004663","0.5964904","0.594268","0.5939773","0.5936331","0.5922371","0.59126276","0.58866394","0.5868141","0.5863001","0.58575445","0.5822713","0.5817181","0.58097297","0.5807156","0.5793985","0.5762162","0.57500875","0.5747096","0.5672626","0.56508505","0.5647747","0.56455034","0.56446654","0.5626886","0.56228703","0.5614523","0.5611608","0.56096345","0.5608692","0.5589565","0.55803466","0.55787396","0.55642587","0.55642277","0.5555433","0.55480033","0.5547505","0.55373293","0.55254513","0.5519288","0.5500769","0.54970795","0.54970795","0.54970795","0.54970795","0.54970795","0.54970795","0.54970795","0.54950225","0.5456699","0.54496706","0.5445228","0.5431628","0.54256284","0.5424564","0.5417336","0.53754646","0.53734785","0.5369348","0.53691405","0.53685844","0.53667563","0.535991","0.5359512","0.53504705","0.5346589","0.5342264","0.5331374","0.53029335","0.5301323","0.52957994","0.5290633","0.5271668","0.5270023","0.5267076","0.5265795","0.52615446","0.5261152","0.5259054","0.52495617","0.5247991","0.5247503","0.5246398","0.52452034","0.5244016","0.52412075","0.52389836","0.5234208"],"string":"[\n \"0.67717135\",\n \"0.65416163\",\n \"0.6259683\",\n \"0.6256776\",\n \"0.6227258\",\n \"0.6202245\",\n \"0.6157576\",\n \"0.6105552\",\n \"0.6069566\",\n \"0.60599804\",\n \"0.604003\",\n \"0.6004663\",\n \"0.5964904\",\n \"0.594268\",\n \"0.5939773\",\n \"0.5936331\",\n \"0.5922371\",\n \"0.59126276\",\n \"0.58866394\",\n \"0.5868141\",\n \"0.5863001\",\n \"0.58575445\",\n \"0.5822713\",\n \"0.5817181\",\n \"0.58097297\",\n \"0.5807156\",\n \"0.5793985\",\n \"0.5762162\",\n \"0.57500875\",\n \"0.5747096\",\n \"0.5672626\",\n \"0.56508505\",\n \"0.5647747\",\n \"0.56455034\",\n \"0.56446654\",\n \"0.5626886\",\n \"0.56228703\",\n \"0.5614523\",\n \"0.5611608\",\n \"0.56096345\",\n \"0.5608692\",\n \"0.5589565\",\n \"0.55803466\",\n \"0.55787396\",\n \"0.55642587\",\n \"0.55642277\",\n \"0.5555433\",\n \"0.55480033\",\n \"0.5547505\",\n \"0.55373293\",\n \"0.55254513\",\n \"0.5519288\",\n \"0.5500769\",\n \"0.54970795\",\n \"0.54970795\",\n \"0.54970795\",\n \"0.54970795\",\n \"0.54970795\",\n \"0.54970795\",\n \"0.54970795\",\n \"0.54950225\",\n \"0.5456699\",\n \"0.54496706\",\n \"0.5445228\",\n \"0.5431628\",\n \"0.54256284\",\n \"0.5424564\",\n \"0.5417336\",\n \"0.53754646\",\n \"0.53734785\",\n \"0.5369348\",\n \"0.53691405\",\n \"0.53685844\",\n \"0.53667563\",\n \"0.535991\",\n \"0.5359512\",\n \"0.53504705\",\n \"0.5346589\",\n \"0.5342264\",\n \"0.5331374\",\n \"0.53029335\",\n \"0.5301323\",\n \"0.52957994\",\n \"0.5290633\",\n \"0.5271668\",\n \"0.5270023\",\n \"0.5267076\",\n \"0.5265795\",\n \"0.52615446\",\n \"0.5261152\",\n \"0.5259054\",\n \"0.52495617\",\n \"0.5247991\",\n \"0.5247503\",\n \"0.5246398\",\n \"0.52452034\",\n \"0.5244016\",\n \"0.52412075\",\n \"0.52389836\",\n \"0.5234208\"\n]"},"document_score":{"kind":"string","value":"0.6311824"},"document_rank":{"kind":"string","value":"2"}}},{"rowIdx":1878,"cells":{"query":{"kind":"string","value":"pisspoor matching but the alternative is complex and this is good enough for error pages"},"document":{"kind":"string","value":"def match_javascript_refresh(line)\n line =~ /window.location\\s*=\\s*([\"'].*)$/i ? \"#{$1.sub(/\\/\\/.*$/, \"\").sub(/\\s*-->.*$/, \"\").sub(/\\s*<\\/script>.*$/, \"\")} [javascript]\" : nil\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def pre_match() end","def match(p0) end","def match(p0) end","def match(pattern); end","def test_match \n begin\n md = @regexp =~ @s\n puts \"\\n#{regexp} =~ #{@s} yields #{@regexp =~ @s} and $~=#{$~.inspect}\"\n\n rescue => e\n $stderr.print e.message \n $stderr.print e.backtrace.join(\"\\n\")\n raise #re-raise\n end \n end","def post_match() end","def match; end","def match; end","def match(argv1)\n return nil unless argv1\n isnot = %r{(?:5[.]1[.]0[ ]Address\n |Recipient[ ]address\n |Sender[ ]IP[ ]address\n )[ ]rejected\n }xi\n regex = %r{(?>\n [<][>][ ]invalid[ ]sender\n |address[ ]rejected\n |Administrative[ ]prohibition\n |batv[ ](?:\n failed[ ]to[ ]verify # SoniWall\n |validation[ ]failure # SoniWall\n )\n |backscatter[ ]protection[ ]detected[ ]an[ ]invalid[ ]or[ ]expired[ ]email[ ]address # MDaemon\n |bogus[ ]mail[ ]from # IMail - block empty sender\n |Connections[ ]not[ ]accepted[ ]from[ ]servers[ ]without[ ]a[ ]valid[ ]sender[ ]domain\n |denied[ ]\\[bouncedeny\\] # McAfee\n |Delivery[ ]not[ ]authorized,[ ]message[ ]refused\n |does[ ]not[ ]exist[ ]E2110\n |domain[ ]of[ ]sender[ ]address[ ].+[ ]does[ ]not[ ]exist\n |Emetteur[ ]invalide.+[A-Z]{3}.+(?:403|405|415)\n |empty[ ]envelope[ ]senders[ ]not[ ]allowed\n |error:[ ]no[ ]third-party[ ]dsns # SpamWall - block empty sender\n |From:[ ]Domain[ ]is[ ]invalid[.][ ]Please[ ]provide[ ]a[ ]valid[ ]From:\n |fully[ ]qualified[ ]email[ ]address[ ]required # McAfee\n |invalid[ ]domain,[ ]see[ ][<]url:.+[>]\n |Mail[ ]from[ ]not[ ]owned[ ]by[ ]user.+[A-Z]{3}.+421\n |Message[ ]rejected:[ ]Email[ ]address[ ]is[ ]not[ ]verified\n |mx[ ]records[ ]for[ ].+[ ]violate[ ]section[ ].+\n |Null[ ]Sender[ ]is[ ]not[ ]allowed\n |recipient[ ]not[ ]accepted[.][ ][(]batv:[ ]no[ ]tag\n |returned[ ]mail[ ]not[ ]accepted[ ]here\n |rfc[ ]1035[ ]violation:[ ]recursive[ ]cname[ ]records[ ]for\n |rule[ ]imposed[ ]mailbox[ ]access[ ]for # MailMarshal\n |sender[ ](?:\n email[ ]address[ ]rejected\n |is[ ]Spammer\n |not[ ]pre[-]approved\n |rejected\n |domain[ ]is[ ]empty\n |verify[ ]failed # Exim callout\n )\n |syntax[ ]error:[ ]empty[ ]email[ ]address\n |the[ ]message[ ]has[ ]been[ ]rejected[ ]by[ ]batv[ ]defense\n |transaction[ ]failed[ ]unsigned[ ]dsn[ ]for\n |Unroutable[ ]sender[ ]address\n |you[ ]are[ ]sending[ ]to[/]from[ ]an[ ]address[ ]that[ ]has[ ]been[ ]blacklisted\n )\n }ix\n\n return false if argv1 =~ isnot\n return true if argv1 =~ regex\n return false\n end","def match(regexp); end","def match(input); end","def stop_if_match; true; end","def matcher; end","def matcher; end","def pre_match\n end","def matching_lines(regex); end","def fnmatch(matcher); end","def refute_match(matcher, obj, msg = T.unsafe(nil)); end","def matches(_ext); end","def matches(_ext); end","def match(argv1)\n return nil unless argv1\n regex = %r{(?>\n Account[ ]disabled[ ]temporarly[ ]for[ ]exceeding[ ]receiving[ ]limits\n |account[ ]is[ ](?:\n exceeding[ ]their[ ]quota\n |over[ ]quota\n |temporarily[ ]over[ ]quota\n )\n |Boite[ ]du[ ]destinataire[ ]pleine.+[A-Z]{3}.+417\n |delivery[ ]failed:[ ]over[ ]quota\n |disc[ ]quota[ ]exceeded\n |does[ ]not[ ]have[ ]enough[ ]space\n |exceeded[ ]storage[ ]allocation\n |exceeding[ ]its[ ]mailbox[ ]quota\n |full[ ]mailbox\n |is[ ]over[ ](?:\n disk[ ]quota\n |quota[ ]temporarily\n )\n |mail[ ](?:\n file[ ]size[ ]exceeds[ ]the[ ]maximum[ ]size[ ]allowed[ ]for[ ]mail[ ]delivery\n |quota[ ]exceeded\n )\n |mailbox[ ](?:\n exceeded[ ]the[ ]local[ ]limit\n |full\n |has[ ]exceeded[ ]its[ ]disk[ ]space[ ]limit\n |is[ ]full\n |over[ ]quota\n |quota[ ]usage[ ]exceeded\n |size[ ]limit[ ]exceeded\n )\n |maildir[ ](?:\n delivery[ ]failed:[ ](?:User|Domain)disk[ ]quota[ ]?.*[ ]exceeded\n |over[ ]quota\n )\n |mailfolder[ ]is[ ]full\n |not[ ]enough[ ]storage[ ]space[ ]in\n |over[ ]the[ ]allowed[ ]quota\n |quota[ ](?:\n exceeded\n |violation[ ]for\n )\n |recipient[ ](?:\n reached[ ]disk[ ]quota\n |rejected:[ ]mailbox[ ]would[ ]exceed[ ]maximum[ ]allowed[ ]storage\n )\n |The[ ](?:\n recipient[ ]mailbox[ ]has[ ]exceeded[ ]its[ ]disk[ ]space[ ]limit\n |user[']s[ ]space[ ]has[ ]been[ ]used[ ]up\n |user[ ]you[ ]are[ ]trying[ ]to[ ]reach[ ]is[ ]over[ ]quota\n )\n |too[ ]much[ ]mail[ ]data # @docomo.ne.jp\n |user[ ](?:\n has[ ](?:\n exceeded[ ]quota,[ ]bouncing[ ]mail\n |too[ ]many[ ]messages[ ]on[ ]the[ ]server\n )\n |is[ ]over[ ](?:the[ ])?quota\n |over[ ]quota\n |over[ ]quota[.][ ][(][#]5[.]1[.]1[)] # qmail-toaster\n )\n |was[ ]automatically[ ]rejected:[ ]quota[ ]exceeded\n |would[ ]be[ ]over[ ]the[ ]allowed[ ]quota\n )\n }ix\n\n return true if argv1 =~ regex\n return false\n end","def methods_matching(re); end","def matches(ext); end","def allow_matcher; end","def submatcher; end","def submatcher; end","def matches?(pattern); end","def regexps; end","def try_regexp( str, re )\n\tif str =~ re\n\t\tputs \" #$PREMATCH\",\n\t\t \" \" + colorize( 'bold', 'green' ) { $MATCH },\n\t\t \" #$POSTMATCH\"\n\telse\n\t\tputs colorize( \"Nope.\", 'red' )\n\tend\nend","def check_scan(s, pattern); end","def check_scan(s, pattern); end","def match(keyword); end","def wont_match(exp, msg=nil)\n MatchAssay.refute!(self, exp, :message=>msg, :backtrace=>caller)\n end","def badish\n# Post process each bad entry to match against the profesor names in a regular expression fashion\nbad.each do |item|\n # unpack\n id = materias[item][0]\n rfc = materias[item][3]\n p_name = materias[item][4]\n #puts materias[item].inspect if (DEBUG)\n\n #name = []\n profesores.each do |profesor|\n # normalize string and split into words\n name = profesor[1].chomp.upcase.gsub(/\\s+/,' ').gsub(/(M\\.[ICAG]|L\\.A|I\\.Q|ING|FIS|MTRO|MRTO|DRA?)\\.?$/,\"\").split(\" \")\n # match the known name against a regular expression\n if (name.length >= 5)\n regex = Regexp.new(\"^\"+name[0]+\" \"+name[1]+\" \"+name[2]+\" \"+name[3]+\" \"+name[4])\n puts [p_name , name , regex].inspect if (p_name =~ regex)\n end\n if (name.length >= 4)\n regex = Regexp.new(\"^\"+name[0]+\" \"+name[1]+\" \"+name[2]+\" \"+name[3])\n puts [p_name , name , regex].inspect if (p_name =~ regex)\n end\n if (name.length >= 3)\n regex = Regexp.new(\"^\"+name[0]+\" \"+name[1]+\" \"+name[2])\n puts [p_name , name , regex].inspect if (p_name =~ regex)\n end\n if (name.length >= 2)\n regex = Regexp.new(\"^\"+name[0]+\" \"+name[1])\n puts [p_name , name , regex].inspect if (p_name =~ regex)\n end\n end\nend\nend","def match_captures; end","def match()\n end","def fnmatch?(matcher); end","def pre_match\n nil\n end","def test_match_resolution\n exc_handler = HumanParseExceptionHandler.new\n new_str = exc_handler.get_human_result_for_string(\"foobar\",\"ParseException\")\n assert_equal(false, new_str)\n \n exc_handler.add_human_result_for_string(\"foobar\",\"ParseException\",\"FOOBAR\")\n assert_equal(\"FOOBAR\",exc_handler.get_human_result_for_string(\"foobar\",\"ParseException\"))\n end","def on_match_pattern_p(node); end","def match_query(query); end","def exact_match?\r\n warning.nil?\r\n end","def exact_match?\r\n warning.nil?\r\n end","def parse_response(response)\n passed = false\n if @each_line_regex\n begin @each_line_regex = Regexp.new(@each_line_regex) rescue raise(\"Invalid each-line-regex: #{@each_line_regex}\") end\n response.each_line do |line|\n passed = true if line =~ @each_line_regex\n end\n end\n if @full_text_regex\n begin @full_text_regex = Regexp.new(@full_text_regex) rescue raise(\"Invalid full-text-regex: #{@each_line_regex}\") end\n passed = true if response =~ @full_text_regex\n end\n passed\nend","def parse_response(response)\n passed = false\n if @each_line_regex\n begin @each_line_regex = Regexp.new(@each_line_regex) rescue raise(\"Invalid each-line-regex: #{@each_line_regex}\") end\n response.each_line do |line|\n passed = true if line =~ @each_line_regex\n end\n end\n if @full_text_regex\n begin @full_text_regex = Regexp.new(@full_text_regex) rescue raise(\"Invalid full-text-regex: #{@each_line_regex}\") end\n passed = true if response =~ @full_text_regex\n end\n passed\nend","def test_truthy_finds(tests, method, options = {})\n tests.each do |test|\n matches = Ramparts.send(method, test[:text], options)\n test[:matches].each_with_index do |match_string, index|\n if matches[index].nil? || matches[index][:value].casecmp(match_string) != 0\n got_result = matches[index].nil? ? 'NIL' : matches[index][:value]\n raise \"Expected: #{match_string}\\nGot: #{got_result}\\nBlock '#{test[:text]}'\\nResult: #{matches}\"\n end\n end\n end\nend","def match(tokens, definitions); end","def matches_specs(text)\n text = text.downcase\n matches = false\n\n # some of Terri's terms were redundant so I removed them\n matches = true if text =~ /\\bsid|pakistan[.]* rendition|apartheid|apart[.]* regime|apart[.]* state|palestin[.]*/\n matches = true if text =~ /israel/ and text =~ /human rights violations/\n\n matches\nend","def refute_match(pattern, string, msg=nil)\n MatchAssay.refute!(string, pattern, :message=>msg, :backtrace=>caller)\n end","def match parser, index\r\n raise \"Must override match\"\r\n end","def underlying_matcher; end","def underlying_matcher; end","def check_error_response(last_response)\n refute_match 'Sinatra doesn&rsquo;t know this ditty', last_response.body, \"unmatched url\"\n end","def build_exception_matcher(exceptions); end","def longexpr\n end","def match\n true\n end","def regexp; end","def regexp; end","def re; end","def on_match_pattern(node); end","def match(input)\n input \n end","def match(source, code)\n html_errors = Array.new\n\n code = Nokogiri::HTML(code)\n\n elements = get_elements(source)\n\n elements.each do |e|\n item = e[:tag]\n\n if item==\"text\"\n\n if !e[:content].nil?\n if code.css(e[:parent]).count < 2\n if code.css(e[:parent]).text != e[:content]\n html_errors << new_error(element: e, type: 330, description: e[:parent] + \" haven't the same text \" + e[:content])\n end\n else\n exist = false\n code.css(e[:parent]).each do |code_css|\n #if code_css.at_css(e[:tag]).parent.name == e[:parent]\n if code_css.text == e[:content]\n exist = true\n end\n #end\n end\n if !exist\n html_errors << new_error(element: e, type: 330, description: e[:parent] + \" haven't the same text \" + e[:content])\n end\n end\n end\n\n else\n if code.css(e[:tag]).length > 0\n\n if !e[:attribute].nil?\n if code.css(e[:tag]).attribute(e[:attribute]).nil?\n html_errors << new_error(element: e, type: 334, description: e[:attribute] + \" didn't exist in \" + e[:tag])\n else\n if code.css(e[:tag]).attribute(e[:attribute]).value != e[:value]\n html_errors << new_error(element: e, type: 333, description: e[:attribute] + \" isn't the same value \" + e[:value])\n end\n end\n end\n\n if code.css(e[:tag]).count < 2\n if code.css(e[:tag]).first.parent.name != e[:parent]\n html_errors << new_error(element: e, type: 440, description: e[:tag] + \" didn't exist in \" + e[:parent])\n end\n else\n exist_in_parent = false\n code.css(e[:tag]).each do |code_css|\n if code_css.parent.name == e[:parent]\n exist_in_parent = true\n end\n end\n if !exist_in_parent\n html_errors << new_error(element: e, type: 440, description: e[:tag] + \" didn't exist in \" + e[:parent])\n end\n end\n\n else\n\n if code.at_css(e[:tag]).nil?\n html_errors << new_error(element: e, type: 404, description: e[:tag] + \" didn't exist\")\n end\n\n end\n\n end\n end\n\n html_errors\n end","def test_extended_patterns_no_flags\n [\n [ \".*\", \"abcd\\nefg\", \"abcd\" ],\n [ \"^a.\", \"abcd\\naefg\", \"ab\" ],\n [ \"^a.\", \"bacd\\naefg\", \"ae\" ],\n [ \".$\", \"bacd\\naefg\", \"d\" ]\n ].each do |reg, str, result|\n m = RustRegexp.new(reg).match(str)\n puts m.inspect\n unless m.nil?\n assert_equal result, m[0]\n end\n end\n end","def issue_found(script, rule, pair); end","def file_match(file)\n end","def test_seqence_valid19\n result = engine(\"TrumppasswORd12%\")\n refute(result, \"'Trump1%' should not be valid because it contains password.\")\n end","def test_exclusion_match\r\n\t\tcontent = \"first line.\\nthis string contains a case sensitive match on: MyMatch123\"\r\n\t\tsnort_rule_content = SnortRuleContent.new\r\n\t\tsnort_rule_content.not_modifier = true\r\n\t\tsnort_rule_content.unescaped_string = \"MyMatch123\"\r\n\t\tsnort_rule_content.nocase = false\r\n\t\tassert(!snort_rule_content.match(content,0),\"incorrect case sensitive exclusion match on content.\")\r\n\tend","def extract(pattern); end","def test_strict_match_criteria\n entry = BigramEntry.new\n entry.parse_line(\"8\t工作\t18904\t6.89133239246\t213454\")\n cedict_entry = CEdictEntry.new\n cedict_entry.parse_line(\"工作 工作 [gong1 zuo4] /job/work/construction/task/CL:個|个[ge4],份[fen4],項|项[xiang4]/\")\n \n result = entry.default_match_criteria.call(cedict_entry,entry)\n assert(true,result)\n end","def matches\n parse\n end","def _match(dir, message)\n return [false, nil] if @idx >= @exps.length\n matched = true\n matched = false if dir != @exps[@idx].direction\n if matched\n if dir == ::SipperUtil::ExpectationElement::Directions[2] # \"!\" \n matched = _match_neutral(message)\n elsif message.first_char(1).int?\n matched = _match_response(message)\n else\n matched = _match_request(message)\n end\n end\n if matched\n @match_count += 1\n return [true, nil] if @match_count < @exps[@idx].range.min\n return [false,_unmatched_expectation] if @match_count > @exps[@idx].range.max\n if @exps[@idx].range.include? @match_count\n @exps[@idx].satisfied = true \n return [true, nil]\n end\n else\n if (@exps[@idx].satisfied || @exps[@idx].range.min == 0)\n @idx += 1\n @match_count = 0\n return _match(dir, message) # match next\n else\n return [false,_unmatched_expectation]\n end\n end \n end","def catch_phrase; end","def catch_phrase; end","def regexp(r0, which)\n source, stop_index = r0.source, r0.stop_index\n return factor_result(source, stop_index, stop_index+$&.length) \\\n if source.index(@regexps[which],stop_index)==stop_index\n terminal_parse_failure(r0, which)\n end","def refute_match(exp, act, msg=nil)\n MatchFailure.refute(act, exp, :message=>msg, :backtrace=>caller)\n end","def match_response(req, res)\n\t\t# Instead of callbacks, i can have a url pattern check here to determine appropriate respose\n\t\turl = req.url\n\t\thtml = res.body\n\t\t#binding.pry\n\n\t\t#Match conditions here\n\t\tif url.match(/zip-codes\\/\\d+/)\n\t\t\t#binding.pry\n byebug\n\t\t\t#movers = parse(html, get_params(url, :ProMoverZip))\n\n\t\t\t#moverdatawriter.write_hashes(movers)\n \n # get pagination links here\n\n\t\t\t#bizlinkw.write_array(mlinks)\n\t\t\t#zip_writer.write_array(ziplinks)\n\t\t\t# Queue the business links\n\t\t\t#Uncomment after replacing these links by webcache links\n\t\t\t##binding.pry\n\t\t\t#queue_links(ziplinks)\n elsif url.match(/zip-codes\\/\\d+\\?page=\\d+/)\n \n\t\tend\n\t\t#Possible actions are pagination_links, parse_links\n\t\t\t\t\n\tend","def matcher_name; end","def matcher_name; end","def match=(_); end","def case_insensitive_match; end","def match\n extract!\n policy_failure_match! || self\n end","def test_string_match\n s = \"a\"\n assert_equal(0, string_match(\"a\", s))\n assert_equal(0, string_match(/a/, s))\n assert_equal(0, string_match('\\(a\\|\\b\\)', s))\n assert_equal(0, string_match(/a|b/, s))\n assert_equal(0, string_match(/^a/, s))\n assert_equal(0, string_match(/a$/, s))\n assert_equal(0, string_match(/.*/, s))\n assert_equal(nil, string_match(/not-match/, s))\n \n end","def remove_bad_ident_matches(matches)\n passed_matches = []\n matches.each do |m|\n next if (m[\"match_type\"] == \"content_body\" &&\n m[\"matched_content\"] == \"(?-mix:Drupal)\")\n\n next if (m[\"match_type\"] == \"content_cookies\" &&\n m[\"matched_content\"] == \"(?i-mx:ADRUM_BTa)\" &&\n m[\"product\"] == \"Jobvite\")\n\n passed_matches << m\n end\n passed_matches\n end","def match_ar_error(string)\n simple_matcher(\"match activerecord error\") do |given|\n error = given.is_a?(Array) ? given.first : given\n error == string\n end\nend","def expected_content\n text = '

is the most important headline

\\s*?' +\n '

\\s*?' +\n 'This is ordinary paragraph text within the body of the document,' +\n ' where certain words and phrases may be ' +\n 'emphasized to mark them as ' +\n 'particularly'\n Regexp.new text\nend","def matched\n match.to_s if matched?\n end","def match(argv1)\n return nil unless argv1\n regex = %r{(?>\n Boite[ ]du[ ]destinataire[ ]archivee.+[A-Z]{3}.+420\n |email[ ]account[ ]that[ ]you[ ]tried[ ]to[ ]reach[ ]is[ ]disabled\n |invalid/inactive[ ]user\n # http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000742\n |is[ ]a[ ]deactivated[ ]mailbox\n |mailbox[ ](?:\n currently[ ]suspended\n |unavailable[ ]or[ ]access[ ]denied\n )\n |recipient[ ](?:\n rejected:[ ]Temporarily[ ]inactive\n |suspend[ ]the[ ]service\n )\n |sorry[ ]your[ ]message[ ]to[ ].+[ ]cannot[ ]be[ ]delivered[.][ ]this[ ]\n account[ ]has[ ]been[ ]disabled[ ]or[ ]discontinued\n |The[ ]domain[ ].+[ ]is[ ]currently[ ]suspended\n |User[ ].+[ ]temporary[ ]locked\n |user[ ]suspended # http://mail.163.com/help/help_spam_16.htm\n |vdelivermail:[ ]account[ ]is[ ]locked[ ]email[ ]bounced\n )\n }ix\n\n return true if argv1 =~ regex\n return false\n end","def test_match_case_sensitive_depth_no_match\r\n\t\t#content with exact match\r\n\t\tcontent = \"123MyMatch and some more\"\r\n\t\tsnort_rule_content = SnortRuleContent.new\r\n\t\tsnort_rule_content.unescaped_string = \"MyMatch\"\r\n\t\tsnort_rule_content.depth = 9\r\n\t\tsnort_rule_content.nocase = false\r\n\t\tassert(!snort_rule_content.match(content,0),\"incorrect match on content with depth.\")\r\n\tend","def matching_text_element_lines(regex, exclude_nested = T.unsafe(nil)); end","def test_seqence_valid16\n result = engine(\"trump12%\")\n refute(result, \"'trump12%' should not be valid because it does not contain upper case letters.\")\n end","def post_match\n end","def refute_punched(str)\n refute_includes brf_content, str\n end","def match_against filename\n @regexp.match(filename)\n end","def find_match\n @skips.each { |pattern| @scanner.skip(pattern) }\n @tests.each do |pattern, block|\n if result = @scanner.scan(pattern)\n return (block.arity.zero? ? block.call : block.call(result))\n end\n end\n raise \"Error: Unregocnized character (#{@scanner.peek(1).inspect}).\"\n end","def test_a_regexp_can_search_a_string_for_matching_content\n assert_equal 'match', \"some matching content\"[/match/]\n end","def matches(key, regex, plaintext)\n # puts \"Matching #{key} against #{regex}\"\n # puts \"Value: #{params[key]}\"\n unless params[key] =~ regex || params[key].to_s.size == 0\n raise SparrowOne::RequestError.new(plaintext)\n end\n end","def scan(pattern); end","def matched?\n !failed?\n end","def test_exclusion_match_nocase_no_match\r\n\t\tcontent = \"first line.\\nthis string does not contain a case insensitive match on: MyMatch123\"\r\n\t\tsnort_rule_content = SnortRuleContent.new\r\n\t\tsnort_rule_content.not_modifier = true\r\n\t\tsnort_rule_content.unescaped_string = \"some other string\"\r\n\t\tsnort_rule_content.nocase = true\r\n\t\tmatch = snort_rule_content.match(content,0)\r\n\t\tassert_equal(0, match,\"nocase exclusion match on content didnt fire.\")\t\r\n\tend","def test_match_case_sensitive_binary_no_match\r\n\t\t#content with exact match\r\n\t\tcontent = \"first line.\\nthis string doesnt contains a match on: My\"\r\n\t\tsnort_rule_content = SnortRuleContent.new\r\n\t\tsnort_rule_content.unescaped_string = \"M|79|Mat|63 68|123\" #equals MyMatch123\r\n\t\tsnort_rule_content.nocase = false\r\n\t\tassert(!snort_rule_content.match(content,0),\"case sensitive match on no match content.\")\r\n\tend","def calculate_match_probability\n # two heuristics: \n # 1 is are their multiple words in term_text? if so, mark as probable\n # if not, does it match the anchor regexp? if so, mark as probable\n # else, mark as improbable\n \n # multiple words?\n anchor_regexp = \"(featuring|plus|the|presents|with|plus|and|\\,|\\&|[()]|\\/|\\:|\\-|^|$)\"\n nix_regexp = \"parking|\\svs\\.?\\s\" \n if artist_name=~/#{nix_regexp}/i\n self.match_probability=\"unlikely\"\n return nil\n end\n text=term_text.strip\n if text[\" \"]\n self.match_probability=\"likely\"\n return \"multpl\"\n end\n if artist_name=~/#{anchor_regexp}\\s*#{text}\\s*#{anchor_regexp}/i\n self.match_probability=\"likely\"\n return \"regexp\"\n end\n# if artist_name=~/#{anchor_regexp}\\s+?#{text}\\s+?#{anchor_regexp}/i\n# match_probability=\"likely\"\n# return \"regexp\"\n# end\n self.match_probability=\"unlikely\"\n return nil\n end"],"string":"[\n \"def pre_match() end\",\n \"def match(p0) end\",\n \"def match(p0) end\",\n \"def match(pattern); end\",\n \"def test_match \\n begin\\n md = @regexp =~ @s\\n puts \\\"\\\\n#{regexp} =~ #{@s} yields #{@regexp =~ @s} and $~=#{$~.inspect}\\\"\\n\\n rescue => e\\n $stderr.print e.message \\n $stderr.print e.backtrace.join(\\\"\\\\n\\\")\\n raise #re-raise\\n end \\n end\",\n \"def post_match() end\",\n \"def match; end\",\n \"def match; end\",\n \"def match(argv1)\\n return nil unless argv1\\n isnot = %r{(?:5[.]1[.]0[ ]Address\\n |Recipient[ ]address\\n |Sender[ ]IP[ ]address\\n )[ ]rejected\\n }xi\\n regex = %r{(?>\\n [<][>][ ]invalid[ ]sender\\n |address[ ]rejected\\n |Administrative[ ]prohibition\\n |batv[ ](?:\\n failed[ ]to[ ]verify # SoniWall\\n |validation[ ]failure # SoniWall\\n )\\n |backscatter[ ]protection[ ]detected[ ]an[ ]invalid[ ]or[ ]expired[ ]email[ ]address # MDaemon\\n |bogus[ ]mail[ ]from # IMail - block empty sender\\n |Connections[ ]not[ ]accepted[ ]from[ ]servers[ ]without[ ]a[ ]valid[ ]sender[ ]domain\\n |denied[ ]\\\\[bouncedeny\\\\] # McAfee\\n |Delivery[ ]not[ ]authorized,[ ]message[ ]refused\\n |does[ ]not[ ]exist[ ]E2110\\n |domain[ ]of[ ]sender[ ]address[ ].+[ ]does[ ]not[ ]exist\\n |Emetteur[ ]invalide.+[A-Z]{3}.+(?:403|405|415)\\n |empty[ ]envelope[ ]senders[ ]not[ ]allowed\\n |error:[ ]no[ ]third-party[ ]dsns # SpamWall - block empty sender\\n |From:[ ]Domain[ ]is[ ]invalid[.][ ]Please[ ]provide[ ]a[ ]valid[ ]From:\\n |fully[ ]qualified[ ]email[ ]address[ ]required # McAfee\\n |invalid[ ]domain,[ ]see[ ][<]url:.+[>]\\n |Mail[ ]from[ ]not[ ]owned[ ]by[ ]user.+[A-Z]{3}.+421\\n |Message[ ]rejected:[ ]Email[ ]address[ ]is[ ]not[ ]verified\\n |mx[ ]records[ ]for[ ].+[ ]violate[ ]section[ ].+\\n |Null[ ]Sender[ ]is[ ]not[ ]allowed\\n |recipient[ ]not[ ]accepted[.][ ][(]batv:[ ]no[ ]tag\\n |returned[ ]mail[ ]not[ ]accepted[ ]here\\n |rfc[ ]1035[ ]violation:[ ]recursive[ ]cname[ ]records[ ]for\\n |rule[ ]imposed[ ]mailbox[ ]access[ ]for # MailMarshal\\n |sender[ ](?:\\n email[ ]address[ ]rejected\\n |is[ ]Spammer\\n |not[ ]pre[-]approved\\n |rejected\\n |domain[ ]is[ ]empty\\n |verify[ ]failed # Exim callout\\n )\\n |syntax[ ]error:[ ]empty[ ]email[ ]address\\n |the[ ]message[ ]has[ ]been[ ]rejected[ ]by[ ]batv[ ]defense\\n |transaction[ ]failed[ ]unsigned[ ]dsn[ ]for\\n |Unroutable[ ]sender[ ]address\\n |you[ ]are[ ]sending[ ]to[/]from[ ]an[ ]address[ ]that[ ]has[ ]been[ ]blacklisted\\n )\\n }ix\\n\\n return false if argv1 =~ isnot\\n return true if argv1 =~ regex\\n return false\\n end\",\n \"def match(regexp); end\",\n \"def match(input); end\",\n \"def stop_if_match; true; end\",\n \"def matcher; end\",\n \"def matcher; end\",\n \"def pre_match\\n end\",\n \"def matching_lines(regex); end\",\n \"def fnmatch(matcher); end\",\n \"def refute_match(matcher, obj, msg = T.unsafe(nil)); end\",\n \"def matches(_ext); end\",\n \"def matches(_ext); end\",\n \"def match(argv1)\\n return nil unless argv1\\n regex = %r{(?>\\n Account[ ]disabled[ ]temporarly[ ]for[ ]exceeding[ ]receiving[ ]limits\\n |account[ ]is[ ](?:\\n exceeding[ ]their[ ]quota\\n |over[ ]quota\\n |temporarily[ ]over[ ]quota\\n )\\n |Boite[ ]du[ ]destinataire[ ]pleine.+[A-Z]{3}.+417\\n |delivery[ ]failed:[ ]over[ ]quota\\n |disc[ ]quota[ ]exceeded\\n |does[ ]not[ ]have[ ]enough[ ]space\\n |exceeded[ ]storage[ ]allocation\\n |exceeding[ ]its[ ]mailbox[ ]quota\\n |full[ ]mailbox\\n |is[ ]over[ ](?:\\n disk[ ]quota\\n |quota[ ]temporarily\\n )\\n |mail[ ](?:\\n file[ ]size[ ]exceeds[ ]the[ ]maximum[ ]size[ ]allowed[ ]for[ ]mail[ ]delivery\\n |quota[ ]exceeded\\n )\\n |mailbox[ ](?:\\n exceeded[ ]the[ ]local[ ]limit\\n |full\\n |has[ ]exceeded[ ]its[ ]disk[ ]space[ ]limit\\n |is[ ]full\\n |over[ ]quota\\n |quota[ ]usage[ ]exceeded\\n |size[ ]limit[ ]exceeded\\n )\\n |maildir[ ](?:\\n delivery[ ]failed:[ ](?:User|Domain)disk[ ]quota[ ]?.*[ ]exceeded\\n |over[ ]quota\\n )\\n |mailfolder[ ]is[ ]full\\n |not[ ]enough[ ]storage[ ]space[ ]in\\n |over[ ]the[ ]allowed[ ]quota\\n |quota[ ](?:\\n exceeded\\n |violation[ ]for\\n )\\n |recipient[ ](?:\\n reached[ ]disk[ ]quota\\n |rejected:[ ]mailbox[ ]would[ ]exceed[ ]maximum[ ]allowed[ ]storage\\n )\\n |The[ ](?:\\n recipient[ ]mailbox[ ]has[ ]exceeded[ ]its[ ]disk[ ]space[ ]limit\\n |user[']s[ ]space[ ]has[ ]been[ ]used[ ]up\\n |user[ ]you[ ]are[ ]trying[ ]to[ ]reach[ ]is[ ]over[ ]quota\\n )\\n |too[ ]much[ ]mail[ ]data # @docomo.ne.jp\\n |user[ ](?:\\n has[ ](?:\\n exceeded[ ]quota,[ ]bouncing[ ]mail\\n |too[ ]many[ ]messages[ ]on[ ]the[ ]server\\n )\\n |is[ ]over[ ](?:the[ ])?quota\\n |over[ ]quota\\n |over[ ]quota[.][ ][(][#]5[.]1[.]1[)] # qmail-toaster\\n )\\n |was[ ]automatically[ ]rejected:[ ]quota[ ]exceeded\\n |would[ ]be[ ]over[ ]the[ ]allowed[ ]quota\\n )\\n }ix\\n\\n return true if argv1 =~ regex\\n return false\\n end\",\n \"def methods_matching(re); end\",\n \"def matches(ext); end\",\n \"def allow_matcher; end\",\n \"def submatcher; end\",\n \"def submatcher; end\",\n \"def matches?(pattern); end\",\n \"def regexps; end\",\n \"def try_regexp( str, re )\\n\\tif str =~ re\\n\\t\\tputs \\\" #$PREMATCH\\\",\\n\\t\\t \\\" \\\" + colorize( 'bold', 'green' ) { $MATCH },\\n\\t\\t \\\" #$POSTMATCH\\\"\\n\\telse\\n\\t\\tputs colorize( \\\"Nope.\\\", 'red' )\\n\\tend\\nend\",\n \"def check_scan(s, pattern); end\",\n \"def check_scan(s, pattern); end\",\n \"def match(keyword); end\",\n \"def wont_match(exp, msg=nil)\\n MatchAssay.refute!(self, exp, :message=>msg, :backtrace=>caller)\\n end\",\n \"def badish\\n# Post process each bad entry to match against the profesor names in a regular expression fashion\\nbad.each do |item|\\n # unpack\\n id = materias[item][0]\\n rfc = materias[item][3]\\n p_name = materias[item][4]\\n #puts materias[item].inspect if (DEBUG)\\n\\n #name = []\\n profesores.each do |profesor|\\n # normalize string and split into words\\n name = profesor[1].chomp.upcase.gsub(/\\\\s+/,' ').gsub(/(M\\\\.[ICAG]|L\\\\.A|I\\\\.Q|ING|FIS|MTRO|MRTO|DRA?)\\\\.?$/,\\\"\\\").split(\\\" \\\")\\n # match the known name against a regular expression\\n if (name.length >= 5)\\n regex = Regexp.new(\\\"^\\\"+name[0]+\\\" \\\"+name[1]+\\\" \\\"+name[2]+\\\" \\\"+name[3]+\\\" \\\"+name[4])\\n puts [p_name , name , regex].inspect if (p_name =~ regex)\\n end\\n if (name.length >= 4)\\n regex = Regexp.new(\\\"^\\\"+name[0]+\\\" \\\"+name[1]+\\\" \\\"+name[2]+\\\" \\\"+name[3])\\n puts [p_name , name , regex].inspect if (p_name =~ regex)\\n end\\n if (name.length >= 3)\\n regex = Regexp.new(\\\"^\\\"+name[0]+\\\" \\\"+name[1]+\\\" \\\"+name[2])\\n puts [p_name , name , regex].inspect if (p_name =~ regex)\\n end\\n if (name.length >= 2)\\n regex = Regexp.new(\\\"^\\\"+name[0]+\\\" \\\"+name[1])\\n puts [p_name , name , regex].inspect if (p_name =~ regex)\\n end\\n end\\nend\\nend\",\n \"def match_captures; end\",\n \"def match()\\n end\",\n \"def fnmatch?(matcher); end\",\n \"def pre_match\\n nil\\n end\",\n \"def test_match_resolution\\n exc_handler = HumanParseExceptionHandler.new\\n new_str = exc_handler.get_human_result_for_string(\\\"foobar\\\",\\\"ParseException\\\")\\n assert_equal(false, new_str)\\n \\n exc_handler.add_human_result_for_string(\\\"foobar\\\",\\\"ParseException\\\",\\\"FOOBAR\\\")\\n assert_equal(\\\"FOOBAR\\\",exc_handler.get_human_result_for_string(\\\"foobar\\\",\\\"ParseException\\\"))\\n end\",\n \"def on_match_pattern_p(node); end\",\n \"def match_query(query); end\",\n \"def exact_match?\\r\\n warning.nil?\\r\\n end\",\n \"def exact_match?\\r\\n warning.nil?\\r\\n end\",\n \"def parse_response(response)\\n passed = false\\n if @each_line_regex\\n begin @each_line_regex = Regexp.new(@each_line_regex) rescue raise(\\\"Invalid each-line-regex: #{@each_line_regex}\\\") end\\n response.each_line do |line|\\n passed = true if line =~ @each_line_regex\\n end\\n end\\n if @full_text_regex\\n begin @full_text_regex = Regexp.new(@full_text_regex) rescue raise(\\\"Invalid full-text-regex: #{@each_line_regex}\\\") end\\n passed = true if response =~ @full_text_regex\\n end\\n passed\\nend\",\n \"def parse_response(response)\\n passed = false\\n if @each_line_regex\\n begin @each_line_regex = Regexp.new(@each_line_regex) rescue raise(\\\"Invalid each-line-regex: #{@each_line_regex}\\\") end\\n response.each_line do |line|\\n passed = true if line =~ @each_line_regex\\n end\\n end\\n if @full_text_regex\\n begin @full_text_regex = Regexp.new(@full_text_regex) rescue raise(\\\"Invalid full-text-regex: #{@each_line_regex}\\\") end\\n passed = true if response =~ @full_text_regex\\n end\\n passed\\nend\",\n \"def test_truthy_finds(tests, method, options = {})\\n tests.each do |test|\\n matches = Ramparts.send(method, test[:text], options)\\n test[:matches].each_with_index do |match_string, index|\\n if matches[index].nil? || matches[index][:value].casecmp(match_string) != 0\\n got_result = matches[index].nil? ? 'NIL' : matches[index][:value]\\n raise \\\"Expected: #{match_string}\\\\nGot: #{got_result}\\\\nBlock '#{test[:text]}'\\\\nResult: #{matches}\\\"\\n end\\n end\\n end\\nend\",\n \"def match(tokens, definitions); end\",\n \"def matches_specs(text)\\n text = text.downcase\\n matches = false\\n\\n # some of Terri's terms were redundant so I removed them\\n matches = true if text =~ /\\\\bsid|pakistan[.]* rendition|apartheid|apart[.]* regime|apart[.]* state|palestin[.]*/\\n matches = true if text =~ /israel/ and text =~ /human rights violations/\\n\\n matches\\nend\",\n \"def refute_match(pattern, string, msg=nil)\\n MatchAssay.refute!(string, pattern, :message=>msg, :backtrace=>caller)\\n end\",\n \"def match parser, index\\r\\n raise \\\"Must override match\\\"\\r\\n end\",\n \"def underlying_matcher; end\",\n \"def underlying_matcher; end\",\n \"def check_error_response(last_response)\\n refute_match 'Sinatra doesn&rsquo;t know this ditty', last_response.body, \\\"unmatched url\\\"\\n end\",\n \"def build_exception_matcher(exceptions); end\",\n \"def longexpr\\n end\",\n \"def match\\n true\\n end\",\n \"def regexp; end\",\n \"def regexp; end\",\n \"def re; end\",\n \"def on_match_pattern(node); end\",\n \"def match(input)\\n input \\n end\",\n \"def match(source, code)\\n html_errors = Array.new\\n\\n code = Nokogiri::HTML(code)\\n\\n elements = get_elements(source)\\n\\n elements.each do |e|\\n item = e[:tag]\\n\\n if item==\\\"text\\\"\\n\\n if !e[:content].nil?\\n if code.css(e[:parent]).count < 2\\n if code.css(e[:parent]).text != e[:content]\\n html_errors << new_error(element: e, type: 330, description: e[:parent] + \\\" haven't the same text \\\" + e[:content])\\n end\\n else\\n exist = false\\n code.css(e[:parent]).each do |code_css|\\n #if code_css.at_css(e[:tag]).parent.name == e[:parent]\\n if code_css.text == e[:content]\\n exist = true\\n end\\n #end\\n end\\n if !exist\\n html_errors << new_error(element: e, type: 330, description: e[:parent] + \\\" haven't the same text \\\" + e[:content])\\n end\\n end\\n end\\n\\n else\\n if code.css(e[:tag]).length > 0\\n\\n if !e[:attribute].nil?\\n if code.css(e[:tag]).attribute(e[:attribute]).nil?\\n html_errors << new_error(element: e, type: 334, description: e[:attribute] + \\\" didn't exist in \\\" + e[:tag])\\n else\\n if code.css(e[:tag]).attribute(e[:attribute]).value != e[:value]\\n html_errors << new_error(element: e, type: 333, description: e[:attribute] + \\\" isn't the same value \\\" + e[:value])\\n end\\n end\\n end\\n\\n if code.css(e[:tag]).count < 2\\n if code.css(e[:tag]).first.parent.name != e[:parent]\\n html_errors << new_error(element: e, type: 440, description: e[:tag] + \\\" didn't exist in \\\" + e[:parent])\\n end\\n else\\n exist_in_parent = false\\n code.css(e[:tag]).each do |code_css|\\n if code_css.parent.name == e[:parent]\\n exist_in_parent = true\\n end\\n end\\n if !exist_in_parent\\n html_errors << new_error(element: e, type: 440, description: e[:tag] + \\\" didn't exist in \\\" + e[:parent])\\n end\\n end\\n\\n else\\n\\n if code.at_css(e[:tag]).nil?\\n html_errors << new_error(element: e, type: 404, description: e[:tag] + \\\" didn't exist\\\")\\n end\\n\\n end\\n\\n end\\n end\\n\\n html_errors\\n end\",\n \"def test_extended_patterns_no_flags\\n [\\n [ \\\".*\\\", \\\"abcd\\\\nefg\\\", \\\"abcd\\\" ],\\n [ \\\"^a.\\\", \\\"abcd\\\\naefg\\\", \\\"ab\\\" ],\\n [ \\\"^a.\\\", \\\"bacd\\\\naefg\\\", \\\"ae\\\" ],\\n [ \\\".$\\\", \\\"bacd\\\\naefg\\\", \\\"d\\\" ]\\n ].each do |reg, str, result|\\n m = RustRegexp.new(reg).match(str)\\n puts m.inspect\\n unless m.nil?\\n assert_equal result, m[0]\\n end\\n end\\n end\",\n \"def issue_found(script, rule, pair); end\",\n \"def file_match(file)\\n end\",\n \"def test_seqence_valid19\\n result = engine(\\\"TrumppasswORd12%\\\")\\n refute(result, \\\"'Trump1%' should not be valid because it contains password.\\\")\\n end\",\n \"def test_exclusion_match\\r\\n\\t\\tcontent = \\\"first line.\\\\nthis string contains a case sensitive match on: MyMatch123\\\"\\r\\n\\t\\tsnort_rule_content = SnortRuleContent.new\\r\\n\\t\\tsnort_rule_content.not_modifier = true\\r\\n\\t\\tsnort_rule_content.unescaped_string = \\\"MyMatch123\\\"\\r\\n\\t\\tsnort_rule_content.nocase = false\\r\\n\\t\\tassert(!snort_rule_content.match(content,0),\\\"incorrect case sensitive exclusion match on content.\\\")\\r\\n\\tend\",\n \"def extract(pattern); end\",\n \"def test_strict_match_criteria\\n entry = BigramEntry.new\\n entry.parse_line(\\\"8\\t工作\\t18904\\t6.89133239246\\t213454\\\")\\n cedict_entry = CEdictEntry.new\\n cedict_entry.parse_line(\\\"工作 工作 [gong1 zuo4] /job/work/construction/task/CL:個|个[ge4],份[fen4],項|项[xiang4]/\\\")\\n \\n result = entry.default_match_criteria.call(cedict_entry,entry)\\n assert(true,result)\\n end\",\n \"def matches\\n parse\\n end\",\n \"def _match(dir, message)\\n return [false, nil] if @idx >= @exps.length\\n matched = true\\n matched = false if dir != @exps[@idx].direction\\n if matched\\n if dir == ::SipperUtil::ExpectationElement::Directions[2] # \\\"!\\\" \\n matched = _match_neutral(message)\\n elsif message.first_char(1).int?\\n matched = _match_response(message)\\n else\\n matched = _match_request(message)\\n end\\n end\\n if matched\\n @match_count += 1\\n return [true, nil] if @match_count < @exps[@idx].range.min\\n return [false,_unmatched_expectation] if @match_count > @exps[@idx].range.max\\n if @exps[@idx].range.include? @match_count\\n @exps[@idx].satisfied = true \\n return [true, nil]\\n end\\n else\\n if (@exps[@idx].satisfied || @exps[@idx].range.min == 0)\\n @idx += 1\\n @match_count = 0\\n return _match(dir, message) # match next\\n else\\n return [false,_unmatched_expectation]\\n end\\n end \\n end\",\n \"def catch_phrase; end\",\n \"def catch_phrase; end\",\n \"def regexp(r0, which)\\n source, stop_index = r0.source, r0.stop_index\\n return factor_result(source, stop_index, stop_index+$&.length) \\\\\\n if source.index(@regexps[which],stop_index)==stop_index\\n terminal_parse_failure(r0, which)\\n end\",\n \"def refute_match(exp, act, msg=nil)\\n MatchFailure.refute(act, exp, :message=>msg, :backtrace=>caller)\\n end\",\n \"def match_response(req, res)\\n\\t\\t# Instead of callbacks, i can have a url pattern check here to determine appropriate respose\\n\\t\\turl = req.url\\n\\t\\thtml = res.body\\n\\t\\t#binding.pry\\n\\n\\t\\t#Match conditions here\\n\\t\\tif url.match(/zip-codes\\\\/\\\\d+/)\\n\\t\\t\\t#binding.pry\\n byebug\\n\\t\\t\\t#movers = parse(html, get_params(url, :ProMoverZip))\\n\\n\\t\\t\\t#moverdatawriter.write_hashes(movers)\\n \\n # get pagination links here\\n\\n\\t\\t\\t#bizlinkw.write_array(mlinks)\\n\\t\\t\\t#zip_writer.write_array(ziplinks)\\n\\t\\t\\t# Queue the business links\\n\\t\\t\\t#Uncomment after replacing these links by webcache links\\n\\t\\t\\t##binding.pry\\n\\t\\t\\t#queue_links(ziplinks)\\n elsif url.match(/zip-codes\\\\/\\\\d+\\\\?page=\\\\d+/)\\n \\n\\t\\tend\\n\\t\\t#Possible actions are pagination_links, parse_links\\n\\t\\t\\t\\t\\n\\tend\",\n \"def matcher_name; end\",\n \"def matcher_name; end\",\n \"def match=(_); end\",\n \"def case_insensitive_match; end\",\n \"def match\\n extract!\\n policy_failure_match! || self\\n end\",\n \"def test_string_match\\n s = \\\"a\\\"\\n assert_equal(0, string_match(\\\"a\\\", s))\\n assert_equal(0, string_match(/a/, s))\\n assert_equal(0, string_match('\\\\(a\\\\|\\\\b\\\\)', s))\\n assert_equal(0, string_match(/a|b/, s))\\n assert_equal(0, string_match(/^a/, s))\\n assert_equal(0, string_match(/a$/, s))\\n assert_equal(0, string_match(/.*/, s))\\n assert_equal(nil, string_match(/not-match/, s))\\n \\n end\",\n \"def remove_bad_ident_matches(matches)\\n passed_matches = []\\n matches.each do |m|\\n next if (m[\\\"match_type\\\"] == \\\"content_body\\\" &&\\n m[\\\"matched_content\\\"] == \\\"(?-mix:Drupal)\\\")\\n\\n next if (m[\\\"match_type\\\"] == \\\"content_cookies\\\" &&\\n m[\\\"matched_content\\\"] == \\\"(?i-mx:ADRUM_BTa)\\\" &&\\n m[\\\"product\\\"] == \\\"Jobvite\\\")\\n\\n passed_matches << m\\n end\\n passed_matches\\n end\",\n \"def match_ar_error(string)\\n simple_matcher(\\\"match activerecord error\\\") do |given|\\n error = given.is_a?(Array) ? given.first : given\\n error == string\\n end\\nend\",\n \"def expected_content\\n text = '

is the most important headline

\\\\s*?' +\\n '

\\\\s*?' +\\n 'This is ordinary paragraph text within the body of the document,' +\\n ' where certain words and phrases may be ' +\\n 'emphasized to mark them as ' +\\n 'particularly'\\n Regexp.new text\\nend\",\n \"def matched\\n match.to_s if matched?\\n end\",\n \"def match(argv1)\\n return nil unless argv1\\n regex = %r{(?>\\n Boite[ ]du[ ]destinataire[ ]archivee.+[A-Z]{3}.+420\\n |email[ ]account[ ]that[ ]you[ ]tried[ ]to[ ]reach[ ]is[ ]disabled\\n |invalid/inactive[ ]user\\n # http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000742\\n |is[ ]a[ ]deactivated[ ]mailbox\\n |mailbox[ ](?:\\n currently[ ]suspended\\n |unavailable[ ]or[ ]access[ ]denied\\n )\\n |recipient[ ](?:\\n rejected:[ ]Temporarily[ ]inactive\\n |suspend[ ]the[ ]service\\n )\\n |sorry[ ]your[ ]message[ ]to[ ].+[ ]cannot[ ]be[ ]delivered[.][ ]this[ ]\\n account[ ]has[ ]been[ ]disabled[ ]or[ ]discontinued\\n |The[ ]domain[ ].+[ ]is[ ]currently[ ]suspended\\n |User[ ].+[ ]temporary[ ]locked\\n |user[ ]suspended # http://mail.163.com/help/help_spam_16.htm\\n |vdelivermail:[ ]account[ ]is[ ]locked[ ]email[ ]bounced\\n )\\n }ix\\n\\n return true if argv1 =~ regex\\n return false\\n end\",\n \"def test_match_case_sensitive_depth_no_match\\r\\n\\t\\t#content with exact match\\r\\n\\t\\tcontent = \\\"123MyMatch and some more\\\"\\r\\n\\t\\tsnort_rule_content = SnortRuleContent.new\\r\\n\\t\\tsnort_rule_content.unescaped_string = \\\"MyMatch\\\"\\r\\n\\t\\tsnort_rule_content.depth = 9\\r\\n\\t\\tsnort_rule_content.nocase = false\\r\\n\\t\\tassert(!snort_rule_content.match(content,0),\\\"incorrect match on content with depth.\\\")\\r\\n\\tend\",\n \"def matching_text_element_lines(regex, exclude_nested = T.unsafe(nil)); end\",\n \"def test_seqence_valid16\\n result = engine(\\\"trump12%\\\")\\n refute(result, \\\"'trump12%' should not be valid because it does not contain upper case letters.\\\")\\n end\",\n \"def post_match\\n end\",\n \"def refute_punched(str)\\n refute_includes brf_content, str\\n end\",\n \"def match_against filename\\n @regexp.match(filename)\\n end\",\n \"def find_match\\n @skips.each { |pattern| @scanner.skip(pattern) }\\n @tests.each do |pattern, block|\\n if result = @scanner.scan(pattern)\\n return (block.arity.zero? ? block.call : block.call(result))\\n end\\n end\\n raise \\\"Error: Unregocnized character (#{@scanner.peek(1).inspect}).\\\"\\n end\",\n \"def test_a_regexp_can_search_a_string_for_matching_content\\n assert_equal 'match', \\\"some matching content\\\"[/match/]\\n end\",\n \"def matches(key, regex, plaintext)\\n # puts \\\"Matching #{key} against #{regex}\\\"\\n # puts \\\"Value: #{params[key]}\\\"\\n unless params[key] =~ regex || params[key].to_s.size == 0\\n raise SparrowOne::RequestError.new(plaintext)\\n end\\n end\",\n \"def scan(pattern); end\",\n \"def matched?\\n !failed?\\n end\",\n \"def test_exclusion_match_nocase_no_match\\r\\n\\t\\tcontent = \\\"first line.\\\\nthis string does not contain a case insensitive match on: MyMatch123\\\"\\r\\n\\t\\tsnort_rule_content = SnortRuleContent.new\\r\\n\\t\\tsnort_rule_content.not_modifier = true\\r\\n\\t\\tsnort_rule_content.unescaped_string = \\\"some other string\\\"\\r\\n\\t\\tsnort_rule_content.nocase = true\\r\\n\\t\\tmatch = snort_rule_content.match(content,0)\\r\\n\\t\\tassert_equal(0, match,\\\"nocase exclusion match on content didnt fire.\\\")\\t\\r\\n\\tend\",\n \"def test_match_case_sensitive_binary_no_match\\r\\n\\t\\t#content with exact match\\r\\n\\t\\tcontent = \\\"first line.\\\\nthis string doesnt contains a match on: My\\\"\\r\\n\\t\\tsnort_rule_content = SnortRuleContent.new\\r\\n\\t\\tsnort_rule_content.unescaped_string = \\\"M|79|Mat|63 68|123\\\" #equals MyMatch123\\r\\n\\t\\tsnort_rule_content.nocase = false\\r\\n\\t\\tassert(!snort_rule_content.match(content,0),\\\"case sensitive match on no match content.\\\")\\r\\n\\tend\",\n \"def calculate_match_probability\\n # two heuristics: \\n # 1 is are their multiple words in term_text? if so, mark as probable\\n # if not, does it match the anchor regexp? if so, mark as probable\\n # else, mark as improbable\\n \\n # multiple words?\\n anchor_regexp = \\\"(featuring|plus|the|presents|with|plus|and|\\\\,|\\\\&|[()]|\\\\/|\\\\:|\\\\-|^|$)\\\"\\n nix_regexp = \\\"parking|\\\\svs\\\\.?\\\\s\\\" \\n if artist_name=~/#{nix_regexp}/i\\n self.match_probability=\\\"unlikely\\\"\\n return nil\\n end\\n text=term_text.strip\\n if text[\\\" \\\"]\\n self.match_probability=\\\"likely\\\"\\n return \\\"multpl\\\"\\n end\\n if artist_name=~/#{anchor_regexp}\\\\s*#{text}\\\\s*#{anchor_regexp}/i\\n self.match_probability=\\\"likely\\\"\\n return \\\"regexp\\\"\\n end\\n# if artist_name=~/#{anchor_regexp}\\\\s+?#{text}\\\\s+?#{anchor_regexp}/i\\n# match_probability=\\\"likely\\\"\\n# return \\\"regexp\\\"\\n# end\\n self.match_probability=\\\"unlikely\\\"\\n return nil\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.7090835","0.689698","0.689698","0.6860065","0.6725951","0.667814","0.65287334","0.65287334","0.6453381","0.6416772","0.6385208","0.6317937","0.6317707","0.6317707","0.61786884","0.6158108","0.60969377","0.60914445","0.60631156","0.60631156","0.59785265","0.59688455","0.59661746","0.59578913","0.59249675","0.59249675","0.5917581","0.5892431","0.5883671","0.58802897","0.58802897","0.5830156","0.58225775","0.5814632","0.5785262","0.57776546","0.5772223","0.57659525","0.574222","0.5739846","0.5735664","0.5734809","0.5734809","0.57333964","0.57333964","0.57329446","0.5730722","0.57087755","0.56851315","0.56832975","0.5669369","0.5669369","0.56687284","0.56672615","0.5623129","0.56189126","0.5608355","0.5608355","0.5590598","0.55786234","0.5568987","0.5567521","0.55621237","0.5558722","0.55415505","0.5539752","0.55254716","0.55186427","0.55111474","0.55005795","0.549903","0.549337","0.549337","0.54841346","0.54786474","0.5472632","0.5471981","0.5471981","0.5469878","0.5464109","0.54618347","0.54609853","0.54546696","0.5451398","0.544385","0.54424554","0.5436838","0.54284203","0.542382","0.54178756","0.5410944","0.540528","0.53991026","0.53967893","0.5392386","0.53898245","0.5386669","0.53841394","0.5375584","0.53751904","0.53689736"],"string":"[\n \"0.7090835\",\n \"0.689698\",\n \"0.689698\",\n \"0.6860065\",\n \"0.6725951\",\n \"0.667814\",\n \"0.65287334\",\n \"0.65287334\",\n \"0.6453381\",\n \"0.6416772\",\n \"0.6385208\",\n \"0.6317937\",\n \"0.6317707\",\n \"0.6317707\",\n \"0.61786884\",\n \"0.6158108\",\n \"0.60969377\",\n \"0.60914445\",\n \"0.60631156\",\n \"0.60631156\",\n \"0.59785265\",\n \"0.59688455\",\n \"0.59661746\",\n \"0.59578913\",\n \"0.59249675\",\n \"0.59249675\",\n \"0.5917581\",\n \"0.5892431\",\n \"0.5883671\",\n \"0.58802897\",\n \"0.58802897\",\n \"0.5830156\",\n \"0.58225775\",\n \"0.5814632\",\n \"0.5785262\",\n \"0.57776546\",\n \"0.5772223\",\n \"0.57659525\",\n \"0.574222\",\n \"0.5739846\",\n \"0.5735664\",\n \"0.5734809\",\n \"0.5734809\",\n \"0.57333964\",\n \"0.57333964\",\n \"0.57329446\",\n \"0.5730722\",\n \"0.57087755\",\n \"0.56851315\",\n \"0.56832975\",\n \"0.5669369\",\n \"0.5669369\",\n \"0.56687284\",\n \"0.56672615\",\n \"0.5623129\",\n \"0.56189126\",\n \"0.5608355\",\n \"0.5608355\",\n \"0.5590598\",\n \"0.55786234\",\n \"0.5568987\",\n \"0.5567521\",\n \"0.55621237\",\n \"0.5558722\",\n \"0.55415505\",\n \"0.5539752\",\n \"0.55254716\",\n \"0.55186427\",\n \"0.55111474\",\n \"0.55005795\",\n \"0.549903\",\n \"0.549337\",\n \"0.549337\",\n \"0.54841346\",\n \"0.54786474\",\n \"0.5472632\",\n \"0.5471981\",\n \"0.5471981\",\n \"0.5469878\",\n \"0.5464109\",\n \"0.54618347\",\n \"0.54609853\",\n \"0.54546696\",\n \"0.5451398\",\n \"0.544385\",\n \"0.54424554\",\n \"0.5436838\",\n \"0.54284203\",\n \"0.542382\",\n \"0.54178756\",\n \"0.5410944\",\n \"0.540528\",\n \"0.53991026\",\n \"0.53967893\",\n \"0.5392386\",\n \"0.53898245\",\n \"0.5386669\",\n \"0.53841394\",\n \"0.5375584\",\n \"0.53751904\",\n \"0.53689736\"\n]"},"document_score":{"kind":"string","value":"0.0"},"document_rank":{"kind":"string","value":"-1"}}},{"rowIdx":1879,"cells":{"query":{"kind":"string","value":"turn a href into an absolute path"},"document":{"kind":"string","value":"def make_path(base, href)\n return href if href[0] == '/'\n base + href\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def expand_path(href)\n return href if href.match(/^https*:\\/\\//) # if starts with protocol complete link\n return @request_href unless href.match(/[a-zA-Z0-9]+/) # rejects href=\"#\" and allows non-unique exception handling.\n return @request_href if href.match(/#[a-zA-Z0-9]*$/)\n\n if href[0, 1] != \"/\"\n return @request_href + href if @request_href[-1, 1] == \"/\"\n return @request_href + \"/\" + href\n else\n # relative path from domain.\n base_url = @request_href.match(BASEURLREG).to_a.first\n return base_url + href unless base_url[-1, 1] == \"/\"\n return base_url.chop + href\n end\n end","def url_from_href(href) #:nodoc:\n scheme, host, path = $1, $2, $3 if URL_PARTS.match href\n\n scheme = uri.scheme if scheme.nil? or scheme.empty? and uri.respond_to? :scheme\n\n host = uri.host if host.nil? or host.empty? and uri.respond_to? :host\n\n path = (\n (/\\/$/.match(uri.path)) ?\n '%s%s' % [uri.path,path] :\n '%s/%s' % [File.dirname(uri.path),path]\n ) unless /^\\//.match path\n\n '%s://%s%s' % [scheme, host, path]\n end","def to_absolute(link)\n return nil if link.nil?\n\n # remove anchor\n link = link.to_s.gsub(/#.*$/,'')\n if Gem::Requirement.new('< 2.5').satisfied_by?(Gem::Version.new(RUBY_VERSION))\n link = URI.encode(URI.decode(link))\n end\n\n relative = URI(link)\n absolute = base ? base.merge(relative) : @url.merge(relative)\n\n absolute.path = '/' if absolute.path.empty?\n\n return absolute\n end","def normalise_href(href)\n # ignore links which are external, or to in-page anchors\n return nil if href[0] == \"#\" || [\"/\", \"http\", \"mail\", \"/ima\"].include?(href[0, 4])\n\n # Remove any trailing anchors, or \"/\" and leading \"./\" \n target = href.sub(/\\#.*/, \"\").sub(/\\/$/, \"\").sub(/\\.*/, \"\").sub(/\\/*/, \"\")\n\n # Ignore links which don't point to html files\n /html$/.match?(target) ? target : nil\nend","def to_absolute(link)\n # remove anchor\n link = URI.encode(link.to_s.gsub(/#[a-zA-Z0-9_-]*$/,''))\n\n relative = URI(link)\n absolute = @url.merge(relative)\n\n absolute.path = '/' if absolute.path.empty?\n\n return absolute\n end","def absolute_url(href)\n Addressable::URI.join(self.class::DOMAIN, href).to_s\n end","def relativize(href, path, absolute_base, root_dir)\n # href = actual href string on page\n # path = actual current location / file path of current page\n # absolute_base = the base url for the site\n\n href_url = URI.join(URI.encode(absolute_base), URI.encode(href))\n path_url = URI.join(absolute_base, URI.encode(path))\n relative_url = path_url.route_to(href_url).to_s\n url_out = test_index(relative_url, href_url, absolute_base, root_dir)\n if href.match(/^#/)\n url_out = href\n end\n url_out\nend","def to_absolute(link, url)\n return nil if link.nil?\n url = URI(url.to_s) unless url.is_a?(URI)\n\n # remove anchor\n link = URI.encode(link.to_s.gsub(/#[a-zA-Z0-9_-]*$/,''))\n\n relative = URI(link)\n absolute = url.merge(relative)\n\n absolute.path = '/' if absolute.path.nil? or absolute.path.empty?\n\n return absolute\n end","def to_absolute(page, link)\n # remove anchor\n link = URI.encode(link.to_s.gsub(/#[a-zA-Z0-9_-]*$/,''))\n\n relative = URI(link)\n absolute = page.url.merge(relative)\n\n absolute.path = '/' if absolute.path.empty?\n\n return absolute\n end","def relative_link(link)\n # REMEMBER TO ADD ROUTES TO HANDLE THESE LINKS\n link.gsub!(@base, \"\").gsub!(\".html\", \"\").gsub!(\"-\", \"_\")\n end","def to_absolute(link)\n # remove fragment\n link = link.split('#').first if link.index('#')\n url = URI(URI.encode(link))\n raise URI::InvalidURIError unless url.path\n url = @url.merge(url) if url.relative?\n url.path = '/' if url.path.empty?\n url\n end","def convert_a(el, indent)\n\t\tif @options[:cdn_prefix]\n\t\t\tel.attr['href'] = cdn_url(el.attr['href'])\n\t\tend\n\t\t# any hrefs not starting with proto: or / or # are relative and \n\t\t# will be prefixed\n\t\tif el.attr['href'] && el.attr['href'] !~ /(^[\\w]*:|^\\/|^\\#)/\n\t\t\tel.attr['href'] = File.join(@options[:asset_prefix], el.attr['href'])\n\t\tend\n\t\tsuper\n\tend","def link_path\n File.join(\"/f/#{@page_name}\", name) # /foo/bar_files/file.jpg\n end","def as_href(from_path)\n RDoc::Markup::ToHtml.gen_relative_url from_path, path\n end","def clean_url(href)\n # TODO: A better way would be to split by / then take the last section, strip off the anchor then cgi escape\n URI.unescape(href.strip).gsub(\" \", \"%20\")\n end","def site_url(href)\n path_resolver = (@path_resolver ||= PathResolver.new)\n base_dir = path_resolver.posixify(@document.base_dir)\n site_root = path_resolver.posixify(@document.attr('site-root', base_dir))\n unless path_resolver.is_root? site_root\n raise ::ArgumentError, %(site-root must be an absolute path: #{site_root})\n end\n base_dir_to_root = nil\n if (base_dir != site_root) && (base_dir.start_with? site_root)\n comp, root = path_resolver.partition_path(base_dir.slice(site_root.length + 1, base_dir.length))\n base_dir_to_root = '../' * comp.length\n end\n path_resolver.web_path(href, base_dir_to_root)\n end","def href\n dir = ::File.dirname(file.path)\n ext = ::File.extname(file.path)\n\n if dir != '.'\n ::File.join(dir, name.chomp(ext)) #file.path) \n else\n if name == settings.index #|| 'Home'\n 'index.html'\n else\n name.chomp(ext) #file.path\n end\n end\n end","def url(href)\n a href, :href => href\n end","def get_path_for(path)\n if path.respond_to?(:href)\n path = path.href\n elsif path =~ /^[^\\/]/\n if link = link_for_rel(path)\n path = link.href\n end\n end\n path\n end","def absolutize_url(url)\n # file_path = File.expand_path(File.join(working_directory, url))\n # full_path = File.expand_path(File.join(path, url))\n # full_path.gsub(File.expand_path(path), '')\n ('/' + url.split('./').last).gsub(%r(/+), '/')\n end","def makeAbsolute(link, currURL)\n\t\tif not ( link =~ /http/ )\n\t\t\t# relative link: create absolute link\n\n\t\t\t# .edu/pigs/index.html should be treated as .edu/pigs\n\t\t\tdirectory = /(.*#{Regexp.escape(\"/\")})\\w+#{Regexp.escape(\".\")}\\w+$/.match(currURL)\n\t\t\tif directory\n\t\t\t\tcurrURL = directory[1]\n\t\t\tend\n\n\t\t\t# remove any trailing forward slash\n\t\t\tif currURL[-1] == \"/\"\n\t\t\t\tcurrURL = currURL[0..-2]\n\t\t\tend\n\n\t\t\t# if the link starts with \"/\", don't just append\n\t\t\tif ( link =~ /^#{Regexp.escape(\"/\")}/ )\n\t\t\t\tdomain = URI.parse(currURL).host\n\t\t\t\tlink = \"http://\" + domain + link\n\t\t\telse\n\t\t\t\t# is ../ the start?\n\t\t\t\tif ( link =~ /^..#{Regexp.escape(\"/\")}/ )\n\t\t\t\t\t# make sure you can actually go back a directory: look for bowdoin.edu/***/ at least\n\t\t\t\t\tif ( currURL =~ /.*bowdoin.edu#{Regexp.escape(\"/\")}.*#{Regexp.escape(\"/\")}?/ )\n\t\t\t\t\t\t# remove first instance of ../\n\t\t\t\t\t\tadjustedLink = link[3..-1]\n\t\t\t\t\t\tshortened = /.*#{Regexp.escape(\"/\")}/.match(currURL)\n\t\t\t\t\t\t# remove / at end (guaranteed if the regex matches)\n\t\t\t\t\t\tshortened = shortened[0][0..-2]\n\n\t\t\t\t\t\t# another instance of ../?\n\t\t\t\t\t\tif ( adjustedLink =~ /^..#{Regexp.escape(\"/\")}/ )\n\t\t\t\t\t\t\t# recurse on shortened URL\n\t\t\t\t\t\t\tresult = makeAbsolute(adjustedLink, shortened)\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tresult = shortened + \"/\" + adjustedLink\n\t\t\t\t\t\t\treturn result\n\t\t\t\t\t\tend\t\t\t\t\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\t# normal relative link - add to end\n\t\t\t\t\tending = /.*#{Regexp.escape(\"/\")}([^#{Regexp.escape(\"/\")}]*)$/.match(currURL)\n\t\t\t\t\tif ending\n\t\t\t\t\t\ttoMatch = ending[1]\n\t\t\t\t\t\tif ( link =~ /^#{toMatch}/ )\n\t\t\t\t\t\t\tputs \"Repeats, avoiding \" + link\n\t\t\t\t\t\t\treturn currURL\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\treturn currURL + \"/\" + link\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\treturn link\n\t\tend\n\tend","def absolutify url, cd \n url = url.to_s\n # deal w/ bad URLs, already absolute, etc\n begin\n u = URI.parse(url)\n rescue\n # GIGO, no need for alarm\n return url\n end\n\n return url if u.absolute? # http://example.com/about\n c = URI.parse(cd)\n return c.scheme + \"://\" + c.host + url if url.index('/') == 0 # /about\n return cd + url if url.match(/^[a-zA-Z]+/) # about*\n\n # only relative from here on in; ../about, ./about, ../../about\n u_dirs = u.path.split('/')\n c_dirs = c.path.split('/')\n\n # move up the directory until there are no more relative paths\n u.path.split('/').each do |x|\n break unless (x == '' || x == '..' || x == '.')\n u_dirs.shift\n c_dirs.pop unless x == '.'\n end\n return c.scheme + \"://\" + c.host + c_dirs.join('/') + '/' + u_dirs.join('/')\n end","def to_url(host)\n uri = URI.parse(href)\n if uri.absolute?\n if uri.host != URI.parse(host).host\n Grell.logger.debug \"GRELL does not follow links to external hosts: #{href}\"\n nil\n else\n href # Absolute link to our own host\n end\n else\n if uri.path.nil?\n Grell.logger.debug \"GRELL does not follow links without a path: #{uri}\"\n nil\n end\n if uri.path.start_with?('/')\n host + href # convert to full URL\n else # links like href=\"google.com\" the browser would go to http://google.com like \"http://#{link}\"\n Grell.logger.debug \"GRELL Bad formatted link: #{href}, assuming external\"\n nil\n end\n end\n rescue URI::InvalidURIError # Invalid links propagating till we navigate to them\n href\n end","def link_path\n File.join('/_attachment', @page_name, name)\n end","def absolute_url_for(uri, str)\n # TODO: use URI.parse() for better handling?\n return str if str =~ /^[|[:alpha:]]+:\\/\\//\n File.join(((uri.path.empty?) ? uri.to_s : File.dirname(uri.to_s)), \n str)\n end","def absolutify_url(uri)\n if uri =~ /^\\w*\\:/i\n normalize_url(uri)\n else\n Addressable::URI.join(@url, uri).normalize.to_s\n end\n rescue URI::InvalidURIError, Addressable::URI::InvalidURIError => e\n add_fatal_error \"Link parsing exception: #{e.message}\" and nil\n end","def fix_link_path(absolute_path, link)\r\n\t\tabsolute_path += \"/\" if !absolute_path.end_with?(\"/\") && !link.start_with?(\"/\")\r\n\t\tabsolute_path + link\r\n\tend","def absolutify_url(url)\n url =~ /^\\w*\\:/i ? url : File.join(@url,url)\n end","def href\n @href ||= build_href(path, collection: self.collection?)\n end","def build_href(path, collection: false)\n if propstat_relative_path\n request.path_for path, collection: collection\n else\n request.url_for path, collection: collection\n end\n end","def make_absolute_url(url)\n return url unless Addressable::URI.parse(url).relative?\n begin\n Addressable::URI.parse(@page_url).merge(url).to_s\n rescue\n url\n end\n end","def absolute_url\n domain + path\n end","def raw_href\n templated? ? template.pattern : target.href\n end","def href\n attributes[:href]\n end","def normalize_path(url); end","def normalize_path(url); end","def resolve_file_path(anchor)\n return anchor if anchor.path.end_with?('index.html') && File.exist?(\"out#{anchor.path}\")\n\n # Check if path is in list of redirects\n # This the initial source path\n redirect_source = anchor.path\n # This is the final destination\n redirect_final_dest = nil\n # Trigger to stop redirect evaluation\n stop_redirect_evaluation = false\n\n until stop_redirect_evaluation\n stop_redirect_evaluation = true\n\n next unless REDIRECTS.key?(redirect_source)\n\n redirect_source = REDIRECTS[redirect_source]\n redirect_final_dest = URI.parse(redirect_source)\n stop_redirect_evaluation = false\n end\n\n # Return path if redirect resolved to an external URL\n case redirect_final_dest.class.to_s\n when 'URI::HTTP', 'URI::HTTPS'\n return redirect_final_dest\n when 'URI::Generic'\n begin\n anchor = anchor.merge(redirect_final_dest)\n rescue URI::BadURIError\n anchor = redirect_final_dest\n end\n end\n\n # List of potential path extensions\n potential_extensions = [\n # change /path/ to path.html\n anchor.path.sub(%r{/$}, '.html'),\n # change /path to /path.html\n \"#{anchor.path}.html\",\n # /path/index.html\n \"#{anchor.path}/index.html\"\n ]\n\n potential_prefixes = [\n # relative\n '',\n # absolute\n '/'\n ]\n\n potential_prefixes.each do |prefix|\n potential_extensions.each do |suffix|\n test_path = \"#{prefix}#{suffix}\"\n if File.exist?(\"out#{test_path}\") && File.file?(\"out#{test_path}\")\n anchor.path = test_path\n return anchor\n end\n end\n end\n\n # Return the original path we were passed in.\n # Its possible this is a redirect which will be resolved later.\n anchor\nend","def normalize_uri\r\n self.link = Addressable::URI.heuristic_parse(self.link).normalize!.to_s if self.link\r\n end","def make_absolute_url(url)\n return url unless URI.parse(url).relative?\n begin\n URI.parse(@page_url).merge(url).to_s\n rescue URI::Error\n url\n end\n end","def full_path(current_url, link)\n uri = URI current_url\n uri.merge link\n rescue URI::InvalidURIError => e\n uri.merge URI.escape(link)\n end","def get_absolute_file_url(url)\n orig_url = url.to_s.strip\n \n url = file_url(orig_url)\n # If a file:// was stripped from the url, this means it will always point\n # to a file\n force_file = (orig_url != url)\n # Indicates wether the base url is a network url or a file/directory\n base_is_net = !base_file_url.is_a?(String)\n # Try to find if we have a \"net\" URL if we aren't sure if this is a file. In\n # case the base url is a network url, we'll always assume that the\n # url is also a net thing. Otherwise we only have a net url if it contains a\n # '://' string\n is_net_url = !force_file && (base_is_net || url.include?('://'))\n # The url is absolute if there is a : character to be found\n \n \n if(is_net_url)\n base_is_net ? join_url(base_file_url, url) : url\n else\n base_is_net ? url : join_files(base_file_url, url)\n end\n end","def absolutify_url(src, base_url, parent_url)\r\n if src.nil? || src.empty? || src == \"//:\" || src =~ /\\s*http:\\/\\//i\r\n return src\r\n end\r\n\r\n return \"#{base_url}#{src}\" if src =~ /^\\s*\\//\r\n return \"#{parent_url}#{src}\" if parent_url\r\n return src\r\n end","def full_url(url, path)\n if path.start_with?('http')\n path\n else\n url = url[0..1] if url.end_with?('/')\n path = path[1..-1] if path.start_with?('/')\n \"#{url}/#{path}\"\n end\n end","def get_link_path(url)\n ((link_path = url.sub(@donor.url, '').squish)[0] == '/') ? link_path : ('/' + link_path)\n end","def absolutify_url(src, base_url, parent_url)\n if src.nil? || src.empty? || src == \"//:\" || src =~ /\\s*http:\\/\\//i\n return src\n end\n \n return \"#{base_url}#{src}\" if src =~ /^\\s*\\//\n return \"#{parent_url}#{src}\" if parent_url\n return src\n end","def relative_path(from, to); end","def rel_to(path)\n path = path + '/' unless path.end_with?('/')\n if rel.start_with?(path)\n rel.sub(path, '')\n else\n raise \"#{@abs} is not in #{path}\"\n end\n end","def uri\n @uri ||= if @href then\n begin\n URI.parse @href\n rescue URI::InvalidURIError\n begin\n URI.parse(Addressable::URI.escape(@href))\n rescue Addressable::URI::InvalidURIError\n raise URI::InvalidURIError\n end\n end\n end\n end","def change_hrefs(html)\n DOM.walk(html) do |node|\n for attr_name in %w{href src}\n attr_obj = node.attributes[attr_name]\n\n # Ignore if its blank\n next if !attr_obj\n\n # URL encode any spaces\n orig_href = attr_obj.to_s.gsub(\" \", \"%20\")\n\n begin\n src = URI(orig_href)\n rescue\n log \"#{orig_href} not a valid URI\"\n next\n end\n\n if internal_link?(src.to_s)\n linked_item = nil\n\n if src.path == \"\"\n # If its just an anchor like '#this' just set to the current file\n linked_item = self\n else\n # Match on the unescaped href\n unescaped_path = URI::unescape(src.path)\n linked_item = get_item(unescaped_path)\n end\n\n # Change link\n if linked_item\n new_path = linked_item.normalized_hashed_path(:relative_to => self)\n new_path = URI(new_path)\n\n if src.fragment\n new_path.fragment = src.fragment\n end\n\n log \"Changing #{src.to_s} to #{new_path.to_s}\"\n attr_obj.content = new_path.to_s\n else\n log \"No item in manifest for #{src}\"\n end\n end\n end\n end\n end","def process\n return nil unless link_url?\n url = @url.dup\n if url = parse(url)\n return parse_relative_url unless url.host\n url.scheme ||= @source_url.scheme\n if same_source_host? || external_asset_url?\n URI.unescape(url.to_s, '%7C')\n end\n end\n end","def make_folders_absolute(f,tt)\n tt.elements.each(\"//node\") do |nn|\n if nn.attributes['LINK']\n nn.attributes['LINK']= File.expand_path(File.dirname(f))+\"/#{nn.attributes['LINK']}\"\n end\n end\n end","def pathname(path, link)\n path_string = path&.length&.positive? ? '/' + path.join('/') : ''\n path_string = path_string.tr(' ', '-')\n \"/#{SITEMAP_SUBDIRECTORY}/#{name}#{path_string}/#{link}\"\n end","def linked_path_for(path)\n return path unless path.include?('/')\n current_path_base = request.env['REQUEST_URI'].gsub(path,'')\n dirs = path.split('/')\n file = dirs.pop\n linked_path = ''\n dirs.each do |dir|\n link = '' + dir + ''\n current_path_base << \"#{dir}/\"\n linked_path << \"#{link}/\" \n end\n linked_path << file\n end","def make_folders_absolute(f,tt)\n tt.elements.each(\"//node\") do |nn|\n if nn.attributes['LINK']\n nn.attributes['LINK']= File.expand_path(File.dirname(f))+\"/#{nn.attributes['LINK']}\"\n end\n end\n end","def path\n @path ||= filters.uri_escape(absolute_url) if absolute_url\n end","def path\n @path ||= filters.uri_escape(absolute_url) if absolute_url\n end","def convert_relative_links(url)\n base_url = doc.css('base').present? ? doc.css('base')[0]['href'] : url.split('?').first \n return if base_url.blank?\n doc.css('a').each do |link|\n link['href'] = converted_link(base_url, link['href'])\n end\n end","def link_name(name)\n File.expand_path(File.join('~', '.' + File.basename(name)))\nend","def link_to(title, path, opts={}, base=true)\n unless is_uri?(path) || base == false\n path = url(path)\n end\n \n return \"#{title}\"\n end","def expand_path( path )\n File.expand_path( path.gsub( /^\\/+/, '' ), self.link.path.gsub( /\\/*$/, '/' ) ).gsub( /^C:/, '')\n end","def absolute_uri_path(path)\n \"#{root_uri}#{path}\"\n end","def link\n # TODO: URL escape links\n if top_level? && (!is_a? SiteDir)\n name\n else\n if is_a? SiteDir # TODO: do a dynamic renderable test?\n top_level? ? \"dropsite/#{@path}.html\" : \"#{@path}.html\".sub(/^\\//, '')\n else\n # Builds a link back up to the file in Public root since the pages\n # are built in a parallel directory structure\n dirs_up = @path.split(File::SEPARATOR).size - 1\n (['..'] * dirs_up).join('/') + \"/#{@path}\"\n end\n end\n end","def get_hyperlink(row)\n URI.join(native_host, row.dig('uri')).to_s\n end","def href; end","def readlink_to_pathname\n rl = readlink\n rl.relative? ? parent + rl : rl\n end","def path\r\n url.gsub(/https?:\\/\\/[^\\/]+\\//i, '').scan(/([^&]+)/i).first().first()\r\n end","def link_to_url(link)\n uri = URI.parse(link)\n if uri.absolute?\n if uri.host != URI.parse(host).host\n Grell.logger.debug \"GRELL does not follow links to external hosts: #{link}\"\n nil\n else\n link # Absolute link to our own host\n end\n else\n if uri.path.nil?\n Grell.logger.debug \"GRELL does not follow links without a path: #{uri}\"\n nil\n end\n if uri.path.start_with?('/')\n host + link #convert to full URL\n else #links like href=\"google.com\" the browser would go to http://google.com like \"http://#{link}\"\n Grell.logger.debug \"GRELL Bad formatted link: #{link}, assuming external\"\n nil\n end\n end\n\n rescue URI::InvalidURIError #We will have invalid links propagating till we navigate to them\n link\n end","def href\n \"/admin/dav/#{path}\"\n end","def url(p = path)\n \"/\" + relative_path(p).to_s.downcase.gsub(/\\s/, \" \")\n end","def to_anchor\n anchor = @uri.fragment\n anchor ? Wgit::Url.new(\"##{anchor}\") : nil\n end","def absolute_url\n return unless fileable?\n Rails.application.routes.default_url_options[:host] ||= \"http://localhost:3000\"\n Rails.application.routes.url_helpers.root_url[0..-2] + file.url\n end","def link_to_url\n return redirect_url unless redirect_url.blank?\n path\n end","def href_for(target)\n if (target =~ /^[\\w-]+:/) == 0\n target\n else\n href_resolver && href_resolver.call(target) || \"##{target}\"\n end\n end","def relative_url(input); end","def url_for(str)\n return str if str =~ /^[|[:alpha:]]+:\\/\\//\n File.join((uri.path.empty?) ? uri.to_s : File.dirname(uri.to_s), str)\n end","def absolute_url(url)\n if url && !url.include?(\"http\") \n URI.join(root_url, url)\n else\n url\n end\n end","def href\n @href ||= raw\n .fetch(\"_links\",{})\n .fetch(\"self\",{})\n .fetch(\"href\",nil)\n end","def href\n @href ||= begin\n h = nokoxmlelement.attr('href')\n h != '' ? h : 'site/home'\n end\n end","def make_link( old ) File.link( old, expand_tilde ) end","def href\n if clickable?\n # current_piece.url > current_data_item.url > current_page.url\n return page_layout.href if get_content_param_by_key( :context ) > 0\n return self.collection_tag.running_data_item.path if self.collection_tag.running_data_item.present?\n return self.collection_tag.current_page_tag.path\n end\n end","def realpath\n if(self.page)\n return Rails.application.routes.url_helpers.page_path(self.page)\n end\n '/' + self.explicit_path\n end","def link(target)\n File.join(site.url, target)\n end","def parse_uri(href)\n # to_s prevent to return nil from this method\n Addressable::URI.heuristic_parse(href.to_s) rescue nil\n end","def href\n href = (@url || @dos).to_s.dup\n if @fragment\n href << client('#', 'UTF-8') << @fragment\n end\n href\n end","def relative_path_from(from); end","def normalize_href(type, value)\n href = Api::Href.new(type.to_s)\n\n if href.collection? && href.subcollection?\n # type is a 'reftype' (/:collection/:id/:subcollection)\n normalize_url(\"#{href.collection}/#{href.collection_id}/#{href.subcollection}/#{value}\")\n elsif href.collection == @req.subcollection\n # type is a subcollection name\n # Use the request to assume the proper collection to nest this under\n if collection_config.subcollection?(@req.collection, href.collection.to_sym)\n normalize_url(\"#{@req.collection}/#{@req.collection_id}/#{href.collection}/#{value}\")\n end\n else\n # type is a collection name\n if collection_config.collection?(href.collection)\n normalize_url(\"#{href.collection}/#{value}\")\n end\n end\n end","def abs_path_with(rel_path)\n path = abs_path\n return rel_path if path.nil?\n return \"#{path}.#{rel_path}\"\n end","def absolutize_url(url)\n url =~ /\\Ahttps?/ ? url : \"http://#{url}\"\n end","def absolute_url\n File.join(BLOG.url, url)\n end","def href=(value)\n @href = value\n end","def uri(path)\n s = File::expand_path(path).gsub(DIR, \"\").gsub(File::SEPARATOR, '/')\n return s == '' ? '/' : s\n end","def parse_uri(href)\n # to_s prevent to return nil from this method\n Addressable::URI.parse(href.to_s) rescue nil\n end","def href\n if @node.name == 'span' &&\n @node.first_element_child&.name == 'a' &&\n @node.first_element_child&.has_attribute?('href')\n strip_google_redirect(\n @node.first_element_child.attribute('href').value\n )\n end\n end","def id_from_href(href)\r\n if href.include?(\"?\")\r\n href = href.partition(\"?\")[0]\r\n end\r\n id = href.split(\"/\").last\r\n id\r\n end","def fix_relative_path(entry)\n feed_url = Addressable::URI.parse(url)\n entry.url = feed_url.scheme + '://' + feed_url.host + entry.url\n end","def absolutize_path(path = nil)\n \"#{root_path}#{path}\"\n end","def add_href\n return if attributes.key?(\"href\")\n return unless attributes.key?(\"id\")\n attributes[\"href\"] = client.connection.api_path(\"#{collection.name}/#{attributes['id']}\")\n end","def link(path=\"\",controller=nil)\n return nil if !@workingpath\n if controller\n path = File.join(\"/#{controller}\",\"#{path}\")\n else\n path = File.join(\"/#{@workingpath[1..-1].join('/')}\",\"#{path}\")\n end\n path = path[0..-2] if path.length && path[-1..-1] == \"/\"\n return path\n end","def join_url(base_url, path)\n return path if(path.include?(':')) # Absolute URL contains ':'\n if(path[0..0] == '/')\n new_url = base_url.clone\n new_url.path = path\n new_url.to_s\n else\n (base_file_url + path).to_s\n end\n end","def to_absolute( reference )\n absolute = case reference\n when Arachni::URI\n reference.parsed_url\n when ::URI\n reference\n else\n self.class.new( reference.to_s ).parsed_url\n end.merge( @parsed_url )\n\n self.class.new( absolute )\n end"],"string":"[\n \"def expand_path(href)\\n return href if href.match(/^https*:\\\\/\\\\//) # if starts with protocol complete link\\n return @request_href unless href.match(/[a-zA-Z0-9]+/) # rejects href=\\\"#\\\" and allows non-unique exception handling.\\n return @request_href if href.match(/#[a-zA-Z0-9]*$/)\\n\\n if href[0, 1] != \\\"/\\\"\\n return @request_href + href if @request_href[-1, 1] == \\\"/\\\"\\n return @request_href + \\\"/\\\" + href\\n else\\n # relative path from domain.\\n base_url = @request_href.match(BASEURLREG).to_a.first\\n return base_url + href unless base_url[-1, 1] == \\\"/\\\"\\n return base_url.chop + href\\n end\\n end\",\n \"def url_from_href(href) #:nodoc:\\n scheme, host, path = $1, $2, $3 if URL_PARTS.match href\\n\\n scheme = uri.scheme if scheme.nil? or scheme.empty? and uri.respond_to? :scheme\\n\\n host = uri.host if host.nil? or host.empty? and uri.respond_to? :host\\n\\n path = (\\n (/\\\\/$/.match(uri.path)) ?\\n '%s%s' % [uri.path,path] :\\n '%s/%s' % [File.dirname(uri.path),path]\\n ) unless /^\\\\//.match path\\n\\n '%s://%s%s' % [scheme, host, path]\\n end\",\n \"def to_absolute(link)\\n return nil if link.nil?\\n\\n # remove anchor\\n link = link.to_s.gsub(/#.*$/,'')\\n if Gem::Requirement.new('< 2.5').satisfied_by?(Gem::Version.new(RUBY_VERSION))\\n link = URI.encode(URI.decode(link))\\n end\\n\\n relative = URI(link)\\n absolute = base ? base.merge(relative) : @url.merge(relative)\\n\\n absolute.path = '/' if absolute.path.empty?\\n\\n return absolute\\n end\",\n \"def normalise_href(href)\\n # ignore links which are external, or to in-page anchors\\n return nil if href[0] == \\\"#\\\" || [\\\"/\\\", \\\"http\\\", \\\"mail\\\", \\\"/ima\\\"].include?(href[0, 4])\\n\\n # Remove any trailing anchors, or \\\"/\\\" and leading \\\"./\\\" \\n target = href.sub(/\\\\#.*/, \\\"\\\").sub(/\\\\/$/, \\\"\\\").sub(/\\\\.*/, \\\"\\\").sub(/\\\\/*/, \\\"\\\")\\n\\n # Ignore links which don't point to html files\\n /html$/.match?(target) ? target : nil\\nend\",\n \"def to_absolute(link)\\n # remove anchor\\n link = URI.encode(link.to_s.gsub(/#[a-zA-Z0-9_-]*$/,''))\\n\\n relative = URI(link)\\n absolute = @url.merge(relative)\\n\\n absolute.path = '/' if absolute.path.empty?\\n\\n return absolute\\n end\",\n \"def absolute_url(href)\\n Addressable::URI.join(self.class::DOMAIN, href).to_s\\n end\",\n \"def relativize(href, path, absolute_base, root_dir)\\n # href = actual href string on page\\n # path = actual current location / file path of current page\\n # absolute_base = the base url for the site\\n\\n href_url = URI.join(URI.encode(absolute_base), URI.encode(href))\\n path_url = URI.join(absolute_base, URI.encode(path))\\n relative_url = path_url.route_to(href_url).to_s\\n url_out = test_index(relative_url, href_url, absolute_base, root_dir)\\n if href.match(/^#/)\\n url_out = href\\n end\\n url_out\\nend\",\n \"def to_absolute(link, url)\\n return nil if link.nil?\\n url = URI(url.to_s) unless url.is_a?(URI)\\n\\n # remove anchor\\n link = URI.encode(link.to_s.gsub(/#[a-zA-Z0-9_-]*$/,''))\\n\\n relative = URI(link)\\n absolute = url.merge(relative)\\n\\n absolute.path = '/' if absolute.path.nil? or absolute.path.empty?\\n\\n return absolute\\n end\",\n \"def to_absolute(page, link)\\n # remove anchor\\n link = URI.encode(link.to_s.gsub(/#[a-zA-Z0-9_-]*$/,''))\\n\\n relative = URI(link)\\n absolute = page.url.merge(relative)\\n\\n absolute.path = '/' if absolute.path.empty?\\n\\n return absolute\\n end\",\n \"def relative_link(link)\\n # REMEMBER TO ADD ROUTES TO HANDLE THESE LINKS\\n link.gsub!(@base, \\\"\\\").gsub!(\\\".html\\\", \\\"\\\").gsub!(\\\"-\\\", \\\"_\\\")\\n end\",\n \"def to_absolute(link)\\n # remove fragment\\n link = link.split('#').first if link.index('#')\\n url = URI(URI.encode(link))\\n raise URI::InvalidURIError unless url.path\\n url = @url.merge(url) if url.relative?\\n url.path = '/' if url.path.empty?\\n url\\n end\",\n \"def convert_a(el, indent)\\n\\t\\tif @options[:cdn_prefix]\\n\\t\\t\\tel.attr['href'] = cdn_url(el.attr['href'])\\n\\t\\tend\\n\\t\\t# any hrefs not starting with proto: or / or # are relative and \\n\\t\\t# will be prefixed\\n\\t\\tif el.attr['href'] && el.attr['href'] !~ /(^[\\\\w]*:|^\\\\/|^\\\\#)/\\n\\t\\t\\tel.attr['href'] = File.join(@options[:asset_prefix], el.attr['href'])\\n\\t\\tend\\n\\t\\tsuper\\n\\tend\",\n \"def link_path\\n File.join(\\\"/f/#{@page_name}\\\", name) # /foo/bar_files/file.jpg\\n end\",\n \"def as_href(from_path)\\n RDoc::Markup::ToHtml.gen_relative_url from_path, path\\n end\",\n \"def clean_url(href)\\n # TODO: A better way would be to split by / then take the last section, strip off the anchor then cgi escape\\n URI.unescape(href.strip).gsub(\\\" \\\", \\\"%20\\\")\\n end\",\n \"def site_url(href)\\n path_resolver = (@path_resolver ||= PathResolver.new)\\n base_dir = path_resolver.posixify(@document.base_dir)\\n site_root = path_resolver.posixify(@document.attr('site-root', base_dir))\\n unless path_resolver.is_root? site_root\\n raise ::ArgumentError, %(site-root must be an absolute path: #{site_root})\\n end\\n base_dir_to_root = nil\\n if (base_dir != site_root) && (base_dir.start_with? site_root)\\n comp, root = path_resolver.partition_path(base_dir.slice(site_root.length + 1, base_dir.length))\\n base_dir_to_root = '../' * comp.length\\n end\\n path_resolver.web_path(href, base_dir_to_root)\\n end\",\n \"def href\\n dir = ::File.dirname(file.path)\\n ext = ::File.extname(file.path)\\n\\n if dir != '.'\\n ::File.join(dir, name.chomp(ext)) #file.path) \\n else\\n if name == settings.index #|| 'Home'\\n 'index.html'\\n else\\n name.chomp(ext) #file.path\\n end\\n end\\n end\",\n \"def url(href)\\n a href, :href => href\\n end\",\n \"def get_path_for(path)\\n if path.respond_to?(:href)\\n path = path.href\\n elsif path =~ /^[^\\\\/]/\\n if link = link_for_rel(path)\\n path = link.href\\n end\\n end\\n path\\n end\",\n \"def absolutize_url(url)\\n # file_path = File.expand_path(File.join(working_directory, url))\\n # full_path = File.expand_path(File.join(path, url))\\n # full_path.gsub(File.expand_path(path), '')\\n ('/' + url.split('./').last).gsub(%r(/+), '/')\\n end\",\n \"def makeAbsolute(link, currURL)\\n\\t\\tif not ( link =~ /http/ )\\n\\t\\t\\t# relative link: create absolute link\\n\\n\\t\\t\\t# .edu/pigs/index.html should be treated as .edu/pigs\\n\\t\\t\\tdirectory = /(.*#{Regexp.escape(\\\"/\\\")})\\\\w+#{Regexp.escape(\\\".\\\")}\\\\w+$/.match(currURL)\\n\\t\\t\\tif directory\\n\\t\\t\\t\\tcurrURL = directory[1]\\n\\t\\t\\tend\\n\\n\\t\\t\\t# remove any trailing forward slash\\n\\t\\t\\tif currURL[-1] == \\\"/\\\"\\n\\t\\t\\t\\tcurrURL = currURL[0..-2]\\n\\t\\t\\tend\\n\\n\\t\\t\\t# if the link starts with \\\"/\\\", don't just append\\n\\t\\t\\tif ( link =~ /^#{Regexp.escape(\\\"/\\\")}/ )\\n\\t\\t\\t\\tdomain = URI.parse(currURL).host\\n\\t\\t\\t\\tlink = \\\"http://\\\" + domain + link\\n\\t\\t\\telse\\n\\t\\t\\t\\t# is ../ the start?\\n\\t\\t\\t\\tif ( link =~ /^..#{Regexp.escape(\\\"/\\\")}/ )\\n\\t\\t\\t\\t\\t# make sure you can actually go back a directory: look for bowdoin.edu/***/ at least\\n\\t\\t\\t\\t\\tif ( currURL =~ /.*bowdoin.edu#{Regexp.escape(\\\"/\\\")}.*#{Regexp.escape(\\\"/\\\")}?/ )\\n\\t\\t\\t\\t\\t\\t# remove first instance of ../\\n\\t\\t\\t\\t\\t\\tadjustedLink = link[3..-1]\\n\\t\\t\\t\\t\\t\\tshortened = /.*#{Regexp.escape(\\\"/\\\")}/.match(currURL)\\n\\t\\t\\t\\t\\t\\t# remove / at end (guaranteed if the regex matches)\\n\\t\\t\\t\\t\\t\\tshortened = shortened[0][0..-2]\\n\\n\\t\\t\\t\\t\\t\\t# another instance of ../?\\n\\t\\t\\t\\t\\t\\tif ( adjustedLink =~ /^..#{Regexp.escape(\\\"/\\\")}/ )\\n\\t\\t\\t\\t\\t\\t\\t# recurse on shortened URL\\n\\t\\t\\t\\t\\t\\t\\tresult = makeAbsolute(adjustedLink, shortened)\\n\\t\\t\\t\\t\\t\\telse\\n\\t\\t\\t\\t\\t\\t\\tresult = shortened + \\\"/\\\" + adjustedLink\\n\\t\\t\\t\\t\\t\\t\\treturn result\\n\\t\\t\\t\\t\\t\\tend\\t\\t\\t\\t\\n\\t\\t\\t\\t\\tend\\n\\t\\t\\t\\telse\\n\\t\\t\\t\\t\\t# normal relative link - add to end\\n\\t\\t\\t\\t\\tending = /.*#{Regexp.escape(\\\"/\\\")}([^#{Regexp.escape(\\\"/\\\")}]*)$/.match(currURL)\\n\\t\\t\\t\\t\\tif ending\\n\\t\\t\\t\\t\\t\\ttoMatch = ending[1]\\n\\t\\t\\t\\t\\t\\tif ( link =~ /^#{toMatch}/ )\\n\\t\\t\\t\\t\\t\\t\\tputs \\\"Repeats, avoiding \\\" + link\\n\\t\\t\\t\\t\\t\\t\\treturn currURL\\n\\t\\t\\t\\t\\t\\telse\\n\\t\\t\\t\\t\\t\\t\\treturn currURL + \\\"/\\\" + link\\n\\t\\t\\t\\t\\t\\tend\\n\\t\\t\\t\\t\\tend\\n\\n\\t\\t\\t\\tend\\n\\t\\t\\tend\\n\\t\\telse\\n\\t\\t\\treturn link\\n\\t\\tend\\n\\tend\",\n \"def absolutify url, cd \\n url = url.to_s\\n # deal w/ bad URLs, already absolute, etc\\n begin\\n u = URI.parse(url)\\n rescue\\n # GIGO, no need for alarm\\n return url\\n end\\n\\n return url if u.absolute? # http://example.com/about\\n c = URI.parse(cd)\\n return c.scheme + \\\"://\\\" + c.host + url if url.index('/') == 0 # /about\\n return cd + url if url.match(/^[a-zA-Z]+/) # about*\\n\\n # only relative from here on in; ../about, ./about, ../../about\\n u_dirs = u.path.split('/')\\n c_dirs = c.path.split('/')\\n\\n # move up the directory until there are no more relative paths\\n u.path.split('/').each do |x|\\n break unless (x == '' || x == '..' || x == '.')\\n u_dirs.shift\\n c_dirs.pop unless x == '.'\\n end\\n return c.scheme + \\\"://\\\" + c.host + c_dirs.join('/') + '/' + u_dirs.join('/')\\n end\",\n \"def to_url(host)\\n uri = URI.parse(href)\\n if uri.absolute?\\n if uri.host != URI.parse(host).host\\n Grell.logger.debug \\\"GRELL does not follow links to external hosts: #{href}\\\"\\n nil\\n else\\n href # Absolute link to our own host\\n end\\n else\\n if uri.path.nil?\\n Grell.logger.debug \\\"GRELL does not follow links without a path: #{uri}\\\"\\n nil\\n end\\n if uri.path.start_with?('/')\\n host + href # convert to full URL\\n else # links like href=\\\"google.com\\\" the browser would go to http://google.com like \\\"http://#{link}\\\"\\n Grell.logger.debug \\\"GRELL Bad formatted link: #{href}, assuming external\\\"\\n nil\\n end\\n end\\n rescue URI::InvalidURIError # Invalid links propagating till we navigate to them\\n href\\n end\",\n \"def link_path\\n File.join('/_attachment', @page_name, name)\\n end\",\n \"def absolute_url_for(uri, str)\\n # TODO: use URI.parse() for better handling?\\n return str if str =~ /^[|[:alpha:]]+:\\\\/\\\\//\\n File.join(((uri.path.empty?) ? uri.to_s : File.dirname(uri.to_s)), \\n str)\\n end\",\n \"def absolutify_url(uri)\\n if uri =~ /^\\\\w*\\\\:/i\\n normalize_url(uri)\\n else\\n Addressable::URI.join(@url, uri).normalize.to_s\\n end\\n rescue URI::InvalidURIError, Addressable::URI::InvalidURIError => e\\n add_fatal_error \\\"Link parsing exception: #{e.message}\\\" and nil\\n end\",\n \"def fix_link_path(absolute_path, link)\\r\\n\\t\\tabsolute_path += \\\"/\\\" if !absolute_path.end_with?(\\\"/\\\") && !link.start_with?(\\\"/\\\")\\r\\n\\t\\tabsolute_path + link\\r\\n\\tend\",\n \"def absolutify_url(url)\\n url =~ /^\\\\w*\\\\:/i ? url : File.join(@url,url)\\n end\",\n \"def href\\n @href ||= build_href(path, collection: self.collection?)\\n end\",\n \"def build_href(path, collection: false)\\n if propstat_relative_path\\n request.path_for path, collection: collection\\n else\\n request.url_for path, collection: collection\\n end\\n end\",\n \"def make_absolute_url(url)\\n return url unless Addressable::URI.parse(url).relative?\\n begin\\n Addressable::URI.parse(@page_url).merge(url).to_s\\n rescue\\n url\\n end\\n end\",\n \"def absolute_url\\n domain + path\\n end\",\n \"def raw_href\\n templated? ? template.pattern : target.href\\n end\",\n \"def href\\n attributes[:href]\\n end\",\n \"def normalize_path(url); end\",\n \"def normalize_path(url); end\",\n \"def resolve_file_path(anchor)\\n return anchor if anchor.path.end_with?('index.html') && File.exist?(\\\"out#{anchor.path}\\\")\\n\\n # Check if path is in list of redirects\\n # This the initial source path\\n redirect_source = anchor.path\\n # This is the final destination\\n redirect_final_dest = nil\\n # Trigger to stop redirect evaluation\\n stop_redirect_evaluation = false\\n\\n until stop_redirect_evaluation\\n stop_redirect_evaluation = true\\n\\n next unless REDIRECTS.key?(redirect_source)\\n\\n redirect_source = REDIRECTS[redirect_source]\\n redirect_final_dest = URI.parse(redirect_source)\\n stop_redirect_evaluation = false\\n end\\n\\n # Return path if redirect resolved to an external URL\\n case redirect_final_dest.class.to_s\\n when 'URI::HTTP', 'URI::HTTPS'\\n return redirect_final_dest\\n when 'URI::Generic'\\n begin\\n anchor = anchor.merge(redirect_final_dest)\\n rescue URI::BadURIError\\n anchor = redirect_final_dest\\n end\\n end\\n\\n # List of potential path extensions\\n potential_extensions = [\\n # change /path/ to path.html\\n anchor.path.sub(%r{/$}, '.html'),\\n # change /path to /path.html\\n \\\"#{anchor.path}.html\\\",\\n # /path/index.html\\n \\\"#{anchor.path}/index.html\\\"\\n ]\\n\\n potential_prefixes = [\\n # relative\\n '',\\n # absolute\\n '/'\\n ]\\n\\n potential_prefixes.each do |prefix|\\n potential_extensions.each do |suffix|\\n test_path = \\\"#{prefix}#{suffix}\\\"\\n if File.exist?(\\\"out#{test_path}\\\") && File.file?(\\\"out#{test_path}\\\")\\n anchor.path = test_path\\n return anchor\\n end\\n end\\n end\\n\\n # Return the original path we were passed in.\\n # Its possible this is a redirect which will be resolved later.\\n anchor\\nend\",\n \"def normalize_uri\\r\\n self.link = Addressable::URI.heuristic_parse(self.link).normalize!.to_s if self.link\\r\\n end\",\n \"def make_absolute_url(url)\\n return url unless URI.parse(url).relative?\\n begin\\n URI.parse(@page_url).merge(url).to_s\\n rescue URI::Error\\n url\\n end\\n end\",\n \"def full_path(current_url, link)\\n uri = URI current_url\\n uri.merge link\\n rescue URI::InvalidURIError => e\\n uri.merge URI.escape(link)\\n end\",\n \"def get_absolute_file_url(url)\\n orig_url = url.to_s.strip\\n \\n url = file_url(orig_url)\\n # If a file:// was stripped from the url, this means it will always point\\n # to a file\\n force_file = (orig_url != url)\\n # Indicates wether the base url is a network url or a file/directory\\n base_is_net = !base_file_url.is_a?(String)\\n # Try to find if we have a \\\"net\\\" URL if we aren't sure if this is a file. In\\n # case the base url is a network url, we'll always assume that the\\n # url is also a net thing. Otherwise we only have a net url if it contains a\\n # '://' string\\n is_net_url = !force_file && (base_is_net || url.include?('://'))\\n # The url is absolute if there is a : character to be found\\n \\n \\n if(is_net_url)\\n base_is_net ? join_url(base_file_url, url) : url\\n else\\n base_is_net ? url : join_files(base_file_url, url)\\n end\\n end\",\n \"def absolutify_url(src, base_url, parent_url)\\r\\n if src.nil? || src.empty? || src == \\\"//:\\\" || src =~ /\\\\s*http:\\\\/\\\\//i\\r\\n return src\\r\\n end\\r\\n\\r\\n return \\\"#{base_url}#{src}\\\" if src =~ /^\\\\s*\\\\//\\r\\n return \\\"#{parent_url}#{src}\\\" if parent_url\\r\\n return src\\r\\n end\",\n \"def full_url(url, path)\\n if path.start_with?('http')\\n path\\n else\\n url = url[0..1] if url.end_with?('/')\\n path = path[1..-1] if path.start_with?('/')\\n \\\"#{url}/#{path}\\\"\\n end\\n end\",\n \"def get_link_path(url)\\n ((link_path = url.sub(@donor.url, '').squish)[0] == '/') ? link_path : ('/' + link_path)\\n end\",\n \"def absolutify_url(src, base_url, parent_url)\\n if src.nil? || src.empty? || src == \\\"//:\\\" || src =~ /\\\\s*http:\\\\/\\\\//i\\n return src\\n end\\n \\n return \\\"#{base_url}#{src}\\\" if src =~ /^\\\\s*\\\\//\\n return \\\"#{parent_url}#{src}\\\" if parent_url\\n return src\\n end\",\n \"def relative_path(from, to); end\",\n \"def rel_to(path)\\n path = path + '/' unless path.end_with?('/')\\n if rel.start_with?(path)\\n rel.sub(path, '')\\n else\\n raise \\\"#{@abs} is not in #{path}\\\"\\n end\\n end\",\n \"def uri\\n @uri ||= if @href then\\n begin\\n URI.parse @href\\n rescue URI::InvalidURIError\\n begin\\n URI.parse(Addressable::URI.escape(@href))\\n rescue Addressable::URI::InvalidURIError\\n raise URI::InvalidURIError\\n end\\n end\\n end\\n end\",\n \"def change_hrefs(html)\\n DOM.walk(html) do |node|\\n for attr_name in %w{href src}\\n attr_obj = node.attributes[attr_name]\\n\\n # Ignore if its blank\\n next if !attr_obj\\n\\n # URL encode any spaces\\n orig_href = attr_obj.to_s.gsub(\\\" \\\", \\\"%20\\\")\\n\\n begin\\n src = URI(orig_href)\\n rescue\\n log \\\"#{orig_href} not a valid URI\\\"\\n next\\n end\\n\\n if internal_link?(src.to_s)\\n linked_item = nil\\n\\n if src.path == \\\"\\\"\\n # If its just an anchor like '#this' just set to the current file\\n linked_item = self\\n else\\n # Match on the unescaped href\\n unescaped_path = URI::unescape(src.path)\\n linked_item = get_item(unescaped_path)\\n end\\n\\n # Change link\\n if linked_item\\n new_path = linked_item.normalized_hashed_path(:relative_to => self)\\n new_path = URI(new_path)\\n\\n if src.fragment\\n new_path.fragment = src.fragment\\n end\\n\\n log \\\"Changing #{src.to_s} to #{new_path.to_s}\\\"\\n attr_obj.content = new_path.to_s\\n else\\n log \\\"No item in manifest for #{src}\\\"\\n end\\n end\\n end\\n end\\n end\",\n \"def process\\n return nil unless link_url?\\n url = @url.dup\\n if url = parse(url)\\n return parse_relative_url unless url.host\\n url.scheme ||= @source_url.scheme\\n if same_source_host? || external_asset_url?\\n URI.unescape(url.to_s, '%7C')\\n end\\n end\\n end\",\n \"def make_folders_absolute(f,tt)\\n tt.elements.each(\\\"//node\\\") do |nn|\\n if nn.attributes['LINK']\\n nn.attributes['LINK']= File.expand_path(File.dirname(f))+\\\"/#{nn.attributes['LINK']}\\\"\\n end\\n end\\n end\",\n \"def pathname(path, link)\\n path_string = path&.length&.positive? ? '/' + path.join('/') : ''\\n path_string = path_string.tr(' ', '-')\\n \\\"/#{SITEMAP_SUBDIRECTORY}/#{name}#{path_string}/#{link}\\\"\\n end\",\n \"def linked_path_for(path)\\n return path unless path.include?('/')\\n current_path_base = request.env['REQUEST_URI'].gsub(path,'')\\n dirs = path.split('/')\\n file = dirs.pop\\n linked_path = ''\\n dirs.each do |dir|\\n link = '' + dir + ''\\n current_path_base << \\\"#{dir}/\\\"\\n linked_path << \\\"#{link}/\\\" \\n end\\n linked_path << file\\n end\",\n \"def make_folders_absolute(f,tt)\\n tt.elements.each(\\\"//node\\\") do |nn|\\n if nn.attributes['LINK']\\n nn.attributes['LINK']= File.expand_path(File.dirname(f))+\\\"/#{nn.attributes['LINK']}\\\"\\n end\\n end\\n end\",\n \"def path\\n @path ||= filters.uri_escape(absolute_url) if absolute_url\\n end\",\n \"def path\\n @path ||= filters.uri_escape(absolute_url) if absolute_url\\n end\",\n \"def convert_relative_links(url)\\n base_url = doc.css('base').present? ? doc.css('base')[0]['href'] : url.split('?').first \\n return if base_url.blank?\\n doc.css('a').each do |link|\\n link['href'] = converted_link(base_url, link['href'])\\n end\\n end\",\n \"def link_name(name)\\n File.expand_path(File.join('~', '.' + File.basename(name)))\\nend\",\n \"def link_to(title, path, opts={}, base=true)\\n unless is_uri?(path) || base == false\\n path = url(path)\\n end\\n \\n return \\\"#{title}\\\"\\n end\",\n \"def expand_path( path )\\n File.expand_path( path.gsub( /^\\\\/+/, '' ), self.link.path.gsub( /\\\\/*$/, '/' ) ).gsub( /^C:/, '')\\n end\",\n \"def absolute_uri_path(path)\\n \\\"#{root_uri}#{path}\\\"\\n end\",\n \"def link\\n # TODO: URL escape links\\n if top_level? && (!is_a? SiteDir)\\n name\\n else\\n if is_a? SiteDir # TODO: do a dynamic renderable test?\\n top_level? ? \\\"dropsite/#{@path}.html\\\" : \\\"#{@path}.html\\\".sub(/^\\\\//, '')\\n else\\n # Builds a link back up to the file in Public root since the pages\\n # are built in a parallel directory structure\\n dirs_up = @path.split(File::SEPARATOR).size - 1\\n (['..'] * dirs_up).join('/') + \\\"/#{@path}\\\"\\n end\\n end\\n end\",\n \"def get_hyperlink(row)\\n URI.join(native_host, row.dig('uri')).to_s\\n end\",\n \"def href; end\",\n \"def readlink_to_pathname\\n rl = readlink\\n rl.relative? ? parent + rl : rl\\n end\",\n \"def path\\r\\n url.gsub(/https?:\\\\/\\\\/[^\\\\/]+\\\\//i, '').scan(/([^&]+)/i).first().first()\\r\\n end\",\n \"def link_to_url(link)\\n uri = URI.parse(link)\\n if uri.absolute?\\n if uri.host != URI.parse(host).host\\n Grell.logger.debug \\\"GRELL does not follow links to external hosts: #{link}\\\"\\n nil\\n else\\n link # Absolute link to our own host\\n end\\n else\\n if uri.path.nil?\\n Grell.logger.debug \\\"GRELL does not follow links without a path: #{uri}\\\"\\n nil\\n end\\n if uri.path.start_with?('/')\\n host + link #convert to full URL\\n else #links like href=\\\"google.com\\\" the browser would go to http://google.com like \\\"http://#{link}\\\"\\n Grell.logger.debug \\\"GRELL Bad formatted link: #{link}, assuming external\\\"\\n nil\\n end\\n end\\n\\n rescue URI::InvalidURIError #We will have invalid links propagating till we navigate to them\\n link\\n end\",\n \"def href\\n \\\"/admin/dav/#{path}\\\"\\n end\",\n \"def url(p = path)\\n \\\"/\\\" + relative_path(p).to_s.downcase.gsub(/\\\\s/, \\\" \\\")\\n end\",\n \"def to_anchor\\n anchor = @uri.fragment\\n anchor ? Wgit::Url.new(\\\"##{anchor}\\\") : nil\\n end\",\n \"def absolute_url\\n return unless fileable?\\n Rails.application.routes.default_url_options[:host] ||= \\\"http://localhost:3000\\\"\\n Rails.application.routes.url_helpers.root_url[0..-2] + file.url\\n end\",\n \"def link_to_url\\n return redirect_url unless redirect_url.blank?\\n path\\n end\",\n \"def href_for(target)\\n if (target =~ /^[\\\\w-]+:/) == 0\\n target\\n else\\n href_resolver && href_resolver.call(target) || \\\"##{target}\\\"\\n end\\n end\",\n \"def relative_url(input); end\",\n \"def url_for(str)\\n return str if str =~ /^[|[:alpha:]]+:\\\\/\\\\//\\n File.join((uri.path.empty?) ? uri.to_s : File.dirname(uri.to_s), str)\\n end\",\n \"def absolute_url(url)\\n if url && !url.include?(\\\"http\\\") \\n URI.join(root_url, url)\\n else\\n url\\n end\\n end\",\n \"def href\\n @href ||= raw\\n .fetch(\\\"_links\\\",{})\\n .fetch(\\\"self\\\",{})\\n .fetch(\\\"href\\\",nil)\\n end\",\n \"def href\\n @href ||= begin\\n h = nokoxmlelement.attr('href')\\n h != '' ? h : 'site/home'\\n end\\n end\",\n \"def make_link( old ) File.link( old, expand_tilde ) end\",\n \"def href\\n if clickable?\\n # current_piece.url > current_data_item.url > current_page.url\\n return page_layout.href if get_content_param_by_key( :context ) > 0\\n return self.collection_tag.running_data_item.path if self.collection_tag.running_data_item.present?\\n return self.collection_tag.current_page_tag.path\\n end\\n end\",\n \"def realpath\\n if(self.page)\\n return Rails.application.routes.url_helpers.page_path(self.page)\\n end\\n '/' + self.explicit_path\\n end\",\n \"def link(target)\\n File.join(site.url, target)\\n end\",\n \"def parse_uri(href)\\n # to_s prevent to return nil from this method\\n Addressable::URI.heuristic_parse(href.to_s) rescue nil\\n end\",\n \"def href\\n href = (@url || @dos).to_s.dup\\n if @fragment\\n href << client('#', 'UTF-8') << @fragment\\n end\\n href\\n end\",\n \"def relative_path_from(from); end\",\n \"def normalize_href(type, value)\\n href = Api::Href.new(type.to_s)\\n\\n if href.collection? && href.subcollection?\\n # type is a 'reftype' (/:collection/:id/:subcollection)\\n normalize_url(\\\"#{href.collection}/#{href.collection_id}/#{href.subcollection}/#{value}\\\")\\n elsif href.collection == @req.subcollection\\n # type is a subcollection name\\n # Use the request to assume the proper collection to nest this under\\n if collection_config.subcollection?(@req.collection, href.collection.to_sym)\\n normalize_url(\\\"#{@req.collection}/#{@req.collection_id}/#{href.collection}/#{value}\\\")\\n end\\n else\\n # type is a collection name\\n if collection_config.collection?(href.collection)\\n normalize_url(\\\"#{href.collection}/#{value}\\\")\\n end\\n end\\n end\",\n \"def abs_path_with(rel_path)\\n path = abs_path\\n return rel_path if path.nil?\\n return \\\"#{path}.#{rel_path}\\\"\\n end\",\n \"def absolutize_url(url)\\n url =~ /\\\\Ahttps?/ ? url : \\\"http://#{url}\\\"\\n end\",\n \"def absolute_url\\n File.join(BLOG.url, url)\\n end\",\n \"def href=(value)\\n @href = value\\n end\",\n \"def uri(path)\\n s = File::expand_path(path).gsub(DIR, \\\"\\\").gsub(File::SEPARATOR, '/')\\n return s == '' ? '/' : s\\n end\",\n \"def parse_uri(href)\\n # to_s prevent to return nil from this method\\n Addressable::URI.parse(href.to_s) rescue nil\\n end\",\n \"def href\\n if @node.name == 'span' &&\\n @node.first_element_child&.name == 'a' &&\\n @node.first_element_child&.has_attribute?('href')\\n strip_google_redirect(\\n @node.first_element_child.attribute('href').value\\n )\\n end\\n end\",\n \"def id_from_href(href)\\r\\n if href.include?(\\\"?\\\")\\r\\n href = href.partition(\\\"?\\\")[0]\\r\\n end\\r\\n id = href.split(\\\"/\\\").last\\r\\n id\\r\\n end\",\n \"def fix_relative_path(entry)\\n feed_url = Addressable::URI.parse(url)\\n entry.url = feed_url.scheme + '://' + feed_url.host + entry.url\\n end\",\n \"def absolutize_path(path = nil)\\n \\\"#{root_path}#{path}\\\"\\n end\",\n \"def add_href\\n return if attributes.key?(\\\"href\\\")\\n return unless attributes.key?(\\\"id\\\")\\n attributes[\\\"href\\\"] = client.connection.api_path(\\\"#{collection.name}/#{attributes['id']}\\\")\\n end\",\n \"def link(path=\\\"\\\",controller=nil)\\n return nil if !@workingpath\\n if controller\\n path = File.join(\\\"/#{controller}\\\",\\\"#{path}\\\")\\n else\\n path = File.join(\\\"/#{@workingpath[1..-1].join('/')}\\\",\\\"#{path}\\\")\\n end\\n path = path[0..-2] if path.length && path[-1..-1] == \\\"/\\\"\\n return path\\n end\",\n \"def join_url(base_url, path)\\n return path if(path.include?(':')) # Absolute URL contains ':'\\n if(path[0..0] == '/')\\n new_url = base_url.clone\\n new_url.path = path\\n new_url.to_s\\n else\\n (base_file_url + path).to_s\\n end\\n end\",\n \"def to_absolute( reference )\\n absolute = case reference\\n when Arachni::URI\\n reference.parsed_url\\n when ::URI\\n reference\\n else\\n self.class.new( reference.to_s ).parsed_url\\n end.merge( @parsed_url )\\n\\n self.class.new( absolute )\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.74313325","0.7259466","0.7234768","0.7195484","0.71680987","0.71527714","0.7023498","0.6959961","0.6959891","0.6949252","0.69085574","0.6827566","0.6731841","0.67244583","0.671601","0.6713233","0.67031634","0.66990775","0.66528964","0.6634661","0.6624634","0.65588886","0.6506714","0.6500628","0.6492348","0.647526","0.6429499","0.6426743","0.6413162","0.64031446","0.63832676","0.6382906","0.63668346","0.6365149","0.63220483","0.63220483","0.62938005","0.62754536","0.62653816","0.6258122","0.62548554","0.62459016","0.6238884","0.62363315","0.6231066","0.6227374","0.61901075","0.6182329","0.6172808","0.6113818","0.6088514","0.60857487","0.60754615","0.6072149","0.6068971","0.6068971","0.60659593","0.605609","0.6042865","0.60402215","0.6037761","0.60330874","0.60324234","0.60302","0.6027449","0.60233533","0.60223883","0.60103005","0.59945995","0.5987092","0.598485","0.5984378","0.5972324","0.5969518","0.5959589","0.59536195","0.5950589","0.5943583","0.5940721","0.5939675","0.5936555","0.59351796","0.5933142","0.59122026","0.59077525","0.5901057","0.5896921","0.5895379","0.58891886","0.58888173","0.58815503","0.5881388","0.5877308","0.58745986","0.5871992","0.58708125","0.5869118","0.5867521","0.585986","0.58548576"],"string":"[\n \"0.74313325\",\n \"0.7259466\",\n \"0.7234768\",\n \"0.7195484\",\n \"0.71680987\",\n \"0.71527714\",\n \"0.7023498\",\n \"0.6959961\",\n \"0.6959891\",\n \"0.6949252\",\n \"0.69085574\",\n \"0.6827566\",\n \"0.6731841\",\n \"0.67244583\",\n \"0.671601\",\n \"0.6713233\",\n \"0.67031634\",\n \"0.66990775\",\n \"0.66528964\",\n \"0.6634661\",\n \"0.6624634\",\n \"0.65588886\",\n \"0.6506714\",\n \"0.6500628\",\n \"0.6492348\",\n \"0.647526\",\n \"0.6429499\",\n \"0.6426743\",\n \"0.6413162\",\n \"0.64031446\",\n \"0.63832676\",\n \"0.6382906\",\n \"0.63668346\",\n \"0.6365149\",\n \"0.63220483\",\n \"0.63220483\",\n \"0.62938005\",\n \"0.62754536\",\n \"0.62653816\",\n \"0.6258122\",\n \"0.62548554\",\n \"0.62459016\",\n \"0.6238884\",\n \"0.62363315\",\n \"0.6231066\",\n \"0.6227374\",\n \"0.61901075\",\n \"0.6182329\",\n \"0.6172808\",\n \"0.6113818\",\n \"0.6088514\",\n \"0.60857487\",\n \"0.60754615\",\n \"0.6072149\",\n \"0.6068971\",\n \"0.6068971\",\n \"0.60659593\",\n \"0.605609\",\n \"0.6042865\",\n \"0.60402215\",\n \"0.6037761\",\n \"0.60330874\",\n \"0.60324234\",\n \"0.60302\",\n \"0.6027449\",\n \"0.60233533\",\n \"0.60223883\",\n \"0.60103005\",\n \"0.59945995\",\n \"0.5987092\",\n \"0.598485\",\n \"0.5984378\",\n \"0.5972324\",\n \"0.5969518\",\n \"0.5959589\",\n \"0.59536195\",\n \"0.5950589\",\n \"0.5943583\",\n \"0.5940721\",\n \"0.5939675\",\n \"0.5936555\",\n \"0.59351796\",\n \"0.5933142\",\n \"0.59122026\",\n \"0.59077525\",\n \"0.5901057\",\n \"0.5896921\",\n \"0.5895379\",\n \"0.58891886\",\n \"0.58888173\",\n \"0.58815503\",\n \"0.5881388\",\n \"0.5877308\",\n \"0.58745986\",\n \"0.5871992\",\n \"0.58708125\",\n \"0.5869118\",\n \"0.5867521\",\n \"0.585986\",\n \"0.58548576\"\n]"},"document_score":{"kind":"string","value":"0.7278829"},"document_rank":{"kind":"string","value":"1"}}},{"rowIdx":1880,"cells":{"query":{"kind":"string","value":"reduce any '../', './', and '//' in a path or uri"},"document":{"kind":"string","value":"def reduce_path(path)\n if path =~ /^(https?:\\/\\/.+)(\\/.*)/\n prefix = $1\n path = $2\n relative = false\n else\n prefix = nil\n relative = path[0] != '/'\n end\n\n while path.sub!(/\\/*[^\\/]+\\/+\\.\\./, ''); end\n while path.sub!(/\\/+\\.\\/+/, '/'); end\n path = path[2..-1] if path[0..1] == './'\n while path.sub!(/\\/\\//, '/'); end\n\n path = path[1..-1] if relative and path[0] == '/'\n path = prefix + path if prefix\n path\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def uri(path)\n s = File::expand_path(path).gsub(DIR, \"\").gsub(File::SEPARATOR, '/')\n return s == '' ? '/' : s\n end","def normalize_path(url); end","def normalize_path(url); end","def normalize_uri(*strs)\n new_str = strs * \"/\"\n\n new_str = new_str.gsub!(\"//\", \"/\") while new_str.index(\"//\")\n\n # Makes sure there's a starting slash\n unless new_str[0,1] == '/'\n new_str = '/' + new_str\n end\n\n new_str\n end","def normalize_uri(*strs)\n new_str = strs * '/'\n new_str = new_str.gsub!('//', '/') while new_str.index('//')\n new_str\n end","def fullpath(uri)\n return File.join(DIR, uri.gsub('/', File::SEPARATOR))\n end","def humanish(uri)\n uri.path.split('/').last.gsub('.git', '')\n end","def normalize_path(path); end","def normalize_path(path); end","def get_path(uri)\n name = uri.gsub(\"http://\", \"\")\n dir_list = name.split(\"/\")\n return dir_list\n end","def uri_normalize(uri)\n \treturn 'http://' + uri unless uri =~ /http:\\/\\//\n \turi\n\tend","def uri_normalize(uri)\n \treturn 'http://' + uri unless uri =~ /http:\\/\\//\n \turi\n\tend","def host_and_path(uri)\n uri = URI.parse(uri) unless uri.is_a? URI\n host = uri.host\n path = uri.path.gsub(/\\/$/, '')\n path = path.empty? ? '/' : uri.path\n URI.parse(\"#{host}#{path}\")\n end","def uri_path(str)\n str.gsub(%r{[^/]+}n) { uri_segment($&) }\n end","def conform_uri(uri_string)\n uri_string.gsub(/^(?!\\/)(.*)/, '/\\1').gsub(/[\\/]+$/, '')\n end","def path_without_name_and_ref(path); end","def normalize_path(path)\n path.sub(%r{^/}, '').tr('', '')\n end","def normalize_path(path)\n path = \"/#{path}\"\n path.squeeze!('/')\n path.sub!(%r{/+\\Z}, '')\n path = '/' if path == ''\n path\n end","def url_for(str)\n return str if str =~ /^[|[:alpha:]]+:\\/\\//\n File.join((uri.path.empty?) ? uri.to_s : File.dirname(uri.to_s), str)\n end","def relativize_path(path)\n path.to_s.gsub(/^\\/?#{Regexp.escape(root_path.to_s)}\\/?/, '')\n end","def normalize_url(path)\n @known_pairs ||= {}\n @public_directories_regex ||= Regexp.new(Bones.public_directories.join('|'))\n \n if v = @known_pairs[path]\n return v\n else\n value = case\n when path =~ /^(\\w{3,}:\\/\\/|mailto)/\n # don't do anything to this type of URL\n return path\n when path =~ @public_directories_regex\n path\n when File.directory?('pages' / path)\n path\n else\n # don't add .html if there's already an extension\n path =~ /\\..+/ ? path : path + '.html'\n end\n \n @known_pairs[path] = options.base / value\n end \n end","def normalize_path(path)\n path = \"/#{path}\"\n path.squeeze!('/')\n path.sub!(%r{/+\\Z}, '')\n path = '/' if path == ''\n path\n end","def remove_leading_slash(path); end","def get_file_uri_path(uri)\n uri.sub(%r{\\Afile://}, '')\n end","def unescape_path(path); end","def file_uri_from_path(path)\n path = path.to_s if path.is_a?(Pathname)\n path = path.tr('\\\\', '/') if windows?\n path = URI::DEFAULT_PARSER.escape(path)\n return path.start_with?('/') ? \"file://\" + path : path unless windows?\n return \"file:///\" + path.tr(\"\\\\\", \"/\") if path =~ %r{^[a-zA-Z]:[/\\\\]}\n return \"file:\" + path.tr(\"\\\\\", \"/\") if path =~ %r{\\\\\\\\[^\\\\]+\\\\[^\\\\/]+}\n path.tr(\"\\\\\", \"/\")\n end","def simplify_path(path)\n return '' if path.empty?\n\n start_with_slash = path[0] == '/'\n stack = []\n stack << '' if start_with_slash\n tokens = path.split('/')\n tokens.each do |token|\n case token\n when '..'\n stack.pop if stack[-1] != ''\n\n when '.', ''\n next\n else\n stack.push token\n end\n end\n\n return '/' if stack.length == 1 && stack[0] == ''\n\n stack.join('/')\nend","def absolute_url_for(uri, str)\n # TODO: use URI.parse() for better handling?\n return str if str =~ /^[|[:alpha:]]+:\\/\\//\n File.join(((uri.path.empty?) ? uri.to_s : File.dirname(uri.to_s)), \n str)\n end","def extract_path(input)\n input_s = input.to_s\n if /^(\\w+):/.match(input_s)\n input_s.gsub(/^\\w+:[^\\/]*\\/\\/[^\\/]+(\\/[^\\?]+)(?:\\?.*)?$/, '\\1')\n else\n input_s.gsub(/(?:\\?.*)$/, '')\n end\n end","def reg_url2; /(.+)\\//; end","def reg_url2; /(.+)\\//; end","def normalize_paths(paths)\n paths = [paths] unless paths.is_a?(Array)\n paths.map(&:dup).map do |path|\n raise ArgumentError.new(\"Invalid path: #{path}\") unless valid_path?(path)\n # Strip leading slash from extension path\n path.gsub!(/^\\/(?=\\*.)/, '')\n # Escape some valid special characters\n path.gsub!(/[.+$\"]/) {|s| '\\\\' + s}\n # Replace * wildcards with .* regex fragment\n path.gsub!(/\\*/, '.*')\n \"^#{path}#{END_URL_REGEX}\"\n end\nend","def get_file_uri_path(uri)\n uri.sub(%r{\\Afile://}, '')\n end","def canonical_path\n p = path.gsub(/\\/+/,'/')\n p.length > 1 ? p.chomp('/') : p\n end","def extract_path(uri_or_path)\n uri = URI(uri_or_path)\n uri.kind_of?(URI::HTTP) ? uri.request_uri : uri_or_path\n end","def categorize_uri(str)\n regex = /\\.+/ # really simple host regex to thwart unwanted strings\n str = \"http://#{str}\" unless str.to_s =~ %r{\\Ahttps?://}\n uri = URI.parse(str.to_s)\n path = uri.path.chomp('/')\n return :unknown if (uri.host =~ regex).nil?\n\n path.empty? ? :host : :url\n rescue URI::InvalidURIError\n :unknown\n end","def normalize_uri(uri)\n (uri =~ /^(https?|ftp|file):/) ? uri : \"http://#{uri}\"\n end","def absolutize_url(url)\n # file_path = File.expand_path(File.join(working_directory, url))\n # full_path = File.expand_path(File.join(path, url))\n # full_path.gsub(File.expand_path(path), '')\n ('/' + url.split('./').last).gsub(%r(/+), '/')\n end","def normalized_request_path(path)\n if path == \"/\"\n path\n else\n path.chomp(\"/\")\n end\n end","def fix_oneoff url\n begin\n uri = URI.parse url\n return (\"\" == uri.path) ? url + '/' : url\n rescue\n #puts \"Ran into issue processing #{url}\"\n end\n end","def uri_normalizer; end","def normalize_req_path(req_path)\n # 1) Decode the req_path with URI::decode\n req_path = URI::decode(req_path)\n # 2) Strip first\n req_path = req_path.strip\n # 3) Remove first slash \n req_path = req_path[1..-1] if req_path[0,1]=='/'\n # 4) Remove last slash\n req_path = req_path[0..-2] if req_path[req_path.length-1,1]=='/'\n req_path\n end","def expand_path( path )\n File.expand_path( path.gsub( /^\\/+/, '' ), self.link.path.gsub( /\\/*$/, '/' ) ).gsub( /^C:/, '')\n end","def path_without_name_and_ref(path)\n Jekyll.sanitized_path theme.root, path.split(\"/\").drop(1).join(\"/\")\n end","def merge_path(base, rel)\n\n # RFC2396, Section 5.2, 5)\n # RFC2396, Section 5.2, 6)\n base_path = split_path(base)\n rel_path = split_path(rel)\n\n # RFC2396, Section 5.2, 6), a)\n base_path << '' if base_path.last == '..'\n while i = base_path.index('..')\n base_path.slice!(i - 1, 2)\n end\n\n if (first = rel_path.first) and first.empty?\n base_path.clear\n rel_path.shift\n end\n\n # RFC2396, Section 5.2, 6), c)\n # RFC2396, Section 5.2, 6), d)\n rel_path.push('') if rel_path.last == '.' || rel_path.last == '..'\n rel_path.delete('.')\n\n # RFC2396, Section 5.2, 6), e)\n tmp = []\n rel_path.each do |x|\n if x == '..' &&\n !(tmp.empty? || tmp.last == '..')\n tmp.pop\n else\n tmp << x\n end\n end\n\n add_trailer_slash = !tmp.empty?\n if base_path.empty?\n base_path = [''] # keep '/' for root directory\n elsif add_trailer_slash\n base_path.pop\n end\n while x = tmp.shift\n if x == '..'\n # RFC2396, Section 4\n # a .. or . in an absolute path has no special meaning\n base_path.pop if base_path.size > 1\n else\n # if x == '..'\n # valid absolute (but abnormal) path \"/../...\"\n # else\n # valid absolute path\n # end\n base_path << x\n tmp.each {|t| base_path << t}\n add_trailer_slash = false\n break\n end\n end\n base_path.push('') if add_trailer_slash\n\n return base_path.join('/')\n end","def path\n return @path.sub(/^\\//,'').sub(/^%2F/,'/')\n end","def path_from_url(url)\n\tresult = url.sub(/https*:\\/\\/[^\\/]*/, '') # Eliminate http[s]:// and beyond to first slash\nend","def unify_path(s)\r\n p = s.frozen? ? s.dup : s\r\n p.gsub!( /\\\\/, '/' )\r\n p = \"#{$1.upcase}/#{$POSTMATCH}\" if p =~ REGEX_DISK\r\n if RUBY_PLATFORM =~ REGEX_CYGWIN\r\n\tif p =~ REGEX_CYGDRIVE\r\n\t p = \"/cygdrive/#{$1.upcase}/#{$POSTMATCH}\" \r\n\telse\r\n\t p.sub!( REGEX_DISK2, '/cygdrive/\\1/' ) if @name == 'PATH'\r\n\tend\r\n end\r\n return p\r\n end","def path\r\n url.gsub(/https?:\\/\\/[^\\/]+\\//i, '').scan(/([^&]+)/i).first().first()\r\n end","def cleanpath\n names = []\n split('/').each do |name|\n case name\n when '..'\n names.pop\n when '.'\n when ''\n else\n names.push name\n end\n end\n names.join('/')\n end","def normalize_uri(uri)\n (uri =~ /^(https?|ftp|file):/) ? uri : \"http://#{uri}\"\n end","def base_uri\n ary = contents_uri.to_s.split(\"/\")\n ary.pop if ary[-1].blank?\n ary.pop\n ary.join(\"/\") + \"/\"\n end","def web_path\n # 47 char is \"/\"\n return path[0] == 47 ? path : \"/\" + path\n end","def relative_path(path)\n # replace array referenced IN the path\n first_pass = path.gsub(/\\/([^\\/]+)\\[\\d+\\]\\//i,\"/*/\")\n # replace array references AT THE END of the path too\n first_pass.gsub(/\\/([^\\/]+)\\[\\d+\\]$/,\"/*\")\n end","def split_path; end","def path_comps path\n path.nil? || path.empty? ? [] : path[1..(path[-1] == \"/\" ? -2 : -1)].split('/')\n end","def expand_path(href)\n return href if href.match(/^https*:\\/\\//) # if starts with protocol complete link\n return @request_href unless href.match(/[a-zA-Z0-9]+/) # rejects href=\"#\" and allows non-unique exception handling.\n return @request_href if href.match(/#[a-zA-Z0-9]*$/)\n\n if href[0, 1] != \"/\"\n return @request_href + href if @request_href[-1, 1] == \"/\"\n return @request_href + \"/\" + href\n else\n # relative path from domain.\n base_url = @request_href.match(BASEURLREG).to_a.first\n return base_url + href unless base_url[-1, 1] == \"/\"\n return base_url.chop + href\n end\n end","def slashless_url(url)\n url.chomp('/')\n end","def clean_path(directory)\n directory.gsub(/\\/\\//, '/')\n end","def relative_path(path)\n path.split('/').drop(5).join('/')\nend","def simplify_path(str)\n directory_names = str.split('/')\n stack = Stack.new\n\n directory_names.each do |name|\n next if name == '.' || name.empty?\n next stack.pop if name == '..'\n stack.push(\"/#{name}\")\n end\n\n result = ''\n until stack.empty?\n result.prepend(stack.pop || '')\n end\n result == '' ? '/' : result\nend","def full_url(url, path)\n if path.start_with?('http')\n path\n else\n url = url[0..1] if url.end_with?('/')\n path = path[1..-1] if path.start_with?('/')\n \"#{url}/#{path}\"\n end\n end","def test_valid_unc_uris\n [\n ['file:////example.com/Share/dir/file.ext', '//example.com/Share/dir/file.ext', '\\\\\\\\example.com\\\\Share\\\\dir\\\\file.ext'],\n ['file://///example.com/Share/dir/file.ext', '//example.com/Share/dir/file.ext', '\\\\\\\\example.com\\\\Share\\\\dir\\\\file.ext'],\n\n ['file:////localhost/Share/dir/file.ext', '//localhost/Share/dir/file.ext', '\\\\\\\\localhost\\\\Share\\\\dir\\\\file.ext'],\n ['file://///localhost/Share/dir/file.ext', '//localhost/Share/dir/file.ext', '\\\\\\\\localhost\\\\Share\\\\dir\\\\file.ext'],\n ].each do |str, path, unc|\n uri = URI.parse(str)\n assert_kind_of( URI::FileCommon, uri )\n assert_equal( path, uri.path )\n\n assert_equal( false, uri.local?(localhost: false) )\n assert_equal( false, uri.local?(localhost: true) )\n assert_equal( false, uri.local? )\n assert_equal( false, uri.local?(localhost: :any) )\n\n assert_raise(RuntimeError) { uri.to_file_path(localhost: false) }\n assert_raise(RuntimeError) { uri.to_file_path(localhost: true) }\n assert_raise(RuntimeError) { uri.to_file_path }\n assert_raise(RuntimeError) { uri.to_file_path(localhost: :any) }\n\n assert_equal( unc, uri.to_unc(localhost: false) )\n assert_equal( unc, uri.to_unc(localhost: true) )\n assert_equal( unc, uri.to_unc )\n assert_equal( unc, uri.to_unc(localhost: :any) )\n end\n end","def sanitize_path(path)\n # joining (e.g. `foo + \"/\" + bar`)\n path = path.gsub(%r{^/+}, \"/\")\n\n # remove leading and trailing slash\n path.sub(%r{^/}, \"\").sub(%r{/$}, \"\")\n end","def get_path(fullpath = \"\")\n (fullpath || \"\").scan(/^[\\w+|\\/]+/)[0]\n end","def normalize_path(path)\n raise if !path.instance_of?(String)\n\n path = path.strip\n if path.size == 0\n path = \"/\"\n end\n if path[0] != \"/\"\n path = \"/\" + path\n end\n return path\n end","def uri_join(*paths)\n return nil if paths.length == 0\n leadingslash = paths[0][0] == '/' ? '/' : ''\n trailingslash = paths[-1][-1] == '/' ? '/' : ''\n paths.map! { |path| path.sub(/^\\/+/, '').sub(/\\/+$/, '') }\n leadingslash + paths.join('/') + trailingslash\n end","def resolve_path(path, kv)\n validate_instance_of(:kv, kv, Hash)\n resolved = []\n # When splitting path, preserve the trailing slash (hence, -1)\n path.split('/', -1).each do |part|\n resolved_part = (part =~ /^:/) ? CGI.escape(kv[part.sub(/^:/, '')].to_s) : part\n if (part != \"\" and resolved_part == \"\")\n raise UriError.new(\"Cannot resolve #{part} in path #{path} from #{kv.inspect}\")\n end\n resolved << resolved_part\n end\n resolved.join('/')\n end","def sanitize_path(path)\n # joining (e.g. `foo + \"/\" + bar`)\n path = path.gsub(/^\\/+/, '/')\n\n # remove leading and trailing slash\n return path.sub(/^\\//, '').sub(/\\/$/, '')\n end","def simplify_path(path)\n path_tokens = path.split(\"/\").reject{ |x| x.empty? || x == \".\" }\n stack = []\n path_tokens.each{ |x|\n if x == \"..\"\n stack.pop if stack.any?\n else\n stack.push(x)\n end\n }\n\n \"/\" << stack.join(\"/\")\nend","def expandPath(url)\n stack = []\n urlTokens = url.split '/'\n while urlTokens.count > 0\n token = urlTokens.shift\n next if token == '.'\n if token == '..'\n puts 'error: invalid path' and return if stack.count == 0\n stack.pop\n else\n stack.push token\n end\n end\n stack.join('/')\nend","def parse_path(path_chunks)\n path = path_chunks[1]\n subpath_chunks = path.split(\"/\")\n base_dir = subpath_chunks[1]\n remaining_path = subpath_chunks[2..-1].join(\"/\")\n [base_dir, remaining_path]\n end","def calculate_uri(uri)\n if uri[0] != '/' && uri.index('://') && uri.index('://') > 0\n uri = ::URI.split(uri)[5] # path component of uri\n end\n\n uri = Uri.normalize(uri.gsub('//', '/'))\n base_uri = Uri.normalize(self.base_uri)\n\n if uri.index(base_uri) == 0\n return Http::UrlUtil.decode_path(uri[base_uri.length..-1]).gsub(%r{^/+}, '').gsub(%r{/+$}, '')\n\n elsif \"#{uri}/\" == base_uri\n # A special case, if the baseUri was accessed without a trailing\n # slash, we'll accept it as well.\n return ''\n else\n fail Exception::Forbidden, \"Requested uri (#{uri}) is out of base uri (#{self.base_uri})\"\n end\n end","def full_path_for(path)\n path = \"/#{path}\" unless path[0..0] == '/'\n path\n end","def process_uri(uri)\n ret = uri\n\n require 'open-uri'\n require 'open_uri_redirections'\n begin\n open(uri, :allow_redirections => :safe) do |r|\n ret = r.base_uri.to_s\n end\n end\n\n ret\n end","def normalized_path\n if normalized_scheme == \"urn\"\n # Special-case URI. Normalize the NID component only\n nid, p = path.to_s.split(':', 2)\n return \"#{nid.downcase}:#{p}\"\n end\n\n segments = path.to_s.split('/', -1) # preserve null segments\n\n norm_segs = case\n when authority\n # ipath-abempty\n segments.map {|s| normalize_segment(s, ENCODE_ISEGMENT)}\n when segments[0].nil?\n # ipath-absolute\n res = [nil]\n res << normalize_segment(segments[1], ENCODE_ISEGMENT) if segments.length > 1\n res += segments[2..-1].map {|s| normalize_segment(s, ENCODE_ISEGMENT)} if segments.length > 2\n res\n when segments[0].to_s.index(':')\n # ipath-noscheme\n res = []\n res << normalize_segment(segments[0], ENCODE_ISEGMENT_NC)\n res += segments[1..-1].map {|s| normalize_segment(s, ENCODE_ISEGMENT)} if segments.length > 1\n res\n when segments[0]\n # ipath-rootless\n # ipath-noscheme\n res = []\n res << normalize_segment(segments[0], ENCODE_ISEGMENT)\n res += segments[1..-1].map {|s| normalize_segment(s, ENCODE_ISEGMENT)} if segments.length > 1\n res\n else\n # Should be empty\n segments\n end\n\n res = self.class.normalize_path(norm_segs.join(\"/\"))\n # Special rules for specific protocols having empty paths\n (res.empty? && %w(http https ftp tftp).include?(normalized_scheme)) ? '/' : res\n end","def simplify_path(path)\n stack = []\n result = ''\n\n path.split('/').each do |dir|\n if dir == '' || dir == '.'\n next\n elsif dir == '..'\n stack.pop()\n else\n stack.push(dir)\n end\n end\n\n while stack.length > 0\n result = '/' + stack.pop() + result\n end\n\n return '/' if result == ''\n\n result\nend","def normalize_uri uri\n (uri =~ /^https?:/) ? uri : \"http://#{uri}\"\n end","def cleanup_paths(*paths)\n #.gsub(%r{#{@locations[:root]}/#{@locations[:root]}}, @locations[:root])\n paths.join('/').gsub(/[\\/]{2,}/,'/')\n end","def parse_uri(path, env)\n uri = URI.parse(path)\n uri.path = \"/#{uri.path}\" unless uri.path.start_with?('/')\n uri.host ||= @default_host\n uri.scheme ||= 'https' if env['HTTPS'] == 'on'\n uri\n end","def request_uri(uri)\n if has_colon_path_separator?(uri)\n path = hostname_and_path(uri).split(':').all_but_first.join('/')\n else\n path = hostname_and_path(uri).split('/').all_but_first.join('/')\n path.blank? ? nil : '/' + path\n end\n end","def relative_path_from(from); end","def mangle(path)\n path.gsub(%r{^file://}, '')\n end","def uri_join(*parts)\n parts = parts.compact.map(&URI.method(:escape))\n URI.parse(parts.join('/')).normalize.to_s\nend","def normalize_url(url)\n\t\tbegin\n\t\t\turl.strip!\n\t\t\t# Converting the scheme and host to lower case in the process, i.e. 'HTTP://www.Example.com/' => 'http://www.example.com/' \n\t\t\t# Normalize the base\n\t\t\tbase=url_2_site(url) \n\t\t\t# Case#1, remove the trailing dot after the hostname, i.e, 'http://www.yahoo.com./' => 'http://www.yahoo.com/'\n\t\t\tbase=base.sub(/\\.\\/$/,'/')\n\t\t\t# Normalize the relative path, case#1\n\t\t\t# retrieve the file path and remove the first '/' or '.', \n\t\t\t# i.e. 'http://www.example.com/mypath' or 'http://www.example.com/./mypath' => 'mypath'\n\t\t\tpath=url_2_path(url).sub(/^(\\/|\\.)*/,'')\n\t\t\t# Normalize the relative path, case#2\n\t\t\t# Replace dot-segments. \"/../\" and \"/./\" with \"/\", i.e. 'http://www.example.com/../a/b/../c/./d.html\" => 'http://www.example.com/a/c/d.html'\n\t\t\tpath=path.gsub(/\\/\\.{1,2}\\//,'/')\n\t\t\tif path.nil?\n\t\t\t\treturn base\n\t\t\telse\n\t\t\t\treturn base+path\n\t\t\tend\n\t\trescue => ee\n\t\t\tputs \"Exception on method #{__method__} for #{url}: #{ee}\" if @verbose\n\t\t\treturn url\n\t\tend\n\tend","def normalize_path(path)\n return '' if path.eql? '<>'\n path =~ PATH\n $~[1].to_s.downcase + normalize_local_part($~[9]) + \"@\" + $~[12].downcase\n end","def normalize_uri\n if @uri.start_with? '/api/'\n return @uri\n else\n return \"/api/#{@uri}\"\n end\n end","def uniPath(source)\n source.gsub(/\\\\/, File::SEPARATOR)\nend","def resolve_path(path, reference)\n # Absolute URL\n if path =~ %r{^(/|[a-z]+:)}\n if @options[:document_root].nil?\n msg = \"Cannot resolve absolute path '#{path}' without document root option\"\n raise ArgumentError.new(msg)\n end\n\n path.sub!(%r{^[a-z]+://[^/]+/}, '')\n return File.expand_path(File.join(@options[:document_root], path))\n end\n\n File.expand_path(File.join(File.dirname(reference), path))\n end","def docpath(uri)\n return File.join(DOCUMENT_ROOT, uri.gsub('/', File::SEPARATOR)).gsub(/#{File::SEPARATOR}$/, \"\")\n end","def clean_path(path)\n if path\n (path[0] != '/' ? path.insert(0, '/') : path).gsub(/\\/{2,}/, '/')\n end\n end","def extract_base_url(uri)\n root = uri.split(\"/\",4)\n root[0] + \"//\" + root[2]\n end","def join_paths(paths)\n paths.join('/').gsub(%r{/+}, '/')\n end","def normalise\n Wgit::Url.new(@uri.normalize.to_s)\n end","def normalize(path)\n path.gsub(/\\\\/, \"/\")\n end","def explicit_relative(path)\n # Paths that do not start with \"/\", \"./\", or \"../\" will be prefixed with ./\n path.sub(%r(^(?!\\.{0,2}/)), './')\n end","def sanitize_path(path)\n newpath = path.gsub(/\\/+/, '/')\n while newpath.gsub!(%r{([^/]+)/\\.\\./?}) { |match|\n $1 == '..' ? match : ''\n } do end\n newpath.gsub(%r{/\\./}, '/').sub(%r{/\\.\\z}, '/')\n end","def path(*elements) #Create a path from the elements\n#-------------------------------------------------------------------------------\n path=elements.join('/').strip #Remove leading and trailing whitespace\n while path.gsub!('//','/'); end #Remove duplicate slashes\n return path\nend","def _path uri, subject\n [uri.request_uri, subject].join\nend","def _path uri, subject\n [uri.request_uri, subject].join\nend"],"string":"[\n \"def uri(path)\\n s = File::expand_path(path).gsub(DIR, \\\"\\\").gsub(File::SEPARATOR, '/')\\n return s == '' ? '/' : s\\n end\",\n \"def normalize_path(url); end\",\n \"def normalize_path(url); end\",\n \"def normalize_uri(*strs)\\n new_str = strs * \\\"/\\\"\\n\\n new_str = new_str.gsub!(\\\"//\\\", \\\"/\\\") while new_str.index(\\\"//\\\")\\n\\n # Makes sure there's a starting slash\\n unless new_str[0,1] == '/'\\n new_str = '/' + new_str\\n end\\n\\n new_str\\n end\",\n \"def normalize_uri(*strs)\\n new_str = strs * '/'\\n new_str = new_str.gsub!('//', '/') while new_str.index('//')\\n new_str\\n end\",\n \"def fullpath(uri)\\n return File.join(DIR, uri.gsub('/', File::SEPARATOR))\\n end\",\n \"def humanish(uri)\\n uri.path.split('/').last.gsub('.git', '')\\n end\",\n \"def normalize_path(path); end\",\n \"def normalize_path(path); end\",\n \"def get_path(uri)\\n name = uri.gsub(\\\"http://\\\", \\\"\\\")\\n dir_list = name.split(\\\"/\\\")\\n return dir_list\\n end\",\n \"def uri_normalize(uri)\\n \\treturn 'http://' + uri unless uri =~ /http:\\\\/\\\\//\\n \\turi\\n\\tend\",\n \"def uri_normalize(uri)\\n \\treturn 'http://' + uri unless uri =~ /http:\\\\/\\\\//\\n \\turi\\n\\tend\",\n \"def host_and_path(uri)\\n uri = URI.parse(uri) unless uri.is_a? URI\\n host = uri.host\\n path = uri.path.gsub(/\\\\/$/, '')\\n path = path.empty? ? '/' : uri.path\\n URI.parse(\\\"#{host}#{path}\\\")\\n end\",\n \"def uri_path(str)\\n str.gsub(%r{[^/]+}n) { uri_segment($&) }\\n end\",\n \"def conform_uri(uri_string)\\n uri_string.gsub(/^(?!\\\\/)(.*)/, '/\\\\1').gsub(/[\\\\/]+$/, '')\\n end\",\n \"def path_without_name_and_ref(path); end\",\n \"def normalize_path(path)\\n path.sub(%r{^/}, '').tr('', '')\\n end\",\n \"def normalize_path(path)\\n path = \\\"/#{path}\\\"\\n path.squeeze!('/')\\n path.sub!(%r{/+\\\\Z}, '')\\n path = '/' if path == ''\\n path\\n end\",\n \"def url_for(str)\\n return str if str =~ /^[|[:alpha:]]+:\\\\/\\\\//\\n File.join((uri.path.empty?) ? uri.to_s : File.dirname(uri.to_s), str)\\n end\",\n \"def relativize_path(path)\\n path.to_s.gsub(/^\\\\/?#{Regexp.escape(root_path.to_s)}\\\\/?/, '')\\n end\",\n \"def normalize_url(path)\\n @known_pairs ||= {}\\n @public_directories_regex ||= Regexp.new(Bones.public_directories.join('|'))\\n \\n if v = @known_pairs[path]\\n return v\\n else\\n value = case\\n when path =~ /^(\\\\w{3,}:\\\\/\\\\/|mailto)/\\n # don't do anything to this type of URL\\n return path\\n when path =~ @public_directories_regex\\n path\\n when File.directory?('pages' / path)\\n path\\n else\\n # don't add .html if there's already an extension\\n path =~ /\\\\..+/ ? path : path + '.html'\\n end\\n \\n @known_pairs[path] = options.base / value\\n end \\n end\",\n \"def normalize_path(path)\\n path = \\\"/#{path}\\\"\\n path.squeeze!('/')\\n path.sub!(%r{/+\\\\Z}, '')\\n path = '/' if path == ''\\n path\\n end\",\n \"def remove_leading_slash(path); end\",\n \"def get_file_uri_path(uri)\\n uri.sub(%r{\\\\Afile://}, '')\\n end\",\n \"def unescape_path(path); end\",\n \"def file_uri_from_path(path)\\n path = path.to_s if path.is_a?(Pathname)\\n path = path.tr('\\\\\\\\', '/') if windows?\\n path = URI::DEFAULT_PARSER.escape(path)\\n return path.start_with?('/') ? \\\"file://\\\" + path : path unless windows?\\n return \\\"file:///\\\" + path.tr(\\\"\\\\\\\\\\\", \\\"/\\\") if path =~ %r{^[a-zA-Z]:[/\\\\\\\\]}\\n return \\\"file:\\\" + path.tr(\\\"\\\\\\\\\\\", \\\"/\\\") if path =~ %r{\\\\\\\\\\\\\\\\[^\\\\\\\\]+\\\\\\\\[^\\\\\\\\/]+}\\n path.tr(\\\"\\\\\\\\\\\", \\\"/\\\")\\n end\",\n \"def simplify_path(path)\\n return '' if path.empty?\\n\\n start_with_slash = path[0] == '/'\\n stack = []\\n stack << '' if start_with_slash\\n tokens = path.split('/')\\n tokens.each do |token|\\n case token\\n when '..'\\n stack.pop if stack[-1] != ''\\n\\n when '.', ''\\n next\\n else\\n stack.push token\\n end\\n end\\n\\n return '/' if stack.length == 1 && stack[0] == ''\\n\\n stack.join('/')\\nend\",\n \"def absolute_url_for(uri, str)\\n # TODO: use URI.parse() for better handling?\\n return str if str =~ /^[|[:alpha:]]+:\\\\/\\\\//\\n File.join(((uri.path.empty?) ? uri.to_s : File.dirname(uri.to_s)), \\n str)\\n end\",\n \"def extract_path(input)\\n input_s = input.to_s\\n if /^(\\\\w+):/.match(input_s)\\n input_s.gsub(/^\\\\w+:[^\\\\/]*\\\\/\\\\/[^\\\\/]+(\\\\/[^\\\\?]+)(?:\\\\?.*)?$/, '\\\\1')\\n else\\n input_s.gsub(/(?:\\\\?.*)$/, '')\\n end\\n end\",\n \"def reg_url2; /(.+)\\\\//; end\",\n \"def reg_url2; /(.+)\\\\//; end\",\n \"def normalize_paths(paths)\\n paths = [paths] unless paths.is_a?(Array)\\n paths.map(&:dup).map do |path|\\n raise ArgumentError.new(\\\"Invalid path: #{path}\\\") unless valid_path?(path)\\n # Strip leading slash from extension path\\n path.gsub!(/^\\\\/(?=\\\\*.)/, '')\\n # Escape some valid special characters\\n path.gsub!(/[.+$\\\"]/) {|s| '\\\\\\\\' + s}\\n # Replace * wildcards with .* regex fragment\\n path.gsub!(/\\\\*/, '.*')\\n \\\"^#{path}#{END_URL_REGEX}\\\"\\n end\\nend\",\n \"def get_file_uri_path(uri)\\n uri.sub(%r{\\\\Afile://}, '')\\n end\",\n \"def canonical_path\\n p = path.gsub(/\\\\/+/,'/')\\n p.length > 1 ? p.chomp('/') : p\\n end\",\n \"def extract_path(uri_or_path)\\n uri = URI(uri_or_path)\\n uri.kind_of?(URI::HTTP) ? uri.request_uri : uri_or_path\\n end\",\n \"def categorize_uri(str)\\n regex = /\\\\.+/ # really simple host regex to thwart unwanted strings\\n str = \\\"http://#{str}\\\" unless str.to_s =~ %r{\\\\Ahttps?://}\\n uri = URI.parse(str.to_s)\\n path = uri.path.chomp('/')\\n return :unknown if (uri.host =~ regex).nil?\\n\\n path.empty? ? :host : :url\\n rescue URI::InvalidURIError\\n :unknown\\n end\",\n \"def normalize_uri(uri)\\n (uri =~ /^(https?|ftp|file):/) ? uri : \\\"http://#{uri}\\\"\\n end\",\n \"def absolutize_url(url)\\n # file_path = File.expand_path(File.join(working_directory, url))\\n # full_path = File.expand_path(File.join(path, url))\\n # full_path.gsub(File.expand_path(path), '')\\n ('/' + url.split('./').last).gsub(%r(/+), '/')\\n end\",\n \"def normalized_request_path(path)\\n if path == \\\"/\\\"\\n path\\n else\\n path.chomp(\\\"/\\\")\\n end\\n end\",\n \"def fix_oneoff url\\n begin\\n uri = URI.parse url\\n return (\\\"\\\" == uri.path) ? url + '/' : url\\n rescue\\n #puts \\\"Ran into issue processing #{url}\\\"\\n end\\n end\",\n \"def uri_normalizer; end\",\n \"def normalize_req_path(req_path)\\n # 1) Decode the req_path with URI::decode\\n req_path = URI::decode(req_path)\\n # 2) Strip first\\n req_path = req_path.strip\\n # 3) Remove first slash \\n req_path = req_path[1..-1] if req_path[0,1]=='/'\\n # 4) Remove last slash\\n req_path = req_path[0..-2] if req_path[req_path.length-1,1]=='/'\\n req_path\\n end\",\n \"def expand_path( path )\\n File.expand_path( path.gsub( /^\\\\/+/, '' ), self.link.path.gsub( /\\\\/*$/, '/' ) ).gsub( /^C:/, '')\\n end\",\n \"def path_without_name_and_ref(path)\\n Jekyll.sanitized_path theme.root, path.split(\\\"/\\\").drop(1).join(\\\"/\\\")\\n end\",\n \"def merge_path(base, rel)\\n\\n # RFC2396, Section 5.2, 5)\\n # RFC2396, Section 5.2, 6)\\n base_path = split_path(base)\\n rel_path = split_path(rel)\\n\\n # RFC2396, Section 5.2, 6), a)\\n base_path << '' if base_path.last == '..'\\n while i = base_path.index('..')\\n base_path.slice!(i - 1, 2)\\n end\\n\\n if (first = rel_path.first) and first.empty?\\n base_path.clear\\n rel_path.shift\\n end\\n\\n # RFC2396, Section 5.2, 6), c)\\n # RFC2396, Section 5.2, 6), d)\\n rel_path.push('') if rel_path.last == '.' || rel_path.last == '..'\\n rel_path.delete('.')\\n\\n # RFC2396, Section 5.2, 6), e)\\n tmp = []\\n rel_path.each do |x|\\n if x == '..' &&\\n !(tmp.empty? || tmp.last == '..')\\n tmp.pop\\n else\\n tmp << x\\n end\\n end\\n\\n add_trailer_slash = !tmp.empty?\\n if base_path.empty?\\n base_path = [''] # keep '/' for root directory\\n elsif add_trailer_slash\\n base_path.pop\\n end\\n while x = tmp.shift\\n if x == '..'\\n # RFC2396, Section 4\\n # a .. or . in an absolute path has no special meaning\\n base_path.pop if base_path.size > 1\\n else\\n # if x == '..'\\n # valid absolute (but abnormal) path \\\"/../...\\\"\\n # else\\n # valid absolute path\\n # end\\n base_path << x\\n tmp.each {|t| base_path << t}\\n add_trailer_slash = false\\n break\\n end\\n end\\n base_path.push('') if add_trailer_slash\\n\\n return base_path.join('/')\\n end\",\n \"def path\\n return @path.sub(/^\\\\//,'').sub(/^%2F/,'/')\\n end\",\n \"def path_from_url(url)\\n\\tresult = url.sub(/https*:\\\\/\\\\/[^\\\\/]*/, '') # Eliminate http[s]:// and beyond to first slash\\nend\",\n \"def unify_path(s)\\r\\n p = s.frozen? ? s.dup : s\\r\\n p.gsub!( /\\\\\\\\/, '/' )\\r\\n p = \\\"#{$1.upcase}/#{$POSTMATCH}\\\" if p =~ REGEX_DISK\\r\\n if RUBY_PLATFORM =~ REGEX_CYGWIN\\r\\n\\tif p =~ REGEX_CYGDRIVE\\r\\n\\t p = \\\"/cygdrive/#{$1.upcase}/#{$POSTMATCH}\\\" \\r\\n\\telse\\r\\n\\t p.sub!( REGEX_DISK2, '/cygdrive/\\\\1/' ) if @name == 'PATH'\\r\\n\\tend\\r\\n end\\r\\n return p\\r\\n end\",\n \"def path\\r\\n url.gsub(/https?:\\\\/\\\\/[^\\\\/]+\\\\//i, '').scan(/([^&]+)/i).first().first()\\r\\n end\",\n \"def cleanpath\\n names = []\\n split('/').each do |name|\\n case name\\n when '..'\\n names.pop\\n when '.'\\n when ''\\n else\\n names.push name\\n end\\n end\\n names.join('/')\\n end\",\n \"def normalize_uri(uri)\\n (uri =~ /^(https?|ftp|file):/) ? uri : \\\"http://#{uri}\\\"\\n end\",\n \"def base_uri\\n ary = contents_uri.to_s.split(\\\"/\\\")\\n ary.pop if ary[-1].blank?\\n ary.pop\\n ary.join(\\\"/\\\") + \\\"/\\\"\\n end\",\n \"def web_path\\n # 47 char is \\\"/\\\"\\n return path[0] == 47 ? path : \\\"/\\\" + path\\n end\",\n \"def relative_path(path)\\n # replace array referenced IN the path\\n first_pass = path.gsub(/\\\\/([^\\\\/]+)\\\\[\\\\d+\\\\]\\\\//i,\\\"/*/\\\")\\n # replace array references AT THE END of the path too\\n first_pass.gsub(/\\\\/([^\\\\/]+)\\\\[\\\\d+\\\\]$/,\\\"/*\\\")\\n end\",\n \"def split_path; end\",\n \"def path_comps path\\n path.nil? || path.empty? ? [] : path[1..(path[-1] == \\\"/\\\" ? -2 : -1)].split('/')\\n end\",\n \"def expand_path(href)\\n return href if href.match(/^https*:\\\\/\\\\//) # if starts with protocol complete link\\n return @request_href unless href.match(/[a-zA-Z0-9]+/) # rejects href=\\\"#\\\" and allows non-unique exception handling.\\n return @request_href if href.match(/#[a-zA-Z0-9]*$/)\\n\\n if href[0, 1] != \\\"/\\\"\\n return @request_href + href if @request_href[-1, 1] == \\\"/\\\"\\n return @request_href + \\\"/\\\" + href\\n else\\n # relative path from domain.\\n base_url = @request_href.match(BASEURLREG).to_a.first\\n return base_url + href unless base_url[-1, 1] == \\\"/\\\"\\n return base_url.chop + href\\n end\\n end\",\n \"def slashless_url(url)\\n url.chomp('/')\\n end\",\n \"def clean_path(directory)\\n directory.gsub(/\\\\/\\\\//, '/')\\n end\",\n \"def relative_path(path)\\n path.split('/').drop(5).join('/')\\nend\",\n \"def simplify_path(str)\\n directory_names = str.split('/')\\n stack = Stack.new\\n\\n directory_names.each do |name|\\n next if name == '.' || name.empty?\\n next stack.pop if name == '..'\\n stack.push(\\\"/#{name}\\\")\\n end\\n\\n result = ''\\n until stack.empty?\\n result.prepend(stack.pop || '')\\n end\\n result == '' ? '/' : result\\nend\",\n \"def full_url(url, path)\\n if path.start_with?('http')\\n path\\n else\\n url = url[0..1] if url.end_with?('/')\\n path = path[1..-1] if path.start_with?('/')\\n \\\"#{url}/#{path}\\\"\\n end\\n end\",\n \"def test_valid_unc_uris\\n [\\n ['file:////example.com/Share/dir/file.ext', '//example.com/Share/dir/file.ext', '\\\\\\\\\\\\\\\\example.com\\\\\\\\Share\\\\\\\\dir\\\\\\\\file.ext'],\\n ['file://///example.com/Share/dir/file.ext', '//example.com/Share/dir/file.ext', '\\\\\\\\\\\\\\\\example.com\\\\\\\\Share\\\\\\\\dir\\\\\\\\file.ext'],\\n\\n ['file:////localhost/Share/dir/file.ext', '//localhost/Share/dir/file.ext', '\\\\\\\\\\\\\\\\localhost\\\\\\\\Share\\\\\\\\dir\\\\\\\\file.ext'],\\n ['file://///localhost/Share/dir/file.ext', '//localhost/Share/dir/file.ext', '\\\\\\\\\\\\\\\\localhost\\\\\\\\Share\\\\\\\\dir\\\\\\\\file.ext'],\\n ].each do |str, path, unc|\\n uri = URI.parse(str)\\n assert_kind_of( URI::FileCommon, uri )\\n assert_equal( path, uri.path )\\n\\n assert_equal( false, uri.local?(localhost: false) )\\n assert_equal( false, uri.local?(localhost: true) )\\n assert_equal( false, uri.local? )\\n assert_equal( false, uri.local?(localhost: :any) )\\n\\n assert_raise(RuntimeError) { uri.to_file_path(localhost: false) }\\n assert_raise(RuntimeError) { uri.to_file_path(localhost: true) }\\n assert_raise(RuntimeError) { uri.to_file_path }\\n assert_raise(RuntimeError) { uri.to_file_path(localhost: :any) }\\n\\n assert_equal( unc, uri.to_unc(localhost: false) )\\n assert_equal( unc, uri.to_unc(localhost: true) )\\n assert_equal( unc, uri.to_unc )\\n assert_equal( unc, uri.to_unc(localhost: :any) )\\n end\\n end\",\n \"def sanitize_path(path)\\n # joining (e.g. `foo + \\\"/\\\" + bar`)\\n path = path.gsub(%r{^/+}, \\\"/\\\")\\n\\n # remove leading and trailing slash\\n path.sub(%r{^/}, \\\"\\\").sub(%r{/$}, \\\"\\\")\\n end\",\n \"def get_path(fullpath = \\\"\\\")\\n (fullpath || \\\"\\\").scan(/^[\\\\w+|\\\\/]+/)[0]\\n end\",\n \"def normalize_path(path)\\n raise if !path.instance_of?(String)\\n\\n path = path.strip\\n if path.size == 0\\n path = \\\"/\\\"\\n end\\n if path[0] != \\\"/\\\"\\n path = \\\"/\\\" + path\\n end\\n return path\\n end\",\n \"def uri_join(*paths)\\n return nil if paths.length == 0\\n leadingslash = paths[0][0] == '/' ? '/' : ''\\n trailingslash = paths[-1][-1] == '/' ? '/' : ''\\n paths.map! { |path| path.sub(/^\\\\/+/, '').sub(/\\\\/+$/, '') }\\n leadingslash + paths.join('/') + trailingslash\\n end\",\n \"def resolve_path(path, kv)\\n validate_instance_of(:kv, kv, Hash)\\n resolved = []\\n # When splitting path, preserve the trailing slash (hence, -1)\\n path.split('/', -1).each do |part|\\n resolved_part = (part =~ /^:/) ? CGI.escape(kv[part.sub(/^:/, '')].to_s) : part\\n if (part != \\\"\\\" and resolved_part == \\\"\\\")\\n raise UriError.new(\\\"Cannot resolve #{part} in path #{path} from #{kv.inspect}\\\")\\n end\\n resolved << resolved_part\\n end\\n resolved.join('/')\\n end\",\n \"def sanitize_path(path)\\n # joining (e.g. `foo + \\\"/\\\" + bar`)\\n path = path.gsub(/^\\\\/+/, '/')\\n\\n # remove leading and trailing slash\\n return path.sub(/^\\\\//, '').sub(/\\\\/$/, '')\\n end\",\n \"def simplify_path(path)\\n path_tokens = path.split(\\\"/\\\").reject{ |x| x.empty? || x == \\\".\\\" }\\n stack = []\\n path_tokens.each{ |x|\\n if x == \\\"..\\\"\\n stack.pop if stack.any?\\n else\\n stack.push(x)\\n end\\n }\\n\\n \\\"/\\\" << stack.join(\\\"/\\\")\\nend\",\n \"def expandPath(url)\\n stack = []\\n urlTokens = url.split '/'\\n while urlTokens.count > 0\\n token = urlTokens.shift\\n next if token == '.'\\n if token == '..'\\n puts 'error: invalid path' and return if stack.count == 0\\n stack.pop\\n else\\n stack.push token\\n end\\n end\\n stack.join('/')\\nend\",\n \"def parse_path(path_chunks)\\n path = path_chunks[1]\\n subpath_chunks = path.split(\\\"/\\\")\\n base_dir = subpath_chunks[1]\\n remaining_path = subpath_chunks[2..-1].join(\\\"/\\\")\\n [base_dir, remaining_path]\\n end\",\n \"def calculate_uri(uri)\\n if uri[0] != '/' && uri.index('://') && uri.index('://') > 0\\n uri = ::URI.split(uri)[5] # path component of uri\\n end\\n\\n uri = Uri.normalize(uri.gsub('//', '/'))\\n base_uri = Uri.normalize(self.base_uri)\\n\\n if uri.index(base_uri) == 0\\n return Http::UrlUtil.decode_path(uri[base_uri.length..-1]).gsub(%r{^/+}, '').gsub(%r{/+$}, '')\\n\\n elsif \\\"#{uri}/\\\" == base_uri\\n # A special case, if the baseUri was accessed without a trailing\\n # slash, we'll accept it as well.\\n return ''\\n else\\n fail Exception::Forbidden, \\\"Requested uri (#{uri}) is out of base uri (#{self.base_uri})\\\"\\n end\\n end\",\n \"def full_path_for(path)\\n path = \\\"/#{path}\\\" unless path[0..0] == '/'\\n path\\n end\",\n \"def process_uri(uri)\\n ret = uri\\n\\n require 'open-uri'\\n require 'open_uri_redirections'\\n begin\\n open(uri, :allow_redirections => :safe) do |r|\\n ret = r.base_uri.to_s\\n end\\n end\\n\\n ret\\n end\",\n \"def normalized_path\\n if normalized_scheme == \\\"urn\\\"\\n # Special-case URI. Normalize the NID component only\\n nid, p = path.to_s.split(':', 2)\\n return \\\"#{nid.downcase}:#{p}\\\"\\n end\\n\\n segments = path.to_s.split('/', -1) # preserve null segments\\n\\n norm_segs = case\\n when authority\\n # ipath-abempty\\n segments.map {|s| normalize_segment(s, ENCODE_ISEGMENT)}\\n when segments[0].nil?\\n # ipath-absolute\\n res = [nil]\\n res << normalize_segment(segments[1], ENCODE_ISEGMENT) if segments.length > 1\\n res += segments[2..-1].map {|s| normalize_segment(s, ENCODE_ISEGMENT)} if segments.length > 2\\n res\\n when segments[0].to_s.index(':')\\n # ipath-noscheme\\n res = []\\n res << normalize_segment(segments[0], ENCODE_ISEGMENT_NC)\\n res += segments[1..-1].map {|s| normalize_segment(s, ENCODE_ISEGMENT)} if segments.length > 1\\n res\\n when segments[0]\\n # ipath-rootless\\n # ipath-noscheme\\n res = []\\n res << normalize_segment(segments[0], ENCODE_ISEGMENT)\\n res += segments[1..-1].map {|s| normalize_segment(s, ENCODE_ISEGMENT)} if segments.length > 1\\n res\\n else\\n # Should be empty\\n segments\\n end\\n\\n res = self.class.normalize_path(norm_segs.join(\\\"/\\\"))\\n # Special rules for specific protocols having empty paths\\n (res.empty? && %w(http https ftp tftp).include?(normalized_scheme)) ? '/' : res\\n end\",\n \"def simplify_path(path)\\n stack = []\\n result = ''\\n\\n path.split('/').each do |dir|\\n if dir == '' || dir == '.'\\n next\\n elsif dir == '..'\\n stack.pop()\\n else\\n stack.push(dir)\\n end\\n end\\n\\n while stack.length > 0\\n result = '/' + stack.pop() + result\\n end\\n\\n return '/' if result == ''\\n\\n result\\nend\",\n \"def normalize_uri uri\\n (uri =~ /^https?:/) ? uri : \\\"http://#{uri}\\\"\\n end\",\n \"def cleanup_paths(*paths)\\n #.gsub(%r{#{@locations[:root]}/#{@locations[:root]}}, @locations[:root])\\n paths.join('/').gsub(/[\\\\/]{2,}/,'/')\\n end\",\n \"def parse_uri(path, env)\\n uri = URI.parse(path)\\n uri.path = \\\"/#{uri.path}\\\" unless uri.path.start_with?('/')\\n uri.host ||= @default_host\\n uri.scheme ||= 'https' if env['HTTPS'] == 'on'\\n uri\\n end\",\n \"def request_uri(uri)\\n if has_colon_path_separator?(uri)\\n path = hostname_and_path(uri).split(':').all_but_first.join('/')\\n else\\n path = hostname_and_path(uri).split('/').all_but_first.join('/')\\n path.blank? ? nil : '/' + path\\n end\\n end\",\n \"def relative_path_from(from); end\",\n \"def mangle(path)\\n path.gsub(%r{^file://}, '')\\n end\",\n \"def uri_join(*parts)\\n parts = parts.compact.map(&URI.method(:escape))\\n URI.parse(parts.join('/')).normalize.to_s\\nend\",\n \"def normalize_url(url)\\n\\t\\tbegin\\n\\t\\t\\turl.strip!\\n\\t\\t\\t# Converting the scheme and host to lower case in the process, i.e. 'HTTP://www.Example.com/' => 'http://www.example.com/' \\n\\t\\t\\t# Normalize the base\\n\\t\\t\\tbase=url_2_site(url) \\n\\t\\t\\t# Case#1, remove the trailing dot after the hostname, i.e, 'http://www.yahoo.com./' => 'http://www.yahoo.com/'\\n\\t\\t\\tbase=base.sub(/\\\\.\\\\/$/,'/')\\n\\t\\t\\t# Normalize the relative path, case#1\\n\\t\\t\\t# retrieve the file path and remove the first '/' or '.', \\n\\t\\t\\t# i.e. 'http://www.example.com/mypath' or 'http://www.example.com/./mypath' => 'mypath'\\n\\t\\t\\tpath=url_2_path(url).sub(/^(\\\\/|\\\\.)*/,'')\\n\\t\\t\\t# Normalize the relative path, case#2\\n\\t\\t\\t# Replace dot-segments. \\\"/../\\\" and \\\"/./\\\" with \\\"/\\\", i.e. 'http://www.example.com/../a/b/../c/./d.html\\\" => 'http://www.example.com/a/c/d.html'\\n\\t\\t\\tpath=path.gsub(/\\\\/\\\\.{1,2}\\\\//,'/')\\n\\t\\t\\tif path.nil?\\n\\t\\t\\t\\treturn base\\n\\t\\t\\telse\\n\\t\\t\\t\\treturn base+path\\n\\t\\t\\tend\\n\\t\\trescue => ee\\n\\t\\t\\tputs \\\"Exception on method #{__method__} for #{url}: #{ee}\\\" if @verbose\\n\\t\\t\\treturn url\\n\\t\\tend\\n\\tend\",\n \"def normalize_path(path)\\n return '' if path.eql? '<>'\\n path =~ PATH\\n $~[1].to_s.downcase + normalize_local_part($~[9]) + \\\"@\\\" + $~[12].downcase\\n end\",\n \"def normalize_uri\\n if @uri.start_with? '/api/'\\n return @uri\\n else\\n return \\\"/api/#{@uri}\\\"\\n end\\n end\",\n \"def uniPath(source)\\n source.gsub(/\\\\\\\\/, File::SEPARATOR)\\nend\",\n \"def resolve_path(path, reference)\\n # Absolute URL\\n if path =~ %r{^(/|[a-z]+:)}\\n if @options[:document_root].nil?\\n msg = \\\"Cannot resolve absolute path '#{path}' without document root option\\\"\\n raise ArgumentError.new(msg)\\n end\\n\\n path.sub!(%r{^[a-z]+://[^/]+/}, '')\\n return File.expand_path(File.join(@options[:document_root], path))\\n end\\n\\n File.expand_path(File.join(File.dirname(reference), path))\\n end\",\n \"def docpath(uri)\\n return File.join(DOCUMENT_ROOT, uri.gsub('/', File::SEPARATOR)).gsub(/#{File::SEPARATOR}$/, \\\"\\\")\\n end\",\n \"def clean_path(path)\\n if path\\n (path[0] != '/' ? path.insert(0, '/') : path).gsub(/\\\\/{2,}/, '/')\\n end\\n end\",\n \"def extract_base_url(uri)\\n root = uri.split(\\\"/\\\",4)\\n root[0] + \\\"//\\\" + root[2]\\n end\",\n \"def join_paths(paths)\\n paths.join('/').gsub(%r{/+}, '/')\\n end\",\n \"def normalise\\n Wgit::Url.new(@uri.normalize.to_s)\\n end\",\n \"def normalize(path)\\n path.gsub(/\\\\\\\\/, \\\"/\\\")\\n end\",\n \"def explicit_relative(path)\\n # Paths that do not start with \\\"/\\\", \\\"./\\\", or \\\"../\\\" will be prefixed with ./\\n path.sub(%r(^(?!\\\\.{0,2}/)), './')\\n end\",\n \"def sanitize_path(path)\\n newpath = path.gsub(/\\\\/+/, '/')\\n while newpath.gsub!(%r{([^/]+)/\\\\.\\\\./?}) { |match|\\n $1 == '..' ? match : ''\\n } do end\\n newpath.gsub(%r{/\\\\./}, '/').sub(%r{/\\\\.\\\\z}, '/')\\n end\",\n \"def path(*elements) #Create a path from the elements\\n#-------------------------------------------------------------------------------\\n path=elements.join('/').strip #Remove leading and trailing whitespace\\n while path.gsub!('//','/'); end #Remove duplicate slashes\\n return path\\nend\",\n \"def _path uri, subject\\n [uri.request_uri, subject].join\\nend\",\n \"def _path uri, subject\\n [uri.request_uri, subject].join\\nend\"\n]"},"negative_scores":{"kind":"list like","value":["0.7050252","0.6911172","0.6911172","0.68011254","0.677133","0.67306715","0.6601699","0.65985906","0.65985906","0.6590226","0.6532023","0.6532023","0.6453584","0.64493656","0.6447845","0.6432042","0.64209706","0.63909125","0.6367975","0.6360824","0.63547516","0.6311897","0.62633437","0.6253081","0.6232644","0.6210744","0.6206922","0.62049615","0.6193031","0.6192998","0.6192998","0.6184197","0.61765987","0.61727124","0.61599076","0.61551064","0.6147042","0.614586","0.6145034","0.6138849","0.6135322","0.6131658","0.61246216","0.61233795","0.6122461","0.6116173","0.6107772","0.61050206","0.6104812","0.6100698","0.60952914","0.60903573","0.60902923","0.6079893","0.60760385","0.60732585","0.60728264","0.6064845","0.6058977","0.6049219","0.6047439","0.60395646","0.6034426","0.6031565","0.602998","0.60273427","0.6004898","0.60021174","0.5996779","0.5990189","0.597308","0.59695256","0.5963107","0.5958175","0.59575796","0.59541315","0.59530765","0.5935505","0.5932014","0.5929433","0.5917734","0.5912727","0.59100026","0.59095937","0.59092087","0.590905","0.59062284","0.58928114","0.58899295","0.58888113","0.588613","0.586213","0.5856596","0.5836977","0.58368","0.58305895","0.58281237","0.58261234","0.58239794","0.58239794"],"string":"[\n \"0.7050252\",\n \"0.6911172\",\n \"0.6911172\",\n \"0.68011254\",\n \"0.677133\",\n \"0.67306715\",\n \"0.6601699\",\n \"0.65985906\",\n \"0.65985906\",\n \"0.6590226\",\n \"0.6532023\",\n \"0.6532023\",\n \"0.6453584\",\n \"0.64493656\",\n \"0.6447845\",\n \"0.6432042\",\n \"0.64209706\",\n \"0.63909125\",\n \"0.6367975\",\n \"0.6360824\",\n \"0.63547516\",\n \"0.6311897\",\n \"0.62633437\",\n \"0.6253081\",\n \"0.6232644\",\n \"0.6210744\",\n \"0.6206922\",\n \"0.62049615\",\n \"0.6193031\",\n \"0.6192998\",\n \"0.6192998\",\n \"0.6184197\",\n \"0.61765987\",\n \"0.61727124\",\n \"0.61599076\",\n \"0.61551064\",\n \"0.6147042\",\n \"0.614586\",\n \"0.6145034\",\n \"0.6138849\",\n \"0.6135322\",\n \"0.6131658\",\n \"0.61246216\",\n \"0.61233795\",\n \"0.6122461\",\n \"0.6116173\",\n \"0.6107772\",\n \"0.61050206\",\n \"0.6104812\",\n \"0.6100698\",\n \"0.60952914\",\n \"0.60903573\",\n \"0.60902923\",\n \"0.6079893\",\n \"0.60760385\",\n \"0.60732585\",\n \"0.60728264\",\n \"0.6064845\",\n \"0.6058977\",\n \"0.6049219\",\n \"0.6047439\",\n \"0.60395646\",\n \"0.6034426\",\n \"0.6031565\",\n \"0.602998\",\n \"0.60273427\",\n \"0.6004898\",\n \"0.60021174\",\n \"0.5996779\",\n \"0.5990189\",\n \"0.597308\",\n \"0.59695256\",\n \"0.5963107\",\n \"0.5958175\",\n \"0.59575796\",\n \"0.59541315\",\n \"0.59530765\",\n \"0.5935505\",\n \"0.5932014\",\n \"0.5929433\",\n \"0.5917734\",\n \"0.5912727\",\n \"0.59100026\",\n \"0.59095937\",\n \"0.59092087\",\n \"0.590905\",\n \"0.59062284\",\n \"0.58928114\",\n \"0.58899295\",\n \"0.58888113\",\n \"0.588613\",\n \"0.586213\",\n \"0.5856596\",\n \"0.5836977\",\n \"0.58368\",\n \"0.58305895\",\n \"0.58281237\",\n \"0.58261234\",\n \"0.58239794\",\n \"0.58239794\"\n]"},"document_score":{"kind":"string","value":"0.7364567"},"document_rank":{"kind":"string","value":"0"}}},{"rowIdx":1881,"cells":{"query":{"kind":"string","value":"add a link to be processed"},"document":{"kind":"string","value":"def add_uri(new_link, from = nil, recurse = true)\n return if not new_link\n\n uri = (new_link.class == LinkToLoad ? new_link.uri : new_link)\n link = to_validate[uri] || queued[uri] || validated[uri] || invalid[uri]\n\n if not link\n puts 'queueing ' + uri.to_s if @opts[:verbose]\n link = (new_link.class == LinkToLoad ? new_link : LinkToLoad.new(uri, from, @opts.merge({ recurse: recurse }), self))\n to_validate[uri] = link\n elsif from and not @opts[:duplicate]\n link.add_page_from from\n end\n\n link\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def add_link(link)\n links << link\n end","def add_link\n @bib.link.each do |l|\n case l.type&.downcase\n when \"doi\" then @item.doi = l.content\n when \"file\" then @item.file2 = l.content\n when \"src\" then @item.url = l.content\n end\n end\n end","def append_link\n url = params[:link]\n @link = Link.new()\n @link.url = url[:url]\n @link.package = Package.find(params[:package_id])\n @link.save()\n # renova a busca para atualizar lista de links.\n @links = Link.find(:all, :conditions => [\"package_id = ?\", params[:package_id]])\n\n flash[:notice] = \"Link was successfully appended.
\" + url[:url]\n redirect_to :action => 'show', :id => params[:package_id]\n end","def add_link(links)\n links = [links] if links.is_a?(String)\n self.class.get(\"/action/add/links/grabber0/start1/\"+links.join(\" \"))\n end","def link(link, title, content)\n\t \"#{content}\"\n\t end","def link() url; end","def link() url; end","def link uri\n self.apply_hyperlink java.net.URI.new(uri)\n end","def add_href\n return if attributes.key?(\"href\")\n return unless attributes.key?(\"id\")\n attributes[\"href\"] = client.connection.api_path(\"#{collection.name}/#{attributes['id']}\")\n end","def add_this(text, url)\n link_to text, \"http://www.addthis.com/bookmark.php\", :onmouseover => \"return addthis_open(this, '', '#{url}', '');\", :onmouseout => \"addthis_close();\", :onclick => \"return addthis_sendto();\"\n end","def add(link)\n @queue.add link\n end","def add_link(target)\n link = Link.new\n link.target_type = target.class.to_s\n link.target_id = target.id\n #adding a link to the link collection should set the polymorphic assosication\n links << link\n link\n end","def check_is_add_link_request\n if params[:add_link]\n link_text = \" link(#{t(:visible_text)}, #{t(:invisible_url)}) \"\n p = Paragraph.find(params[:add_link].keys.first)\n p.update_attributes({title: p.get_title, body: p.get_body + link_text})\n end\n end","def add(url)\n @links << url\n end","def html_link(item)\n tag :a, yield, :href => item.url\n end","def link(link, title, content)\n \"#{content} (#{link})\"\n end","def add_link(uri, x0, y0, x1, y1)\n PDF::Writer::Object::Annotation.new(self, :link, [x0, y0, x1, y1], uri)\n end","def add_link(key, name)\n passage = Passage.where(name: name).first\n\n self.links << Link.create({ key: key, passage: passage })\n end","def append_link( output, text, record )\n return ( output << \" \" << link_to(\n text.html_safe,\n {\n :controller => record.auditable_type.downcase.pluralize,\n :action => 'show',\n :id => record.auditable_id\n }\n )\n ).html_safe()\n end","def add_link(el, href, title, alt_text = T.unsafe(nil), ial = T.unsafe(nil)); end","def link *a; app.link *a end","def link\n Html::Link.new(:href => url) << display_name\n end","def create_links\n end","def create_links\n end","def add(link, options={})\n if file = link.is_a?(SitemapFile) && link\n @sitemaps_link_count += file.link_count\n file.finalize!\n end\n super(SitemapGenerator::Builder::SitemapIndexUrl.new(link, options))\n end","def parse_link; end","def link(relation, href, options={})\n @resource.add_link relation, href, options\n end","def link(_content, _url)\n raise NotImplementedError\n end","def link_to(name, url, options = {}); end","def add_link(lh)\n lnk_wid = lh[:wid]\n\tlnk_role = lh[:role]\n\t\n\t# find or create the attach node\n if @doc.xpath('//field[@id=\"linkedWorkItems\"]/list').last.nil?\n Nokogiri::XML::Builder.with(@doc.xpath('//work-item').last) do\n field(:id => 'linkedWorkItems') {\n\t list {}\n\t }\n end\n end\n\t\n\t# build and attach the link struct\n\tNokogiri::XML::Builder.with(@doc.xpath('//field[@id=\"linkedWorkItems\"]/list').last) do\n\t struct {\n\t item(:id => 'revision')\n\t\titem(:id => 'workItem') {\n\t\t text lnk_wid\n\t\t}\n\t\titem(:id => 'role') {\n\t\t text lnk_role\n\t\t}\n\t }\n\tend\n end","def link(content,href,options={})\n options.update :href => href\n tag :a, content, options\n end","def link!\n self.linkbutton = true\n self.save\n self.linkbutton\n end","def link_to_add_entry page\n url = new_admin_page_path parent_id: @page.id, type: page_set_type(page)\n raw link_to 'Add Entry', url, class: 'button add', id: 'add-entry'\n end","def add_link step, condition\n # need to review whether we need links as a has table of this kind\n link = Link.new(step, condition)\n @links[condition] = link\n condition.step.add_link link\n link\n end","def add_link step, condition\r\n # need to review whether we need links as a has table of this kind\r\n link = Link.new(step, condition)\r\n @links[condition] = link\r\n condition.step.add_link link\r\n link\r\n end","def link(link, title, content)\n link = OodAppkit.files.api(path: @app_path.to_s + '/' + link).to_s if @app_path && relative?(link)\n return \"#{content}\" unless id_link?(link)\n return \"#{content}\"\n end","def link(link, title, content)\n if no_links\n content\n else\n # \"#{content}\"\n \"#{content}\"\n end\n end","def link(link_text)\n element(damballa(link_text+\"_link\")) { |b| b.link(:text=>link_text) }\n action(damballa(link_text)) { |b| b.link(:text=>link_text).click }\n end","def make_link(source:, link:)\n @output.item @i18n.t('setup.ln', target: link, source: source)\n FileUtils::rm link if (File::symlink? link and not File::exist? link)\n FileUtils::ln_s source, link unless File::exist? link\n end","def add_link(options = {}, &block)\n id = @link_options[:id] ? (@link_options[:id].to_s + \"_\" + (@links.size + 1).to_s) : nil\n link = Ubiquo::NavigationLinks::Link.new(\n { :id => id, \n :class => @link_options[:class]\n }.merge(options))\n @links << link\n block.call(link)\n link\n end","def process_page_link_tag(tag)\n parts = tag.split(' ')\n\n url, *descp = parts\n title = descp.join(\" \")\n\n alternatives = Repos.alternatives(*url.split(\"/\"))\n\n base_link, add_links = [], []\n\n extern_url = url =~ /^https?:/\n\n url = \"/#{url}\" if not url[0..0] == \"/\" and not extern_url\n title = url if title.empty?\n\n if extern_url\n return %Q{#{title}}\n elsif tag =~ /^mailto:/\n return %Q{#{tag.split(\":\")[1..-1]}}\n end\n\n if not alternatives.empty?\n alternatives.each_pair do |ext, file|\n if ext == defext # find page with default extension\n\n base_url =\n if alternatives.size > 1\n # add extension for base_url unless given\n url !~ /\\.#{ext}$/ ? \"#{url}.#{ext}\" : url\n else url end\n\n base_link << [base_url, file]\n else\n add_links << [\"#{url}.#{ext}\", file]\n end\n end\n else\n # not existing page\n base_link << [url, nil]\n end\n\n # sort links by extension\n add_links = add_links.sort_by{|link, file| File.extname(file) }\n\n if base_link.empty?\n base_link << add_links.shift\n end\n\n title = title[1..-1] if title[0..0] == \"/\"\n base_link.map!{|url, _| mk_link(url, (alternatives.empty? ? \"o\" : \"x\"), title) }\n add_links.map!{|url, _| mk_link(url, 'alt', nil) }\n\n ret = base_link.join\n unless add_links.empty?\n ret << \" (%s)\" % add_links.join(\", \")\n end\n ret\n end","def external_link(link_label, url, options={})\n attributes = options[:attributes] || {}\n children = options[:children] || {}\n image = options[:image] || {}\n\n img =\"\"\n unless image.empty?\n img = self.external_image(image[:url], image, true) \n end\n\n child_elements = self.children_list(children) << img\n link_label = self.tag('label', link_label)\n url = self.tag('url', url)\n link = self.tag('externalLink', url << link_label << child_elements, attributes)\n\n cell = options[:cell] || {}\n row = options[:row] || {}\n self.row_cell(link, cell, row)\n end","def linkify(options = {})\n url = options[:value].first\n link_to url, url\n end","def link_action_add(path = nil, url_options = {})\n path ||= path_args(model_class)\n link_action ti(:\"link.add\"), 'plus', path.is_a?(String) ? path : new_polymorphic_path(path, url_options)\n end","def link_action_add(path = nil, url_options = {})\n path ||= path_args(model_class)\n link_action ti(:\"link.add\"), 'plus', path.is_a?(String) ? path : new_polymorphic_path(path, url_options)\n end","def update_link(link)\n if i = find_index { |l| l.rel.to_s == link.rel.to_s }\n return self[i] = link\n end\n self << link\n end","def click(link); end","def emit_link(cur_mtg_dir, f, desc)\n _a desc, href: f.include?('/') ? f : File.join(cur_mtg_dir, f)\nend","def add_line_items_link\n self.get_element(@browser, '//a[contains(@href, \"/line_items/create?insertion_orders.id=\")]')\n end","def add_link(el, href, title, alt_text = nil, ial = nil)\n el.options[:ial] = ial\n update_attr_with_ial(el.attr, ial) if ial\n if el.type == :a\n el.attr['href'] = href\n else\n el.attr['src'] = href\n el.attr['alt'] = alt_text\n el.children.clear\n end\n el.attr['title'] = title if title\n @tree.children << el\n end","def link\n h.content_tag :li do\n h.link_to h.content_tag(:i, '' , class: object.icon ) , object.url , target: \"_blank\" , title: object.name\n end\n end","def link(url, title) # :nodoc:\n warn \"link called from #{self.inspect}\"\n \"[#{title}](#{url})\"\n end","def with_link(*args)\n @links.push(args.length == 1 ? args.first : Link.new(*args))\n self\n end","def make_link(url, text)\n return (\"[#{text}|#{url}]\")\n end","def link(tag)\n apply_uri_template @tag_link_template, tag: safe_parameterize(tag)\n end","def AddLink()\n\t\t#Create a new internal link\n\t\tn=@links.length+1;\n\t\t@links[n]=[0,0];\n\t\treturn n;\n\tend","def link(url)\n if @_bucket.nil?\n raise \"Robots.link must be called inside of allow or disallow block\"\n else\n @_bucket.push(url.to_s)\n end\n end","def create_link(item_nr)\n \"#{self}\"\n end","def new_link\n @link = Link.new\n end","def link(opts)\n \"#{opts[:name]} !LINK_OPEN_TAG!#{opts[:href]}!LINK_CLOSE_TAG!\"\n end","def link_to(body, url)\n \"[#{body}](#{url})\" if !AIPP.options.check_links || url_exists?(url)\n end","def insert_link (fileArray, linkName, utilHash)\n\nend","def link(href, opts={})\n @resource.tap {|obj| obj.add_link(@rel, href, opts) }\n end","def link(_link, _title, content)\n content.to_s\n end","def link_tag(output_file, map = {})\n write output_file, \"\\t\"\n end","def link(*args)\n Restfulie::Common::Builder::Rules::Link.new(*args)\n end","def href; end","def link_to_add_entry(page)\n url = new_admin_page_path parent_id: page.id, type: page_set_type(page)\n raw link_to 'Add Entry', url, class: 'button add-child'\n end","def link_add\n @link = Link.find(params[:link])\n @show_date = ShowdateLink.find_by_user_id(@user)\n l = Linkalation.new\n\n l.user_id = current_user.id\n l.link_id = @link.id\n l.show_date = @show_date.showdate\n l.save!\n\n render :nothing => true\n end","def parse_link_definition; end","def create\n @link = Link.new(params[:link])\n\n respond_to do |format|\n if (@entity.links << @link)\n flash[:notice] = 'Link was successfully created.'\n furl = link_url(@entity,@link)\n format.html { redirect_to furl}\n format.xml { head :created, :location => furl }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @link.errors.to_xml }\n end\n end\n end","def concat(link)\n Wgit::Url.concat(self, link)\n end","def linkgen\n\n LinkGenerator.new(request)\n end","def link!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 25 )\n\n type = LINK\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 159:8: 'link'\n match( \"link\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 25 )\n\n end","def link(text, target, attributes = {})\n if target.is_a? Fixnum\n attributes[:rel] = rel_value(target)\n target = url(target)\n end\n @template.link_to(text, target, attributes.merge(:remote => true))\n end","def link\n @link\n end","def append_target!\n @tag.gsub! /\\ @link, :status => :created, :location => @link }\n else\n format.html { redirect_to @question }\n flash[:notice] = 'Link must start with \"http://\"'\n format.xml { render :xml => @link.errors, :status => :unprocessable_entity }\n end\n end\n end","def add_link_header(query_parameters)\n response.headers['Link'] = construct_link_header(query_parameters)\n end","def link(text, target, attributes = {})\n if target.is_a? Fixnum\n attributes[:rel] = rel_value(target)\n target = url(target)\n end\n @template.link_to(text, target, attributes)\n end","def link(link, title, content)\n\t\tif (title)\n\t\t\treturn \"title : [#{content}|#{link}]\"\n\t\telse\n\t\t\treturn \"[#{content}|#{link}]\"\n\t\tend\n\tend","def click_add_line_items_link\n add_line_items_link.click\n end","def add_link(url)\n if url.is_a?(Array)\n url.each do |u|\n self.add_link(u)\n end\n return @links\n end\n if url.is_a?(String) and url =~ /^http(s)?\\:\\/\\//\n response = nil\n uri = URI.parse(url)\n Net::HTTP.start(uri.host, uri.port) {|http|\n response = http.head(uri.path)\n }\n @links.push({:url=>url,:filename=>File.basename(uri.path),:size=>response['content-length'].to_i})\n return @links\n end\n raise RuntimeError, \"Invalid URL: #{url}\"\n end","def linkify(url, text)\n if ENV['BUILDKITE']\n \"\\033]1339;url='#{url}';content='#{text}'\\a\"\n else\n \"#{text}: #{url}\"\n end\n end","def queue_link( tag, source )\n return if tag.attributes['class'] && tag.attributes['class']['thickbox'] == 'thickbox'\n return if tag.attributes['onclick']\n dest = (tag.attributes['onclick'] =~ /^new Ajax.Updater\\(['\"].*?['\"], ['\"](.*?)['\"]/i) ? $1 : tag.attributes['href']\n if !(dest =~ %r{^(mailto:|#|javascript:|http://|.*\\.jpg|aim:|ichat:|xmpp:)})\n @links_to_visit << Link.new( dest, source )\n end\n end","def inline_auto_link(text)\n text.gsub!(AUTO_LINK_RE) do\n all, leading, proto, url, post = $&, $1, $2, $3, $6\n if leading =~ /=]?/\n # don't replace URL's that are already linked\n # and URL's prefixed with ! !> !< != (textile images)\n all\n else\n # Idea below : an URL with unbalanced parethesis and\n # ending by ')' is put into external parenthesis\n if ( url[-1]==?) and ((url.count(\"(\") - url.count(\")\")) < 0 ) )\n url=url[0..-2] # discard closing parenth from url\n post = \")\"+post # add closing parenth to post\n end\n tag = content_tag('a', proto + url, :href => \"#{proto==\"www.\"?\"http://www.\":proto}#{url}\", :class => 'external')\n %(#{leading}#{tag}#{post})\n end\n end\n end","def url(href)\n a href, :href => href\n end","def handle_special_HYPERLINK(special)\n url = special.text\n gen_url url, url\n end","def publication_link\n h.link_to \"Read Now\" , object.publication_url , title: 'Read Now' , class: 'btn waves-effect waves-light btn-primary custom-btn' , target: '_blank'\n end","def link_to_asset(body,model,url_opts={},html={})\n result = String.new\n result << ''\n result << body\n result << ''\n end","def process\n # process url\n urls = self.text.scan(URL_REGEXP)\n urls.each { |url|\n tiny_url = open(\"http://tinyurl.com/api-create.php?url=#{url[0]}\") { |s| s.read }\n self.text.sub!(url[0], \"#{tiny_url}\")\n }\n \n # process @\n ats = self.text.scan(AT_REGEXP)\n ats.each { |at| \n self.text.sub!(at, \"#{at}\")\n }\n\n end","def process\n # process url\n urls = self.text.scan(URL_REGEXP)\n urls.each { |url|\n tiny_url = open(\"http://tinyurl.com/api-create.php?url=#{url[0]}\") {|s| s.read} \n self.text.sub!(url[0], \"#{tiny_url}\")\n } \n # process @\n ats = self.text.scan(AT_REGEXP)\n ats.each { |at| self.text.sub!(at, \"#{at}\") } \n end","def render_create_content_link(element, options = {})\n\t\t\t\tdefaults = {\n\t\t\t\t\t:label => t('add new content')\n\t\t\t\t}\n\t\t\t\toptions = defaults.merge(options)\n\t\t\t\tlink_to(\n\t\t\t\t\toptions[:label],\n\t\t\t\t\talchemy.admin_contents_path(\n\t\t\t\t\t\t:content => {\n\t\t\t\t\t\t\t:name => options[:content_name],\n\t\t\t\t\t\t\t:element_id => element.id\n\t\t\t\t\t\t}\n\t\t\t\t\t),\n\t\t\t\t\t:method => 'post',\n\t\t\t\t\t:remote => true,\n\t\t\t\t\t:id => \"add_content_for_element_#{element.id}\",\n\t\t\t\t\t:class => 'button new_content_link'\n\t\t\t\t)\n\t\t\tend","def Link(x, y, w, h, link)\n\t\t#Put a link on the page\n @page_links ||= Array.new\n @page_links[@page] ||= Array.new\n @page_links[@page].push([x * @k, @h_pt - y * @k, w * @k, h*@k, link]);\n\tend","def link *a, &b; app.link *a, &b end","def ajax_add_link\n\n # Create a new Link Instance\n link = Link.new\n\n # Update the fields of Link Instance\n link.funnel_id = params[:funnel_id]\n link.to_node_id = params[:to_operator_id].to_i\n\n if params[:from_operator_id].to_i === 0\n # If the link starts at the start node, set slink to 1\n link.start_link = 1\n else\n # Otherwise, set slink to 0 (false) and set from_operator_id\n link.start_link = 0\n link.from_node_id = params[:from_operator_id].to_i\n end\n\n # Save and verify Link and return correct JSON response\n if link.save!\n final_json = JSON.pretty_generate(result = {\n :success => true\n })\n else\n final_json = JSON.pretty_generate(result = {\n :success => false\n })\n end\n\n # Return JSON response\n render json: final_json\n\n end","def link(**opt)\n opt[:path] = show_path(id: object.identifier)\n super(**opt)\n end","def link\n @link ||= uri.to_s\n end"],"string":"[\n \"def add_link(link)\\n links << link\\n end\",\n \"def add_link\\n @bib.link.each do |l|\\n case l.type&.downcase\\n when \\\"doi\\\" then @item.doi = l.content\\n when \\\"file\\\" then @item.file2 = l.content\\n when \\\"src\\\" then @item.url = l.content\\n end\\n end\\n end\",\n \"def append_link\\n url = params[:link]\\n @link = Link.new()\\n @link.url = url[:url]\\n @link.package = Package.find(params[:package_id])\\n @link.save()\\n # renova a busca para atualizar lista de links.\\n @links = Link.find(:all, :conditions => [\\\"package_id = ?\\\", params[:package_id]])\\n\\n flash[:notice] = \\\"Link was successfully appended.
\\\" + url[:url]\\n redirect_to :action => 'show', :id => params[:package_id]\\n end\",\n \"def add_link(links)\\n links = [links] if links.is_a?(String)\\n self.class.get(\\\"/action/add/links/grabber0/start1/\\\"+links.join(\\\" \\\"))\\n end\",\n \"def link(link, title, content)\\n\\t \\\"#{content}\\\"\\n\\t end\",\n \"def link() url; end\",\n \"def link() url; end\",\n \"def link uri\\n self.apply_hyperlink java.net.URI.new(uri)\\n end\",\n \"def add_href\\n return if attributes.key?(\\\"href\\\")\\n return unless attributes.key?(\\\"id\\\")\\n attributes[\\\"href\\\"] = client.connection.api_path(\\\"#{collection.name}/#{attributes['id']}\\\")\\n end\",\n \"def add_this(text, url)\\n link_to text, \\\"http://www.addthis.com/bookmark.php\\\", :onmouseover => \\\"return addthis_open(this, '', '#{url}', '');\\\", :onmouseout => \\\"addthis_close();\\\", :onclick => \\\"return addthis_sendto();\\\"\\n end\",\n \"def add(link)\\n @queue.add link\\n end\",\n \"def add_link(target)\\n link = Link.new\\n link.target_type = target.class.to_s\\n link.target_id = target.id\\n #adding a link to the link collection should set the polymorphic assosication\\n links << link\\n link\\n end\",\n \"def check_is_add_link_request\\n if params[:add_link]\\n link_text = \\\" link(#{t(:visible_text)}, #{t(:invisible_url)}) \\\"\\n p = Paragraph.find(params[:add_link].keys.first)\\n p.update_attributes({title: p.get_title, body: p.get_body + link_text})\\n end\\n end\",\n \"def add(url)\\n @links << url\\n end\",\n \"def html_link(item)\\n tag :a, yield, :href => item.url\\n end\",\n \"def link(link, title, content)\\n \\\"#{content} (#{link})\\\"\\n end\",\n \"def add_link(uri, x0, y0, x1, y1)\\n PDF::Writer::Object::Annotation.new(self, :link, [x0, y0, x1, y1], uri)\\n end\",\n \"def add_link(key, name)\\n passage = Passage.where(name: name).first\\n\\n self.links << Link.create({ key: key, passage: passage })\\n end\",\n \"def append_link( output, text, record )\\n return ( output << \\\" \\\" << link_to(\\n text.html_safe,\\n {\\n :controller => record.auditable_type.downcase.pluralize,\\n :action => 'show',\\n :id => record.auditable_id\\n }\\n )\\n ).html_safe()\\n end\",\n \"def add_link(el, href, title, alt_text = T.unsafe(nil), ial = T.unsafe(nil)); end\",\n \"def link *a; app.link *a end\",\n \"def link\\n Html::Link.new(:href => url) << display_name\\n end\",\n \"def create_links\\n end\",\n \"def create_links\\n end\",\n \"def add(link, options={})\\n if file = link.is_a?(SitemapFile) && link\\n @sitemaps_link_count += file.link_count\\n file.finalize!\\n end\\n super(SitemapGenerator::Builder::SitemapIndexUrl.new(link, options))\\n end\",\n \"def parse_link; end\",\n \"def link(relation, href, options={})\\n @resource.add_link relation, href, options\\n end\",\n \"def link(_content, _url)\\n raise NotImplementedError\\n end\",\n \"def link_to(name, url, options = {}); end\",\n \"def add_link(lh)\\n lnk_wid = lh[:wid]\\n\\tlnk_role = lh[:role]\\n\\t\\n\\t# find or create the attach node\\n if @doc.xpath('//field[@id=\\\"linkedWorkItems\\\"]/list').last.nil?\\n Nokogiri::XML::Builder.with(@doc.xpath('//work-item').last) do\\n field(:id => 'linkedWorkItems') {\\n\\t list {}\\n\\t }\\n end\\n end\\n\\t\\n\\t# build and attach the link struct\\n\\tNokogiri::XML::Builder.with(@doc.xpath('//field[@id=\\\"linkedWorkItems\\\"]/list').last) do\\n\\t struct {\\n\\t item(:id => 'revision')\\n\\t\\titem(:id => 'workItem') {\\n\\t\\t text lnk_wid\\n\\t\\t}\\n\\t\\titem(:id => 'role') {\\n\\t\\t text lnk_role\\n\\t\\t}\\n\\t }\\n\\tend\\n end\",\n \"def link(content,href,options={})\\n options.update :href => href\\n tag :a, content, options\\n end\",\n \"def link!\\n self.linkbutton = true\\n self.save\\n self.linkbutton\\n end\",\n \"def link_to_add_entry page\\n url = new_admin_page_path parent_id: @page.id, type: page_set_type(page)\\n raw link_to 'Add Entry', url, class: 'button add', id: 'add-entry'\\n end\",\n \"def add_link step, condition\\n # need to review whether we need links as a has table of this kind\\n link = Link.new(step, condition)\\n @links[condition] = link\\n condition.step.add_link link\\n link\\n end\",\n \"def add_link step, condition\\r\\n # need to review whether we need links as a has table of this kind\\r\\n link = Link.new(step, condition)\\r\\n @links[condition] = link\\r\\n condition.step.add_link link\\r\\n link\\r\\n end\",\n \"def link(link, title, content)\\n link = OodAppkit.files.api(path: @app_path.to_s + '/' + link).to_s if @app_path && relative?(link)\\n return \\\"#{content}\\\" unless id_link?(link)\\n return \\\"#{content}\\\"\\n end\",\n \"def link(link, title, content)\\n if no_links\\n content\\n else\\n # \\\"#{content}\\\"\\n \\\"#{content}\\\"\\n end\\n end\",\n \"def link(link_text)\\n element(damballa(link_text+\\\"_link\\\")) { |b| b.link(:text=>link_text) }\\n action(damballa(link_text)) { |b| b.link(:text=>link_text).click }\\n end\",\n \"def make_link(source:, link:)\\n @output.item @i18n.t('setup.ln', target: link, source: source)\\n FileUtils::rm link if (File::symlink? link and not File::exist? link)\\n FileUtils::ln_s source, link unless File::exist? link\\n end\",\n \"def add_link(options = {}, &block)\\n id = @link_options[:id] ? (@link_options[:id].to_s + \\\"_\\\" + (@links.size + 1).to_s) : nil\\n link = Ubiquo::NavigationLinks::Link.new(\\n { :id => id, \\n :class => @link_options[:class]\\n }.merge(options))\\n @links << link\\n block.call(link)\\n link\\n end\",\n \"def process_page_link_tag(tag)\\n parts = tag.split(' ')\\n\\n url, *descp = parts\\n title = descp.join(\\\" \\\")\\n\\n alternatives = Repos.alternatives(*url.split(\\\"/\\\"))\\n\\n base_link, add_links = [], []\\n\\n extern_url = url =~ /^https?:/\\n\\n url = \\\"/#{url}\\\" if not url[0..0] == \\\"/\\\" and not extern_url\\n title = url if title.empty?\\n\\n if extern_url\\n return %Q{#{title}}\\n elsif tag =~ /^mailto:/\\n return %Q{#{tag.split(\\\":\\\")[1..-1]}}\\n end\\n\\n if not alternatives.empty?\\n alternatives.each_pair do |ext, file|\\n if ext == defext # find page with default extension\\n\\n base_url =\\n if alternatives.size > 1\\n # add extension for base_url unless given\\n url !~ /\\\\.#{ext}$/ ? \\\"#{url}.#{ext}\\\" : url\\n else url end\\n\\n base_link << [base_url, file]\\n else\\n add_links << [\\\"#{url}.#{ext}\\\", file]\\n end\\n end\\n else\\n # not existing page\\n base_link << [url, nil]\\n end\\n\\n # sort links by extension\\n add_links = add_links.sort_by{|link, file| File.extname(file) }\\n\\n if base_link.empty?\\n base_link << add_links.shift\\n end\\n\\n title = title[1..-1] if title[0..0] == \\\"/\\\"\\n base_link.map!{|url, _| mk_link(url, (alternatives.empty? ? \\\"o\\\" : \\\"x\\\"), title) }\\n add_links.map!{|url, _| mk_link(url, 'alt', nil) }\\n\\n ret = base_link.join\\n unless add_links.empty?\\n ret << \\\" (%s)\\\" % add_links.join(\\\", \\\")\\n end\\n ret\\n end\",\n \"def external_link(link_label, url, options={})\\n attributes = options[:attributes] || {}\\n children = options[:children] || {}\\n image = options[:image] || {}\\n\\n img =\\\"\\\"\\n unless image.empty?\\n img = self.external_image(image[:url], image, true) \\n end\\n\\n child_elements = self.children_list(children) << img\\n link_label = self.tag('label', link_label)\\n url = self.tag('url', url)\\n link = self.tag('externalLink', url << link_label << child_elements, attributes)\\n\\n cell = options[:cell] || {}\\n row = options[:row] || {}\\n self.row_cell(link, cell, row)\\n end\",\n \"def linkify(options = {})\\n url = options[:value].first\\n link_to url, url\\n end\",\n \"def link_action_add(path = nil, url_options = {})\\n path ||= path_args(model_class)\\n link_action ti(:\\\"link.add\\\"), 'plus', path.is_a?(String) ? path : new_polymorphic_path(path, url_options)\\n end\",\n \"def link_action_add(path = nil, url_options = {})\\n path ||= path_args(model_class)\\n link_action ti(:\\\"link.add\\\"), 'plus', path.is_a?(String) ? path : new_polymorphic_path(path, url_options)\\n end\",\n \"def update_link(link)\\n if i = find_index { |l| l.rel.to_s == link.rel.to_s }\\n return self[i] = link\\n end\\n self << link\\n end\",\n \"def click(link); end\",\n \"def emit_link(cur_mtg_dir, f, desc)\\n _a desc, href: f.include?('/') ? f : File.join(cur_mtg_dir, f)\\nend\",\n \"def add_line_items_link\\n self.get_element(@browser, '//a[contains(@href, \\\"/line_items/create?insertion_orders.id=\\\")]')\\n end\",\n \"def add_link(el, href, title, alt_text = nil, ial = nil)\\n el.options[:ial] = ial\\n update_attr_with_ial(el.attr, ial) if ial\\n if el.type == :a\\n el.attr['href'] = href\\n else\\n el.attr['src'] = href\\n el.attr['alt'] = alt_text\\n el.children.clear\\n end\\n el.attr['title'] = title if title\\n @tree.children << el\\n end\",\n \"def link\\n h.content_tag :li do\\n h.link_to h.content_tag(:i, '' , class: object.icon ) , object.url , target: \\\"_blank\\\" , title: object.name\\n end\\n end\",\n \"def link(url, title) # :nodoc:\\n warn \\\"link called from #{self.inspect}\\\"\\n \\\"[#{title}](#{url})\\\"\\n end\",\n \"def with_link(*args)\\n @links.push(args.length == 1 ? args.first : Link.new(*args))\\n self\\n end\",\n \"def make_link(url, text)\\n return (\\\"[#{text}|#{url}]\\\")\\n end\",\n \"def link(tag)\\n apply_uri_template @tag_link_template, tag: safe_parameterize(tag)\\n end\",\n \"def AddLink()\\n\\t\\t#Create a new internal link\\n\\t\\tn=@links.length+1;\\n\\t\\t@links[n]=[0,0];\\n\\t\\treturn n;\\n\\tend\",\n \"def link(url)\\n if @_bucket.nil?\\n raise \\\"Robots.link must be called inside of allow or disallow block\\\"\\n else\\n @_bucket.push(url.to_s)\\n end\\n end\",\n \"def create_link(item_nr)\\n \\\"#{self}\\\"\\n end\",\n \"def new_link\\n @link = Link.new\\n end\",\n \"def link(opts)\\n \\\"#{opts[:name]} !LINK_OPEN_TAG!#{opts[:href]}!LINK_CLOSE_TAG!\\\"\\n end\",\n \"def link_to(body, url)\\n \\\"[#{body}](#{url})\\\" if !AIPP.options.check_links || url_exists?(url)\\n end\",\n \"def insert_link (fileArray, linkName, utilHash)\\n\\nend\",\n \"def link(href, opts={})\\n @resource.tap {|obj| obj.add_link(@rel, href, opts) }\\n end\",\n \"def link(_link, _title, content)\\n content.to_s\\n end\",\n \"def link_tag(output_file, map = {})\\n write output_file, \\\"\\\\t\\\"\\n end\",\n \"def link(*args)\\n Restfulie::Common::Builder::Rules::Link.new(*args)\\n end\",\n \"def href; end\",\n \"def link_to_add_entry(page)\\n url = new_admin_page_path parent_id: page.id, type: page_set_type(page)\\n raw link_to 'Add Entry', url, class: 'button add-child'\\n end\",\n \"def link_add\\n @link = Link.find(params[:link])\\n @show_date = ShowdateLink.find_by_user_id(@user)\\n l = Linkalation.new\\n\\n l.user_id = current_user.id\\n l.link_id = @link.id\\n l.show_date = @show_date.showdate\\n l.save!\\n\\n render :nothing => true\\n end\",\n \"def parse_link_definition; end\",\n \"def create\\n @link = Link.new(params[:link])\\n\\n respond_to do |format|\\n if (@entity.links << @link)\\n flash[:notice] = 'Link was successfully created.'\\n furl = link_url(@entity,@link)\\n format.html { redirect_to furl}\\n format.xml { head :created, :location => furl }\\n else\\n format.html { render :action => \\\"new\\\" }\\n format.xml { render :xml => @link.errors.to_xml }\\n end\\n end\\n end\",\n \"def concat(link)\\n Wgit::Url.concat(self, link)\\n end\",\n \"def linkgen\\n\\n LinkGenerator.new(request)\\n end\",\n \"def link!\\n # -> uncomment the next line to manually enable rule tracing\\n # trace_in( __method__, 25 )\\n\\n type = LINK\\n channel = ANTLR3::DEFAULT_CHANNEL\\n\\n \\n # - - - - main rule block - - - -\\n # at line 159:8: 'link'\\n match( \\\"link\\\" )\\n\\n \\n @state.type = type\\n @state.channel = channel\\n\\n ensure\\n # -> uncomment the next line to manually enable rule tracing\\n # trace_out( __method__, 25 )\\n\\n end\",\n \"def link(text, target, attributes = {})\\n if target.is_a? Fixnum\\n attributes[:rel] = rel_value(target)\\n target = url(target)\\n end\\n @template.link_to(text, target, attributes.merge(:remote => true))\\n end\",\n \"def link\\n @link\\n end\",\n \"def append_target!\\n @tag.gsub! /\\\\ @link, :status => :created, :location => @link }\\n else\\n format.html { redirect_to @question }\\n flash[:notice] = 'Link must start with \\\"http://\\\"'\\n format.xml { render :xml => @link.errors, :status => :unprocessable_entity }\\n end\\n end\\n end\",\n \"def add_link_header(query_parameters)\\n response.headers['Link'] = construct_link_header(query_parameters)\\n end\",\n \"def link(text, target, attributes = {})\\n if target.is_a? Fixnum\\n attributes[:rel] = rel_value(target)\\n target = url(target)\\n end\\n @template.link_to(text, target, attributes)\\n end\",\n \"def link(link, title, content)\\n\\t\\tif (title)\\n\\t\\t\\treturn \\\"title : [#{content}|#{link}]\\\"\\n\\t\\telse\\n\\t\\t\\treturn \\\"[#{content}|#{link}]\\\"\\n\\t\\tend\\n\\tend\",\n \"def click_add_line_items_link\\n add_line_items_link.click\\n end\",\n \"def add_link(url)\\n if url.is_a?(Array)\\n url.each do |u|\\n self.add_link(u)\\n end\\n return @links\\n end\\n if url.is_a?(String) and url =~ /^http(s)?\\\\:\\\\/\\\\//\\n response = nil\\n uri = URI.parse(url)\\n Net::HTTP.start(uri.host, uri.port) {|http|\\n response = http.head(uri.path)\\n }\\n @links.push({:url=>url,:filename=>File.basename(uri.path),:size=>response['content-length'].to_i})\\n return @links\\n end\\n raise RuntimeError, \\\"Invalid URL: #{url}\\\"\\n end\",\n \"def linkify(url, text)\\n if ENV['BUILDKITE']\\n \\\"\\\\033]1339;url='#{url}';content='#{text}'\\\\a\\\"\\n else\\n \\\"#{text}: #{url}\\\"\\n end\\n end\",\n \"def queue_link( tag, source )\\n return if tag.attributes['class'] && tag.attributes['class']['thickbox'] == 'thickbox'\\n return if tag.attributes['onclick']\\n dest = (tag.attributes['onclick'] =~ /^new Ajax.Updater\\\\(['\\\"].*?['\\\"], ['\\\"](.*?)['\\\"]/i) ? $1 : tag.attributes['href']\\n if !(dest =~ %r{^(mailto:|#|javascript:|http://|.*\\\\.jpg|aim:|ichat:|xmpp:)})\\n @links_to_visit << Link.new( dest, source )\\n end\\n end\",\n \"def inline_auto_link(text)\\n text.gsub!(AUTO_LINK_RE) do\\n all, leading, proto, url, post = $&, $1, $2, $3, $6\\n if leading =~ /=]?/\\n # don't replace URL's that are already linked\\n # and URL's prefixed with ! !> !< != (textile images)\\n all\\n else\\n # Idea below : an URL with unbalanced parethesis and\\n # ending by ')' is put into external parenthesis\\n if ( url[-1]==?) and ((url.count(\\\"(\\\") - url.count(\\\")\\\")) < 0 ) )\\n url=url[0..-2] # discard closing parenth from url\\n post = \\\")\\\"+post # add closing parenth to post\\n end\\n tag = content_tag('a', proto + url, :href => \\\"#{proto==\\\"www.\\\"?\\\"http://www.\\\":proto}#{url}\\\", :class => 'external')\\n %(#{leading}#{tag}#{post})\\n end\\n end\\n end\",\n \"def url(href)\\n a href, :href => href\\n end\",\n \"def handle_special_HYPERLINK(special)\\n url = special.text\\n gen_url url, url\\n end\",\n \"def publication_link\\n h.link_to \\\"Read Now\\\" , object.publication_url , title: 'Read Now' , class: 'btn waves-effect waves-light btn-primary custom-btn' , target: '_blank'\\n end\",\n \"def link_to_asset(body,model,url_opts={},html={})\\n result = String.new\\n result << ''\\n result << body\\n result << ''\\n end\",\n \"def process\\n # process url\\n urls = self.text.scan(URL_REGEXP)\\n urls.each { |url|\\n tiny_url = open(\\\"http://tinyurl.com/api-create.php?url=#{url[0]}\\\") { |s| s.read }\\n self.text.sub!(url[0], \\\"#{tiny_url}\\\")\\n }\\n \\n # process @\\n ats = self.text.scan(AT_REGEXP)\\n ats.each { |at| \\n self.text.sub!(at, \\\"#{at}\\\")\\n }\\n\\n end\",\n \"def process\\n # process url\\n urls = self.text.scan(URL_REGEXP)\\n urls.each { |url|\\n tiny_url = open(\\\"http://tinyurl.com/api-create.php?url=#{url[0]}\\\") {|s| s.read} \\n self.text.sub!(url[0], \\\"#{tiny_url}\\\")\\n } \\n # process @\\n ats = self.text.scan(AT_REGEXP)\\n ats.each { |at| self.text.sub!(at, \\\"#{at}\\\") } \\n end\",\n \"def render_create_content_link(element, options = {})\\n\\t\\t\\t\\tdefaults = {\\n\\t\\t\\t\\t\\t:label => t('add new content')\\n\\t\\t\\t\\t}\\n\\t\\t\\t\\toptions = defaults.merge(options)\\n\\t\\t\\t\\tlink_to(\\n\\t\\t\\t\\t\\toptions[:label],\\n\\t\\t\\t\\t\\talchemy.admin_contents_path(\\n\\t\\t\\t\\t\\t\\t:content => {\\n\\t\\t\\t\\t\\t\\t\\t:name => options[:content_name],\\n\\t\\t\\t\\t\\t\\t\\t:element_id => element.id\\n\\t\\t\\t\\t\\t\\t}\\n\\t\\t\\t\\t\\t),\\n\\t\\t\\t\\t\\t:method => 'post',\\n\\t\\t\\t\\t\\t:remote => true,\\n\\t\\t\\t\\t\\t:id => \\\"add_content_for_element_#{element.id}\\\",\\n\\t\\t\\t\\t\\t:class => 'button new_content_link'\\n\\t\\t\\t\\t)\\n\\t\\t\\tend\",\n \"def Link(x, y, w, h, link)\\n\\t\\t#Put a link on the page\\n @page_links ||= Array.new\\n @page_links[@page] ||= Array.new\\n @page_links[@page].push([x * @k, @h_pt - y * @k, w * @k, h*@k, link]);\\n\\tend\",\n \"def link *a, &b; app.link *a, &b end\",\n \"def ajax_add_link\\n\\n # Create a new Link Instance\\n link = Link.new\\n\\n # Update the fields of Link Instance\\n link.funnel_id = params[:funnel_id]\\n link.to_node_id = params[:to_operator_id].to_i\\n\\n if params[:from_operator_id].to_i === 0\\n # If the link starts at the start node, set slink to 1\\n link.start_link = 1\\n else\\n # Otherwise, set slink to 0 (false) and set from_operator_id\\n link.start_link = 0\\n link.from_node_id = params[:from_operator_id].to_i\\n end\\n\\n # Save and verify Link and return correct JSON response\\n if link.save!\\n final_json = JSON.pretty_generate(result = {\\n :success => true\\n })\\n else\\n final_json = JSON.pretty_generate(result = {\\n :success => false\\n })\\n end\\n\\n # Return JSON response\\n render json: final_json\\n\\n end\",\n \"def link(**opt)\\n opt[:path] = show_path(id: object.identifier)\\n super(**opt)\\n end\",\n \"def link\\n @link ||= uri.to_s\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.7483394","0.7205235","0.70008266","0.6883265","0.68251795","0.67953926","0.67953926","0.67707944","0.67035586","0.6687012","0.66641146","0.664809","0.66434485","0.66281384","0.6623783","0.6621798","0.66100514","0.6582565","0.65666807","0.6542367","0.65401983","0.65352124","0.6511309","0.6511309","0.6493562","0.6472986","0.6468805","0.64435047","0.6419305","0.6407972","0.6405193","0.6404987","0.6362903","0.63546073","0.6339188","0.631416","0.6313179","0.6306525","0.6302327","0.62959015","0.62777627","0.62708336","0.62605447","0.6244956","0.6244956","0.62220335","0.6218723","0.62069553","0.62002635","0.6193897","0.61814606","0.6181015","0.61789","0.6172508","0.61698526","0.61690456","0.61679274","0.6167876","0.6162403","0.6153435","0.61435604","0.61324066","0.6130988","0.6129573","0.6118488","0.611785","0.61157376","0.6095532","0.60671103","0.6065403","0.60621727","0.6059515","0.605911","0.6045412","0.6044647","0.60430235","0.60172725","0.60092527","0.6005361","0.600534","0.59963745","0.5992248","0.59873885","0.59852695","0.5978453","0.59724665","0.59721303","0.59472567","0.594152","0.5937757","0.5933143","0.59329116","0.59311795","0.5925635","0.5918012","0.59179014","0.591518","0.5912413","0.59111696","0.59107184"],"string":"[\n \"0.7483394\",\n \"0.7205235\",\n \"0.70008266\",\n \"0.6883265\",\n \"0.68251795\",\n \"0.67953926\",\n \"0.67953926\",\n \"0.67707944\",\n \"0.67035586\",\n \"0.6687012\",\n \"0.66641146\",\n \"0.664809\",\n \"0.66434485\",\n \"0.66281384\",\n \"0.6623783\",\n \"0.6621798\",\n \"0.66100514\",\n \"0.6582565\",\n \"0.65666807\",\n \"0.6542367\",\n \"0.65401983\",\n \"0.65352124\",\n \"0.6511309\",\n \"0.6511309\",\n \"0.6493562\",\n \"0.6472986\",\n \"0.6468805\",\n \"0.64435047\",\n \"0.6419305\",\n \"0.6407972\",\n \"0.6405193\",\n \"0.6404987\",\n \"0.6362903\",\n \"0.63546073\",\n \"0.6339188\",\n \"0.631416\",\n \"0.6313179\",\n \"0.6306525\",\n \"0.6302327\",\n \"0.62959015\",\n \"0.62777627\",\n \"0.62708336\",\n \"0.62605447\",\n \"0.6244956\",\n \"0.6244956\",\n \"0.62220335\",\n \"0.6218723\",\n \"0.62069553\",\n \"0.62002635\",\n \"0.6193897\",\n \"0.61814606\",\n \"0.6181015\",\n \"0.61789\",\n \"0.6172508\",\n \"0.61698526\",\n \"0.61690456\",\n \"0.61679274\",\n \"0.6167876\",\n \"0.6162403\",\n \"0.6153435\",\n \"0.61435604\",\n \"0.61324066\",\n \"0.6130988\",\n \"0.6129573\",\n \"0.6118488\",\n \"0.611785\",\n \"0.61157376\",\n \"0.6095532\",\n \"0.60671103\",\n \"0.6065403\",\n \"0.60621727\",\n \"0.6059515\",\n \"0.605911\",\n \"0.6045412\",\n \"0.6044647\",\n \"0.60430235\",\n \"0.60172725\",\n \"0.60092527\",\n \"0.6005361\",\n \"0.600534\",\n \"0.59963745\",\n \"0.5992248\",\n \"0.59873885\",\n \"0.59852695\",\n \"0.5978453\",\n \"0.59724665\",\n \"0.59721303\",\n \"0.59472567\",\n \"0.594152\",\n \"0.5937757\",\n \"0.5933143\",\n \"0.59329116\",\n \"0.59311795\",\n \"0.5925635\",\n \"0.5918012\",\n \"0.59179014\",\n \"0.591518\",\n \"0.5912413\",\n \"0.59111696\",\n \"0.59107184\"\n]"},"document_score":{"kind":"string","value":"0.6007093"},"document_rank":{"kind":"string","value":"78"}}},{"rowIdx":1882,"cells":{"query":{"kind":"string","value":"grab the next link off the list"},"document":{"kind":"string","value":"def queue_next\n begin\n link = to_validate.shift\n return if not link\n\n queued[link[0]] = link[1]\n\n link[1].validate(@hydra) { |error: nil|\n queued.delete(link[0])\n\n if error then invalidate(link[1], error[:type], error[:msg])\n else validated[link[0]] = link[1]\n end\n }\n link\n rescue Exception\n unshift(link)\n raise $!\n end\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def next\n perform_get(links.next, self.class)\n end","def next_item\n return nil if @link == nil\n link.kernel.select {|item| item.rule == @rule}.first\n end","def next_address\n list_entry[:next]\n end","def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape(page)\n next_link = page.at_css('a.next')\n if next_link \n p next_link\n next_url = BASE_URL + next_link['href']\n p next_url\n scrape_and_look_for_next_link(next_url)\n end\nend","def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape(page)\n next_link = page.at_css('a.next')\n if next_link \n p next_link\n next_url = BASE_URL + next_link['href']\n p next_url\n scrape_and_look_for_next_link(next_url)\n end\nend","def next_list\n @_next ? @resource.list(abs_url: @_next) : nil\n end","def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n\n ## debugging note to the console\n puts 'scraping: '+url\n\n scrape_table(page)\n next_link = page.at_css('li.next')\n if next_link\n next_url = BASE_URL + next_link.at_css('a').attribute(\"href\")\n scrape_and_look_for_next_link(next_url)\n end\nend","def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n\n ## debugging note to the console\n puts 'scraping: '+url\n\n scrape_table(page)\n next_link = page.at_css('li.next')\n if next_link\n next_url = BASE_URL + next_link.at_css('a').attribute(\"href\")\n scrape_and_look_for_next_link(next_url)\n end\nend","def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape_table(page)\n next_link = page.at_css('a.next')\n if next_link \n puts next_link\n next_url = BASE_URL + next_link['href']\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend","def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape_table(page)\n next_link = page.at_css('a.next')\n if next_link \n puts next_link\n next_url = BASE_URL + next_link['href']\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend","def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape_table(page)\n next_link = page.at_css('a.next')\n if next_link \n puts next_link\n next_url = BASE_URL + next_link['href']\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend","def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape_table(page)\n next_link = page.at_css('a.next')\n if next_link \n puts next_link\n next_url = BASE_URL + next_link['href']\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend","def next_page\n @links['next']\n end","def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape_table(page)\n if page.css(\"p.stdPager a\").last.content.include? \"Succ\"\n next_link = page.css(\"p.stdPager a\").last[\"href\"]\n end\n if next_link \n puts \"next link= \" + next_link\n next_url = DOMAIN + next_link\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend","def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape_table(page)\n if page.css(\"p.stdPager a\").last.content.include? \"Succ\"\n next_link = page.css(\"p.stdPager a\").last[\"href\"]\n end\n if next_link \n puts \"next link= \" + next_link\n next_url = DOMAIN + next_link\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend","def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape_table(page)\n if page.css(\"p.stdPager a\").last.content.include? \"Succ\"\n next_link = page.css(\"p.stdPager a\").last[\"href\"]\n end\n if next_link \n puts \"next link= \" + next_link\n next_url = DOMAIN + next_link\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend","def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape_table(page)\n if page.css(\"p.stdPager a\").last.content.include? \"Succ\"\n next_link = page.css(\"p.stdPager a\").last[\"href\"]\n end\n if next_link \n puts \"next link= \" + next_link\n next_url = DOMAIN + next_link\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend","def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape_table(page)\n next_link = page.at_css('a.next')\n if next_link \n p next_link\n next_url = BASE_URL + next_link['href']\n p next_url\n scrape_and_look_for_next_link(next_url)\n end\nend","def get_next()\n\t\t\treturn @next\n\t\tend","def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape(url)\n next_link = page.xpath(\".//a[@title='Go to next page']\")\n puts next_link\n if next_link && next_link[0]\n puts next_link[0]['href']\n next_url = BASE_URL + next_link[0]['href']\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend","def scrape_and_look_for_next_link(url)\n page = Nokogiri::HTML(open(url))\n scrape(url)\n next_link = page.xpath(\".//a[@title='Go to next page']\")\n puts next_link\n if next_link && next_link[0]\n puts next_link[0]['href']\n next_url = BASE_URL + next_link[0]['href']\n puts next_url\n scrape_and_look_for_next_link(next_url)\n end\nend","def next_link(headers)\n key = 'link' # todo: can be 'Link' as well\n return nil unless headers.member? key\n link_tuple = LinkHeader.parse(headers[key]).links.select { |l| l.attr_pairs[0][1] == 'next' }\n link_tuple.size.zero? ? nil : link_tuple[0].href\n end","def next\n @next\n end","def next_sibling\n return @links[:next_sibling]\n end","def get_next_page\n nextlink = @doc.search(\"//p[@class='nextprev']/a[@rel='nofollow next']\")\n nextlink.map! { |link| \"#{link['href']}\" }\n stringlink = nextlink[0]\n @doc = open(stringlink) { |f| Hpricot(f) }\n get_links\n end","def get_next_target(page)\n start_link = page.index(' ?\", id).first\n next_listing\n else\n Listing.first\n end\n end","def next\n @links.key?(:next) ? Page.new(@links[:next], {}, @headers) : nil\n end","def next_item\n index = self.simple_acts_as_list_scope.index(self)\n self.simple_acts_as_list_scope[index + 1]\n end","def get_next_url\n @index = @index + 1\n link = @url.to_s + \"?PageNumber=\"\n link = link + @index.to_s\n \n return link\nend","def get_next_url\n @index = @index + 1\n link = @url.to_s + \"?PageNumber=\"\n link = link + @index.to_s\n \n return link\nend","def get_next\n _info = self.get_next_list_entry!\n unless _info.nil?\n _url = _info[0]\n _imgurl = self.get_image_url _url\n unless _imgurl.nil?\n _filename = self.dl_image _imgurl\n return {\n 'filename' => _filename,\n 'author' => _info[1],\n 'title' => _info[2],\n 'origin' => _url\n }\n end\n end\n return nil\n end","def next_item\n @current += 1 if @current < last\n\n items\n end","def next\n @next && @next.value\n end","def next_page\n @page.link_with(:text => /Next/)\n end","def find_next(*args)\n find(:next, *args)\n end","def find_next(*args)\n find(:next, *args)\n end","def next\n connection.write(\"next\")\n end","def next\n connection.write(\"next\")\n end","def next\n\t\t@curItem.where(\"id > ?\", id).order(\"id ASC\").first || @curItem.first\n\t\t@curItem.show\n\tend","def get_next_url\n\n @index = @index + 1\n\n link = @url.to_s + \"?PageNumber=\"\n\n link = link + @index.to_s\n\n return link\n\nend","def get_next_url\n\n @index = @index + 1\n\n link = @url.to_s + \"?PageNumber=\"\n\n link = link + @index.to_s\n\n return link\n\nend","def get_next_list_entry!\n begin \n # Read out every line of list file\n # into an array\n full_file = []\n File.open(@list_file, 'r') do |file|\n while _line = file.gets\n unless _line == '' || _line.start_with?('#')\n full_file << _line.sub(/\\n/, '')\n end\n end\n end\n # If the array is not empty, shift the first\n # entry into an output variable and save the\n # shifted array in the file by overwriting.\n # Then, return the output variable\n if !full_file.empty?\n _out = full_file.shift.split('|')\n File.open(@list_file, 'w') do |file|\n full_file.each { |ln| \n file.puts ln \n }\n end\n return _out\n end\n return nil\n rescue Exception => e\n puts \"[FATAL ERROR] in 'DavidGetter#get_next_list_entry': #{e}\"\n exit\n end\n end","def next\n @next ||= WikiContent::Version.\n reorder('version ASC').\n includes(:author).\n where(\"wiki_content_id = ? AND version > ?\", wiki_content_id, version).first\n end","def next\n perform_request(next_page_uri) if next?\n end","def next\n @next ||= Changeset.where([\"id > ? AND repository_id = ?\", id, repository_id]).order('id ASC').first\n end","def next\n @next ||=\n if next_uri\n node_cache.fetch(next_uri) do\n node = self.class.new(node_cache, next_uri, adapter, graph)\n node.prev = self\n node\n end\n end\n end","def get_next_url\n while true\n unless url = @node_manager.dequeue_url\n # there are currently no further URLs in the queue\n return nil\n end\n\n unless http_url = HttpUrl.parse(url)\n @node_manager.log_error :invalid_url, url.inspect \n next\n end\n\n if @node_manager.has_file?(http_url.to_filename) \n @node_manager.log :skip_url__already_fetched, url.inspect\n next\n end\n\n return http_url\n end # while\n end","def updateNextURI\n # Parse next result page link from the currently marked one\n nextPagePath = @currentPage.at_css(\"table#nav tr td.cur\").next_sibling().at_css(\"a\")['href']\n\n # Construct the URI\n @nextURI = \"https://www.google.com\" + nextPagePath\n end","def next\n goto(@current_page + 1)\n end","def next\n return nil unless has_next?\n perform_request(next_page_uri)\n end","def next\n self.next_id == -1 ? nil : self.story.cards.find(self.next_id)\n end","def next\n\t\tend","def next_page\n @current_page = @agent.page.links.find { |l| l.text == \"Next →\" }.click\n rescue\n nil\n end","def next\n @pointer += 1\n end","def next\n Photo.find_by_id(next_id) if next?\n end","def get_next_link(index, toc_lines)\n\n max_index = toc_lines.length - 1\n (index..max_index).each do |i|\n search = toc_lines[i].scan(/\\[[^\\(]*\\]\\(([^\\[]*?)\\)/m)\n unless search.empty?\n return search[0][0]\n end\n end\n\n # if you get here no match was found\n ''\n end","def next\n next? ? @current + 1 : nil\n end","def next_page_path(response)\n response.get(\"_links.next.href\")\n end","def get_next_page_url(first_page_doc)\n first_page_doc.css('span.paging:first-of-type a:last-of-type').first['href']\nend","def get_next_url\n while true\n unless url = dequeue_url()\n # there are currently no further URLs in the queue\n return nil\n end\n\n unless http_url = HttpUrl.parse(url)\n log_error :invalid_url, url.inspect \n next\n end\n\n if has_file?(http_url.to_filename) \n log :skip_url__already_fetched, url.inspect\n next\n end\n\n return http_url\n end # while\n end","def next\n end","def next\n end","def get_next_page page\n link = page.search('.nextpostslink').first\n\n begin\n unless link[:href].nil? \n return @agent.get(link[:href])\n end\n rescue\n end\n\n return nil\nend","def get_next_page page\n link = page.search('.nextpostslink').first\n\n begin\n unless link[:href].nil? \n return @agent.get(link[:href])\n end\n rescue\n end\n\n return nil\nend","def get_next_page page\n link = page.search('.nextpostslink').first\n\n begin\n unless link[:href].nil? \n return @agent.get(link[:href])\n end\n rescue\n end\n\n return nil\nend","def get_next_page page\n link = page.search('.nextpostslink').first\n\n begin\n unless link[:href].nil? \n return @agent.get(link[:href])\n end\n rescue\n end\n\n return nil\nend","def scrape_and_look_for_next_link(page)\n scrape_table(page.body)\n link = page.link_with(:text => '2')\n if link\n page.form_with(:name => 'aspnetForm') do |f|\n f['__EVENTTARGET'] = 'ctl00$ContentPlaceHolder1$tab21$GVProcesos'\n f['__EVENTARGUMENT'] = 'Page$2'\n page = f.submit()\n p page.body\n end\n scrape_and_look_for_next_link(page)\n end\nend","def scrape_and_look_for_next_link(page)\n scrape_table(page.body)\n link = page.link_with(:text => '2')\n if link\n page.form_with(:name => 'aspnetForm') do |f|\n f['__EVENTTARGET'] = 'ctl00$ContentPlaceHolder1$tab21$GVProcesos'\n f['__EVENTARGUMENT'] = 'Page$2'\n page = f.submit()\n p page.body\n end\n scrape_and_look_for_next_link(page)\n end\nend","def nextResults\n # Update results\n updateResults(@nextURI)\n\n # Update nextURI\n updateNextURI\n end","def scrape_and_look_for_next_link(page)\n scrape_table(page.body)\n link = page.link_with(:text => '2')\n if link\n page.form_with(:name => 'aspnetForm') do |f|\n f['__EVENTTARGET'] = 'ctl00$ContentPlaceHolder1$tab21$GVProcesos'\n f['__EVENTARGUMENT'] = 'Page$2'\n page = f.submit()\n p page.body\n end\n scrape_and_look_for_next_link(page)\n end\nend","def scrape_and_look_for_next_link(page)\n scrape_table(page.body)\n link = page.link_with(:text => '2')\n if link\n page.form_with(:name => 'aspnetForm') do |f|\n f['__EVENTTARGET'] = 'ctl00$ContentPlaceHolder1$tab21$GVProcesos'\n f['__EVENTARGUMENT'] = 'Page$2'\n page = f.submit()\n p page.body\n end\n scrape_and_look_for_next_link(page)\n end\nend","def next\n \t\tNote.where([\"id > ?\", self.id]).first\n\tend","def next\n\t\t\t\t@index += 1\n\t\t\t\tself._update\n\t\t\t\tself\n\t\t\tend","def has_next?\n !!@links['next']\n end","def next\n if self.last?\n first_in_section\n else lower_item\n end\n end","def next_element\n validates_possibility_of :next\n self.index += 1\n self.current\n end","def crawlNext(&blk)\r\n if @toCrawl.empty?\r\n return false\r\n end\r\n crawlThis=@toCrawl.pop()\r\n crawlOne(crawlThis,&blk)\r\n return true\r\n end","def get_next_page(page)\n\n # Todo: Put your code here to get the next page to be scraped\n\n next_page_condition = page.search('input[id$=nextPageHyperLink]')\n\n if !next_page_condition.empty? \n\n link = get_next_url()\n\n page = @agent.get(link)\n\n return page\n\n else\n\n return nil\n\n end\n\nend","def get_next_page(page)\n\n # Todo: Put your code here to get the next page to be scraped\n\n next_page_condition = page.search('input[id$=nextPageHyperLink]')\n\n if !next_page_condition.empty? \n\n link = get_next_url()\n\n page = @agent.get(link)\n\n return page\n\n else\n\n return nil\n\n end\n\nend","def next\n \tself.class.where(\"id > ?\", id).first\n \tend","def test_next\n\t\tassert_equal(6, @freeid.next, \"Extras not working\")\n\t\tassert_equal(1, @freeid.next, \"Last not working\")\n\t\tassert_equal(2, @freeid.next, \"Last not incrementing\")\n\tend","def next\n after.first\n end","def next\n at(position + 1)\n end","def check_next(products_page)\n xnext = \"//td[@align='right']/strong/a[contains(text(), 'Следующие')]/@href\"\n next_url = products_page.xpath(xnext).text\n next_products_page_url = if next_url != ''\n URL + '/' + next_url\n end || false\n next_products_page_url\n end","def next\n return @page + 1\n end"],"string":"[\n \"def next\\n perform_get(links.next, self.class)\\n end\",\n \"def next_item\\n return nil if @link == nil\\n link.kernel.select {|item| item.rule == @rule}.first\\n end\",\n \"def next_address\\n list_entry[:next]\\n end\",\n \"def scrape_and_look_for_next_link(url)\\n page = Nokogiri::HTML(open(url))\\n scrape(page)\\n next_link = page.at_css('a.next')\\n if next_link \\n p next_link\\n next_url = BASE_URL + next_link['href']\\n p next_url\\n scrape_and_look_for_next_link(next_url)\\n end\\nend\",\n \"def scrape_and_look_for_next_link(url)\\n page = Nokogiri::HTML(open(url))\\n scrape(page)\\n next_link = page.at_css('a.next')\\n if next_link \\n p next_link\\n next_url = BASE_URL + next_link['href']\\n p next_url\\n scrape_and_look_for_next_link(next_url)\\n end\\nend\",\n \"def next_list\\n @_next ? @resource.list(abs_url: @_next) : nil\\n end\",\n \"def scrape_and_look_for_next_link(url)\\n page = Nokogiri::HTML(open(url))\\n\\n ## debugging note to the console\\n puts 'scraping: '+url\\n\\n scrape_table(page)\\n next_link = page.at_css('li.next')\\n if next_link\\n next_url = BASE_URL + next_link.at_css('a').attribute(\\\"href\\\")\\n scrape_and_look_for_next_link(next_url)\\n end\\nend\",\n \"def scrape_and_look_for_next_link(url)\\n page = Nokogiri::HTML(open(url))\\n\\n ## debugging note to the console\\n puts 'scraping: '+url\\n\\n scrape_table(page)\\n next_link = page.at_css('li.next')\\n if next_link\\n next_url = BASE_URL + next_link.at_css('a').attribute(\\\"href\\\")\\n scrape_and_look_for_next_link(next_url)\\n end\\nend\",\n \"def scrape_and_look_for_next_link(url)\\n page = Nokogiri::HTML(open(url))\\n scrape_table(page)\\n next_link = page.at_css('a.next')\\n if next_link \\n puts next_link\\n next_url = BASE_URL + next_link['href']\\n puts next_url\\n scrape_and_look_for_next_link(next_url)\\n end\\nend\",\n \"def scrape_and_look_for_next_link(url)\\n page = Nokogiri::HTML(open(url))\\n scrape_table(page)\\n next_link = page.at_css('a.next')\\n if next_link \\n puts next_link\\n next_url = BASE_URL + next_link['href']\\n puts next_url\\n scrape_and_look_for_next_link(next_url)\\n end\\nend\",\n \"def scrape_and_look_for_next_link(url)\\n page = Nokogiri::HTML(open(url))\\n scrape_table(page)\\n next_link = page.at_css('a.next')\\n if next_link \\n puts next_link\\n next_url = BASE_URL + next_link['href']\\n puts next_url\\n scrape_and_look_for_next_link(next_url)\\n end\\nend\",\n \"def scrape_and_look_for_next_link(url)\\n page = Nokogiri::HTML(open(url))\\n scrape_table(page)\\n next_link = page.at_css('a.next')\\n if next_link \\n puts next_link\\n next_url = BASE_URL + next_link['href']\\n puts next_url\\n scrape_and_look_for_next_link(next_url)\\n end\\nend\",\n \"def next_page\\n @links['next']\\n end\",\n \"def scrape_and_look_for_next_link(url)\\n page = Nokogiri::HTML(open(url))\\n scrape_table(page)\\n if page.css(\\\"p.stdPager a\\\").last.content.include? \\\"Succ\\\"\\n next_link = page.css(\\\"p.stdPager a\\\").last[\\\"href\\\"]\\n end\\n if next_link \\n puts \\\"next link= \\\" + next_link\\n next_url = DOMAIN + next_link\\n puts next_url\\n scrape_and_look_for_next_link(next_url)\\n end\\nend\",\n \"def scrape_and_look_for_next_link(url)\\n page = Nokogiri::HTML(open(url))\\n scrape_table(page)\\n if page.css(\\\"p.stdPager a\\\").last.content.include? \\\"Succ\\\"\\n next_link = page.css(\\\"p.stdPager a\\\").last[\\\"href\\\"]\\n end\\n if next_link \\n puts \\\"next link= \\\" + next_link\\n next_url = DOMAIN + next_link\\n puts next_url\\n scrape_and_look_for_next_link(next_url)\\n end\\nend\",\n \"def scrape_and_look_for_next_link(url)\\n page = Nokogiri::HTML(open(url))\\n scrape_table(page)\\n if page.css(\\\"p.stdPager a\\\").last.content.include? \\\"Succ\\\"\\n next_link = page.css(\\\"p.stdPager a\\\").last[\\\"href\\\"]\\n end\\n if next_link \\n puts \\\"next link= \\\" + next_link\\n next_url = DOMAIN + next_link\\n puts next_url\\n scrape_and_look_for_next_link(next_url)\\n end\\nend\",\n \"def scrape_and_look_for_next_link(url)\\n page = Nokogiri::HTML(open(url))\\n scrape_table(page)\\n if page.css(\\\"p.stdPager a\\\").last.content.include? \\\"Succ\\\"\\n next_link = page.css(\\\"p.stdPager a\\\").last[\\\"href\\\"]\\n end\\n if next_link \\n puts \\\"next link= \\\" + next_link\\n next_url = DOMAIN + next_link\\n puts next_url\\n scrape_and_look_for_next_link(next_url)\\n end\\nend\",\n \"def scrape_and_look_for_next_link(url)\\n page = Nokogiri::HTML(open(url))\\n scrape_table(page)\\n next_link = page.at_css('a.next')\\n if next_link \\n p next_link\\n next_url = BASE_URL + next_link['href']\\n p next_url\\n scrape_and_look_for_next_link(next_url)\\n end\\nend\",\n \"def get_next()\\n\\t\\t\\treturn @next\\n\\t\\tend\",\n \"def scrape_and_look_for_next_link(url)\\n page = Nokogiri::HTML(open(url))\\n scrape(url)\\n next_link = page.xpath(\\\".//a[@title='Go to next page']\\\")\\n puts next_link\\n if next_link && next_link[0]\\n puts next_link[0]['href']\\n next_url = BASE_URL + next_link[0]['href']\\n puts next_url\\n scrape_and_look_for_next_link(next_url)\\n end\\nend\",\n \"def scrape_and_look_for_next_link(url)\\n page = Nokogiri::HTML(open(url))\\n scrape(url)\\n next_link = page.xpath(\\\".//a[@title='Go to next page']\\\")\\n puts next_link\\n if next_link && next_link[0]\\n puts next_link[0]['href']\\n next_url = BASE_URL + next_link[0]['href']\\n puts next_url\\n scrape_and_look_for_next_link(next_url)\\n end\\nend\",\n \"def next_link(headers)\\n key = 'link' # todo: can be 'Link' as well\\n return nil unless headers.member? key\\n link_tuple = LinkHeader.parse(headers[key]).links.select { |l| l.attr_pairs[0][1] == 'next' }\\n link_tuple.size.zero? ? nil : link_tuple[0].href\\n end\",\n \"def next\\n @next\\n end\",\n \"def next_sibling\\n return @links[:next_sibling]\\n end\",\n \"def get_next_page\\n nextlink = @doc.search(\\\"//p[@class='nextprev']/a[@rel='nofollow next']\\\")\\n nextlink.map! { |link| \\\"#{link['href']}\\\" }\\n stringlink = nextlink[0]\\n @doc = open(stringlink) { |f| Hpricot(f) }\\n get_links\\n end\",\n \"def get_next_target(page)\\n start_link = page.index(' ?\\\", id).first\\n next_listing\\n else\\n Listing.first\\n end\\n end\",\n \"def next\\n @links.key?(:next) ? Page.new(@links[:next], {}, @headers) : nil\\n end\",\n \"def next_item\\n index = self.simple_acts_as_list_scope.index(self)\\n self.simple_acts_as_list_scope[index + 1]\\n end\",\n \"def get_next_url\\n @index = @index + 1\\n link = @url.to_s + \\\"?PageNumber=\\\"\\n link = link + @index.to_s\\n \\n return link\\nend\",\n \"def get_next_url\\n @index = @index + 1\\n link = @url.to_s + \\\"?PageNumber=\\\"\\n link = link + @index.to_s\\n \\n return link\\nend\",\n \"def get_next\\n _info = self.get_next_list_entry!\\n unless _info.nil?\\n _url = _info[0]\\n _imgurl = self.get_image_url _url\\n unless _imgurl.nil?\\n _filename = self.dl_image _imgurl\\n return {\\n 'filename' => _filename,\\n 'author' => _info[1],\\n 'title' => _info[2],\\n 'origin' => _url\\n }\\n end\\n end\\n return nil\\n end\",\n \"def next_item\\n @current += 1 if @current < last\\n\\n items\\n end\",\n \"def next\\n @next && @next.value\\n end\",\n \"def next_page\\n @page.link_with(:text => /Next/)\\n end\",\n \"def find_next(*args)\\n find(:next, *args)\\n end\",\n \"def find_next(*args)\\n find(:next, *args)\\n end\",\n \"def next\\n connection.write(\\\"next\\\")\\n end\",\n \"def next\\n connection.write(\\\"next\\\")\\n end\",\n \"def next\\n\\t\\t@curItem.where(\\\"id > ?\\\", id).order(\\\"id ASC\\\").first || @curItem.first\\n\\t\\t@curItem.show\\n\\tend\",\n \"def get_next_url\\n\\n @index = @index + 1\\n\\n link = @url.to_s + \\\"?PageNumber=\\\"\\n\\n link = link + @index.to_s\\n\\n return link\\n\\nend\",\n \"def get_next_url\\n\\n @index = @index + 1\\n\\n link = @url.to_s + \\\"?PageNumber=\\\"\\n\\n link = link + @index.to_s\\n\\n return link\\n\\nend\",\n \"def get_next_list_entry!\\n begin \\n # Read out every line of list file\\n # into an array\\n full_file = []\\n File.open(@list_file, 'r') do |file|\\n while _line = file.gets\\n unless _line == '' || _line.start_with?('#')\\n full_file << _line.sub(/\\\\n/, '')\\n end\\n end\\n end\\n # If the array is not empty, shift the first\\n # entry into an output variable and save the\\n # shifted array in the file by overwriting.\\n # Then, return the output variable\\n if !full_file.empty?\\n _out = full_file.shift.split('|')\\n File.open(@list_file, 'w') do |file|\\n full_file.each { |ln| \\n file.puts ln \\n }\\n end\\n return _out\\n end\\n return nil\\n rescue Exception => e\\n puts \\\"[FATAL ERROR] in 'DavidGetter#get_next_list_entry': #{e}\\\"\\n exit\\n end\\n end\",\n \"def next\\n @next ||= WikiContent::Version.\\n reorder('version ASC').\\n includes(:author).\\n where(\\\"wiki_content_id = ? AND version > ?\\\", wiki_content_id, version).first\\n end\",\n \"def next\\n perform_request(next_page_uri) if next?\\n end\",\n \"def next\\n @next ||= Changeset.where([\\\"id > ? AND repository_id = ?\\\", id, repository_id]).order('id ASC').first\\n end\",\n \"def next\\n @next ||=\\n if next_uri\\n node_cache.fetch(next_uri) do\\n node = self.class.new(node_cache, next_uri, adapter, graph)\\n node.prev = self\\n node\\n end\\n end\\n end\",\n \"def get_next_url\\n while true\\n unless url = @node_manager.dequeue_url\\n # there are currently no further URLs in the queue\\n return nil\\n end\\n\\n unless http_url = HttpUrl.parse(url)\\n @node_manager.log_error :invalid_url, url.inspect \\n next\\n end\\n\\n if @node_manager.has_file?(http_url.to_filename) \\n @node_manager.log :skip_url__already_fetched, url.inspect\\n next\\n end\\n\\n return http_url\\n end # while\\n end\",\n \"def updateNextURI\\n # Parse next result page link from the currently marked one\\n nextPagePath = @currentPage.at_css(\\\"table#nav tr td.cur\\\").next_sibling().at_css(\\\"a\\\")['href']\\n\\n # Construct the URI\\n @nextURI = \\\"https://www.google.com\\\" + nextPagePath\\n end\",\n \"def next\\n goto(@current_page + 1)\\n end\",\n \"def next\\n return nil unless has_next?\\n perform_request(next_page_uri)\\n end\",\n \"def next\\n self.next_id == -1 ? nil : self.story.cards.find(self.next_id)\\n end\",\n \"def next\\n\\t\\tend\",\n \"def next_page\\n @current_page = @agent.page.links.find { |l| l.text == \\\"Next →\\\" }.click\\n rescue\\n nil\\n end\",\n \"def next\\n @pointer += 1\\n end\",\n \"def next\\n Photo.find_by_id(next_id) if next?\\n end\",\n \"def get_next_link(index, toc_lines)\\n\\n max_index = toc_lines.length - 1\\n (index..max_index).each do |i|\\n search = toc_lines[i].scan(/\\\\[[^\\\\(]*\\\\]\\\\(([^\\\\[]*?)\\\\)/m)\\n unless search.empty?\\n return search[0][0]\\n end\\n end\\n\\n # if you get here no match was found\\n ''\\n end\",\n \"def next\\n next? ? @current + 1 : nil\\n end\",\n \"def next_page_path(response)\\n response.get(\\\"_links.next.href\\\")\\n end\",\n \"def get_next_page_url(first_page_doc)\\n first_page_doc.css('span.paging:first-of-type a:last-of-type').first['href']\\nend\",\n \"def get_next_url\\n while true\\n unless url = dequeue_url()\\n # there are currently no further URLs in the queue\\n return nil\\n end\\n\\n unless http_url = HttpUrl.parse(url)\\n log_error :invalid_url, url.inspect \\n next\\n end\\n\\n if has_file?(http_url.to_filename) \\n log :skip_url__already_fetched, url.inspect\\n next\\n end\\n\\n return http_url\\n end # while\\n end\",\n \"def next\\n end\",\n \"def next\\n end\",\n \"def get_next_page page\\n link = page.search('.nextpostslink').first\\n\\n begin\\n unless link[:href].nil? \\n return @agent.get(link[:href])\\n end\\n rescue\\n end\\n\\n return nil\\nend\",\n \"def get_next_page page\\n link = page.search('.nextpostslink').first\\n\\n begin\\n unless link[:href].nil? \\n return @agent.get(link[:href])\\n end\\n rescue\\n end\\n\\n return nil\\nend\",\n \"def get_next_page page\\n link = page.search('.nextpostslink').first\\n\\n begin\\n unless link[:href].nil? \\n return @agent.get(link[:href])\\n end\\n rescue\\n end\\n\\n return nil\\nend\",\n \"def get_next_page page\\n link = page.search('.nextpostslink').first\\n\\n begin\\n unless link[:href].nil? \\n return @agent.get(link[:href])\\n end\\n rescue\\n end\\n\\n return nil\\nend\",\n \"def scrape_and_look_for_next_link(page)\\n scrape_table(page.body)\\n link = page.link_with(:text => '2')\\n if link\\n page.form_with(:name => 'aspnetForm') do |f|\\n f['__EVENTTARGET'] = 'ctl00$ContentPlaceHolder1$tab21$GVProcesos'\\n f['__EVENTARGUMENT'] = 'Page$2'\\n page = f.submit()\\n p page.body\\n end\\n scrape_and_look_for_next_link(page)\\n end\\nend\",\n \"def scrape_and_look_for_next_link(page)\\n scrape_table(page.body)\\n link = page.link_with(:text => '2')\\n if link\\n page.form_with(:name => 'aspnetForm') do |f|\\n f['__EVENTTARGET'] = 'ctl00$ContentPlaceHolder1$tab21$GVProcesos'\\n f['__EVENTARGUMENT'] = 'Page$2'\\n page = f.submit()\\n p page.body\\n end\\n scrape_and_look_for_next_link(page)\\n end\\nend\",\n \"def nextResults\\n # Update results\\n updateResults(@nextURI)\\n\\n # Update nextURI\\n updateNextURI\\n end\",\n \"def scrape_and_look_for_next_link(page)\\n scrape_table(page.body)\\n link = page.link_with(:text => '2')\\n if link\\n page.form_with(:name => 'aspnetForm') do |f|\\n f['__EVENTTARGET'] = 'ctl00$ContentPlaceHolder1$tab21$GVProcesos'\\n f['__EVENTARGUMENT'] = 'Page$2'\\n page = f.submit()\\n p page.body\\n end\\n scrape_and_look_for_next_link(page)\\n end\\nend\",\n \"def scrape_and_look_for_next_link(page)\\n scrape_table(page.body)\\n link = page.link_with(:text => '2')\\n if link\\n page.form_with(:name => 'aspnetForm') do |f|\\n f['__EVENTTARGET'] = 'ctl00$ContentPlaceHolder1$tab21$GVProcesos'\\n f['__EVENTARGUMENT'] = 'Page$2'\\n page = f.submit()\\n p page.body\\n end\\n scrape_and_look_for_next_link(page)\\n end\\nend\",\n \"def next\\n \\t\\tNote.where([\\\"id > ?\\\", self.id]).first\\n\\tend\",\n \"def next\\n\\t\\t\\t\\t@index += 1\\n\\t\\t\\t\\tself._update\\n\\t\\t\\t\\tself\\n\\t\\t\\tend\",\n \"def has_next?\\n !!@links['next']\\n end\",\n \"def next\\n if self.last?\\n first_in_section\\n else lower_item\\n end\\n end\",\n \"def next_element\\n validates_possibility_of :next\\n self.index += 1\\n self.current\\n end\",\n \"def crawlNext(&blk)\\r\\n if @toCrawl.empty?\\r\\n return false\\r\\n end\\r\\n crawlThis=@toCrawl.pop()\\r\\n crawlOne(crawlThis,&blk)\\r\\n return true\\r\\n end\",\n \"def get_next_page(page)\\n\\n # Todo: Put your code here to get the next page to be scraped\\n\\n next_page_condition = page.search('input[id$=nextPageHyperLink]')\\n\\n if !next_page_condition.empty? \\n\\n link = get_next_url()\\n\\n page = @agent.get(link)\\n\\n return page\\n\\n else\\n\\n return nil\\n\\n end\\n\\nend\",\n \"def get_next_page(page)\\n\\n # Todo: Put your code here to get the next page to be scraped\\n\\n next_page_condition = page.search('input[id$=nextPageHyperLink]')\\n\\n if !next_page_condition.empty? \\n\\n link = get_next_url()\\n\\n page = @agent.get(link)\\n\\n return page\\n\\n else\\n\\n return nil\\n\\n end\\n\\nend\",\n \"def next\\n \\tself.class.where(\\\"id > ?\\\", id).first\\n \\tend\",\n \"def test_next\\n\\t\\tassert_equal(6, @freeid.next, \\\"Extras not working\\\")\\n\\t\\tassert_equal(1, @freeid.next, \\\"Last not working\\\")\\n\\t\\tassert_equal(2, @freeid.next, \\\"Last not incrementing\\\")\\n\\tend\",\n \"def next\\n after.first\\n end\",\n \"def next\\n at(position + 1)\\n end\",\n \"def check_next(products_page)\\n xnext = \\\"//td[@align='right']/strong/a[contains(text(), 'Следующие')]/@href\\\"\\n next_url = products_page.xpath(xnext).text\\n next_products_page_url = if next_url != ''\\n URL + '/' + next_url\\n end || false\\n next_products_page_url\\n end\",\n \"def next\\n return @page + 1\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.76924497","0.7587537","0.7422341","0.7188903","0.7188903","0.71803594","0.71423864","0.71423864","0.71327865","0.71327865","0.71327865","0.71327865","0.7115808","0.7076858","0.7075121","0.7075121","0.7075121","0.7065827","0.7035438","0.69852316","0.69852316","0.6871616","0.68600816","0.6852011","0.6794819","0.67830044","0.67446786","0.6742262","0.6738502","0.6726795","0.6693582","0.66428375","0.66304255","0.66258305","0.6622428","0.65780723","0.6576499","0.6576499","0.6546826","0.65390795","0.6537929","0.65212363","0.65059495","0.65034","0.6494419","0.6494419","0.648266","0.6473187","0.64401054","0.6433362","0.64201695","0.64201695","0.64042014","0.64042014","0.638998","0.6389119","0.6389119","0.63677865","0.633887","0.6334604","0.6325269","0.6309682","0.62990355","0.6297091","0.62877035","0.62486136","0.62367177","0.6225417","0.62233895","0.6222457","0.62145174","0.61867106","0.6185187","0.6179215","0.6166781","0.61655605","0.61648023","0.61648023","0.6157173","0.6157173","0.6157173","0.6157173","0.61547226","0.61547226","0.6153562","0.61523014","0.61523014","0.6145139","0.61403567","0.61338353","0.6128745","0.61275303","0.61160016","0.61131513","0.61131513","0.61131024","0.6108339","0.6106686","0.61034715","0.6089053","0.6084781"],"string":"[\n \"0.76924497\",\n \"0.7587537\",\n \"0.7422341\",\n \"0.7188903\",\n \"0.7188903\",\n \"0.71803594\",\n \"0.71423864\",\n \"0.71423864\",\n \"0.71327865\",\n \"0.71327865\",\n \"0.71327865\",\n \"0.71327865\",\n \"0.7115808\",\n \"0.7076858\",\n \"0.7075121\",\n \"0.7075121\",\n \"0.7075121\",\n \"0.7065827\",\n \"0.7035438\",\n \"0.69852316\",\n \"0.69852316\",\n \"0.6871616\",\n \"0.68600816\",\n \"0.6852011\",\n \"0.6794819\",\n \"0.67830044\",\n \"0.67446786\",\n \"0.6742262\",\n \"0.6738502\",\n \"0.6726795\",\n \"0.6693582\",\n \"0.66428375\",\n \"0.66304255\",\n \"0.66258305\",\n \"0.6622428\",\n \"0.65780723\",\n \"0.6576499\",\n \"0.6576499\",\n \"0.6546826\",\n \"0.65390795\",\n \"0.6537929\",\n \"0.65212363\",\n \"0.65059495\",\n \"0.65034\",\n \"0.6494419\",\n \"0.6494419\",\n \"0.648266\",\n \"0.6473187\",\n \"0.64401054\",\n \"0.6433362\",\n \"0.64201695\",\n \"0.64201695\",\n \"0.64042014\",\n \"0.64042014\",\n \"0.638998\",\n \"0.6389119\",\n \"0.6389119\",\n \"0.63677865\",\n \"0.633887\",\n \"0.6334604\",\n \"0.6325269\",\n \"0.6309682\",\n \"0.62990355\",\n \"0.6297091\",\n \"0.62877035\",\n \"0.62486136\",\n \"0.62367177\",\n \"0.6225417\",\n \"0.62233895\",\n \"0.6222457\",\n \"0.62145174\",\n \"0.61867106\",\n \"0.6185187\",\n \"0.6179215\",\n \"0.6166781\",\n \"0.61655605\",\n \"0.61648023\",\n \"0.61648023\",\n \"0.6157173\",\n \"0.6157173\",\n \"0.6157173\",\n \"0.6157173\",\n \"0.61547226\",\n \"0.61547226\",\n \"0.6153562\",\n \"0.61523014\",\n \"0.61523014\",\n \"0.6145139\",\n \"0.61403567\",\n \"0.61338353\",\n \"0.6128745\",\n \"0.61275303\",\n \"0.61160016\",\n \"0.61131513\",\n \"0.61131513\",\n \"0.61131024\",\n \"0.6108339\",\n \"0.6106686\",\n \"0.61034715\",\n \"0.6089053\",\n \"0.6084781\"\n]"},"document_score":{"kind":"string","value":"0.0"},"document_rank":{"kind":"string","value":"-1"}}},{"rowIdx":1883,"cells":{"query":{"kind":"string","value":"move the given link off the main queue and onto the invalid queue"},"document":{"kind":"string","value":"def invalidate(link, *args)\n queued.delete(link.uri)\n\n if not link.suspect\n inv = InvalidURI.new(link, *args)\n invalid[inv.uri] = inv\n elsif @opts[:verbose]\n puts 'questionable link invalidated: ' + link.uri.to_s\n end\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def queue_next\n begin\n link = to_validate.shift\n return if not link\n\n queued[link[0]] = link[1]\n\n link[1].validate(@hydra) { |error: nil|\n queued.delete(link[0])\n\n if error then invalidate(link[1], error[:type], error[:msg])\n else validated[link[0]] = link[1]\n end\n }\n link\n rescue Exception\n unshift(link)\n raise $!\n end\n end","def move_lower_in_queue\n return unless lower_item_in_queue\n\n acts_as_queue_class.transaction do\n lower_item_in_queue.decrement_queue_position\n increment_queue_position\n end\n end","def move_higher_in_queue\n return unless higher_item_in_queue\n\n acts_as_queue_class.transaction do\n higher_item_in_queue.increment_queue_position\n decrement_queue_position\n end\n end","def move_to_bottom_in_queue\n return unless in_queue?\n acts_as_queue_class.transaction do\n decrement_queue_positions_on_lower_items\n assume_bottom_queue_position\n end\n end","def move_to_top_in_queue\n return unless in_queue?\n acts_as_queue_class.transaction do\n increment_queue_positions_on_higher_items\n assume_top_queue_position\n end\n end","def shift()\n # If our ttl is zero, skip\n if @queue.length < 1\n return nil\n end\n # Get next from queue\n this = @queue.shift\n puts \"QUEUE ->: %3d %s\" % [this['ttl'], this['url']]\n # Do we already have this page?\n if ! @store.exists?(this['url'])\n # Get page and read links\n p = Page.new(this['url'], nil, this['ttl'])\n # Add each link to the queue (if it doesn't alreaady exist)\n p.links.each do |l|\n if l['ttl'] > 0 and !@store.exists?(l['href'])\n self.push(l['href'], l['ttl'])\n end\n end\n # Store the links\n @store.add(this['url'], p.links)\n end\n end","def blmove(source, destination, where_source, where_destination, timeout: T.unsafe(nil)); end","def shift\n @lock.synchronize do\n @queue.shift\n end\n end","def queue_video!(video)\n queue_items.create(video: video, \n position: new_queue_item_position) unless queued_video?(video)\n end","def move_later\n nekst = self.next\n self.append_to(nekst) if nekst\n end","def add(link)\n @queue.add link\n end","def queue(a)\n p \"Before: #{a}\"\n a.push(6)\n a.shift(1)\n p \"After: #{a}\"\nend","def move_next\n\t\tself.current = self.current&.next\n\tend","def move_next\n\t\tself.current = self.current&.next\n\tend","def remove_from_queue\n if in_queue?\n decrement_queue_positions_on_lower_items\n update_attribute queue_position_column, nil\n end\n end","def remove\n @queue.shift\n end","def blocking_redirect to, timeout = 0\n brpoplpush(@key, key(:queue)/(to.kind_of?(RedisQueue::Simple) ? to.name : to), timeout)\n end","def shift!\n shifted = @queue.shift\n\n return nil if shifted.nil?\n shifted[0]\n end","def remove\n @queue.shift\n end","def dequeue\n\t\t@queue.shift\n\tend","def update_link!(link)\n key = link.key\n val = link.val\n @store.remove(key)\n link = @store.append(key,val) #this is where you move the link to end of list\n @map[key] = link\n end","def __ap4r_forward_by_queue_info(stored_message_id, queue_info, options)\r\n __ap4r_queue_put(queue_info[:queue_name], queue_info[:queue_message], queue_info[:queue_headers])\r\n StoredMessage.destroy_if_exists(stored_message_id, options)\r\n end","def dequeue\n @queue.shift\n end","def remove\n @queue.shift\n end","def dequeue; @queue.pop end","def queue(link)\n\t\t####binding.pry\n\t\treq = request(link)\n\t\t######binding.pry\n\t\treq.on_complete {|res| \n\t\t\t######binding.pry\n\t\t\thandle_response(req, res)\n\t\t}\n\t\t#####binding.pry\n\t\thydra.queue(req)\n\t\t####binding.pry\n\tend","def _put_back_on_queue(message)\n future = nil\n _redis.multi do\n _redis.rpush(@queue, message)\n future = _redis.lrem(@in_progress_queue, 1, message)\n end\n removed = future.value\n if removed !=1\n RailsPipeline.logger.error \"ERROR: Didn't remove message from in_progress queue?!!!\"\n end\n end","def regress_head\n\t\t\t# @queue[@head_index] = nil\n\t\t\t# @size -= 1 unless @size == 0\n\t\t\t\n\t\t\t# @head_index -= 1\n\t\t\t# @head_index = @queue.size-1 if @head_index < 0\n\t\tend","def queue(_); end","def queue(_); end","def brpoplpush(source, destination, timeout: T.unsafe(nil)); end","def reposition_queue\n task_queue = TaskQueue.where(user_id: user_id, task_type_id: task_type_id)\n if task_queue.pluck(:position).any? {|pos| pos > position}\n task_queue.where(\"position > ?\", position).each do |queue_item|\n queue_item.update(:position => (queue_item.position - 1))\n end\n end\n end","def lmove(source, destination, where_source, where_destination); end","def lmove(source, destination, where_source, where_destination); end","def shift\n return nil if empty?\n @que.shift\n end","def step\n @queue.enq nil\n end","def invalidate_link link\r\n @links.delete(link.condition)\r\n link.detach_and_revert\r\n end","def move\n move_by a, m\n end","def queue_links(links)\n\t\tlinks.each do |link|\n\t\t\tqueue(link)\n\t\tend\n\tend","def pop()\n @size -= 1 \n @queue.shift\n end","def remove!(item)\n @queue.delete(item)\n end","def pop()\n @queue.shift\n end","def queue_link( tag, source )\n return if tag.attributes['class'] && tag.attributes['class']['thickbox'] == 'thickbox'\n return if tag.attributes['onclick']\n dest = (tag.attributes['onclick'] =~ /^new Ajax.Updater\\(['\"].*?['\"], ['\"](.*?)['\"]/i) ? $1 : tag.attributes['href']\n if !(dest =~ %r{^(mailto:|#|javascript:|http://|.*\\.jpg|aim:|ichat:|xmpp:)})\n @links_to_visit << Link.new( dest, source )\n end\n end","def smove(source, destination, member); end","def smove(source, destination, member); end","def move(from, to)\n @tasks.insert(index(to), @tasks.delete_at(index(from)))\n end","def advance_head\n\t\t\t@head_index += 1\n\t\t\t@head_index = 0 if @head_index == @queue.size\n\t\tend","def dequeue\n @q.shift\n end","def dequeue\n @store.shift\n end","def place_link(link, dest, last_link)\n # If there is no dest, we are meant to be \n if dest.nil?\n # If we have no last link, we are alone - and are head\n # and link's prev remains nil\n if last_link.nil?\n self[:head_id] = link.id\n # If we have the last link, we want to be after it\n else\n last_link.next = link\n link.prev = last_link\n end\n # Otherwise, we want to be at dest\n else\n # If dest has no prev, we'll be it's prev and the head\n if dest.prev_id.nil?\n self[:head_id] = link.id\n link.next = dest\n dest.prev = link\n # Otherwise, squeeze our way in\n else\n link.next = dest\n link.prev = dest.prev\n dest.prev = link\n link.prev.next = link\n end\n end\n end","def drop_link\n return @drop_link if @drop_link\n to_link = @to_link\n \n # continue along the road (to_link and further down) as long as\n # no choices must be made between roads\n # (method: more connectors may connect a road to the same downstream road)\n while to_link.outgoing_connectors.map{|conn|conn.to_link}.uniq.size == 1\n to_link = to_link.outgoing_connectors.first.to_link\n end\n @drop_link = to_link\n end","def shift\n deadline = Time.now + @timeout\n\n synchronize do\n loop do\n return @queue.shift unless @queue.empty?\n wait = deadline - Time.now\n raise Timeout::Error, \"Waited for #{@timeout} seconds for connection but none was pushed.\" if wait <= 0\n @cond.wait(wait)\n end\n end\n end","def queue(*items)\n\t\t\t# insert @ tail\n\t\t\t# increment size (if able)\n\t\t\t# check size\n\t\t\t\t# move head if necessary\n\t\t\t# move tail\n\t\t\t\n\t\t\titems.each do |i|\n\t\t\t\t# puts \"head #{@head_index} tail #{@tail_index}\"\n\t\t\t\t\n\t\t\t\t@queue[@tail_index] = i\n\t\t\t\t\n\t\t\t\t@size += 1 unless @size == @queue.size\n\t\t\t\t\n\t\t\t\tif @size == @queue.size\n\t\t\t\t\tadvance_head\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tadvance_tail\n\t\t\tend\n\t\tend","def move(thing, to, check=true)\n item = find(thing)\n dest = find(to)\n\n return if item.nil?\n if check && item.hidden?\n puts \"You can't get to that right now\"\n return\n end\n\n return if dest.nil?\n if check && (dest.hidden? || dest.open == false)\n puts \"You can't put that there\"\n return\n end\n\n if dest.ancestors.include?(item)\n puts \"Are you trying to destroy the universe?\"\n return\n end\n\n item.parent.children.delete(item)\n dest.children << item\n item.parent = dest\n end","def deq\n @queued = false\n nil\n end","def add!(item)\n @queue[item] = item\n end","def move_left\n tenacious_transaction do\n move_to_left_of left_sibling.try(:lock!)\n end\n end","def dequeue\n @items.shift\n end","def complete_order\n @queue.dequeue\n end","def test_move_under_single_lock\n setup_hr\n\n lock = lock 'httplock/hr', :depth => RubyDav::INFINITY\n\n response = @request.move('httplock/hr/recruiting/resumes', 'httplock/hr/archives/resumes')\n assert_equal '423', response.status\n assert_exists 'httplock/hr/recruiting/resumes/'\n assert_does_not_exist 'httplock/hr/archives/resumes/'\n\n if_hdr = lock.token\n response = @request.move('httplock/hr/recruiting/resumes', 'httplock/hr/archives/resumes', false, :if => if_hdr)\n assert_equal '201', response.status\n assert_does_not_exist 'httplock/hr/recruiting/resumes/'\n assert_exists 'httplock/hr/archives/resumes/'\n\n # cleanup\n unlock('httplock/hr', lock.token)\n delete_coll('httplock')\n end","def moveInQueue\n # Don't bother unless the next car has cleared the end of the queue.\n if carAhead && carAhead.tailInQueue\n return false\n end\n\n return false unless @currentLane.meterOK\n\n @bodyStart = 0\n @bodyEnd = @bodyStart - @length\n @nextSpeed = @driver.velocity(self)\n @currentLane.updateMeter\n\n return true\n end","def dequeue\n end","def remove\n if empty?\n raise \"Can't remove if queue is empty\"\n else\n @info.shift\n end\n end","def remove\n if empty?\n raise \"Can't remove if queue is empty\"\n else\n @info.shift\n end\n end","def remove\n if empty?\n raise \"Can't remove if queue is empty\"\n else\n @info.shift\n end\n end","def remove_link(link)\n # If the_link is head, set head to nil\n if self[:head_id] == link.id\n self[:head_id] = link.next_id\n end\n if link.prev\n # If things on both sides, link them\n if link.next\n link.prev.next_id = link.next_id\n link.next.prev_id = link.prev_id \n link.next = nil\n link.prev = nil\n # If no next id, clear prev's next\n else\n link.prev.next_id = nil\n link.prev = nil\n end\n else\n # If no prev id, clear next's prev\n if link.next\n link.next.prev_id = nil\n link.next = nil\n # It none on either side, do nothing\n else\n end\n end\n end","def move_onto(a, b)\n reveal(a)\n reveal(b)\n move_single(a, b)\n end","def watch_movie (queue)\n queue.shift\n queue\nend","def force_queue_to_vimeo\n self.queue_transfer_to_vimeo(true)\n true\n end","def requeue\n __requeue__(\"RPUSH\")\n end","def remove\n @nxt.prv = @prv if @nxt\n @prv.nxt = @nxt if @prv\n end","def enqueue(object_)\n result_ = true\n if @push_ptr\n if @pop_ptr == @push_ptr\n if @drop_oldest\n @pop_ptr += 1\n @pop_ptr = 0 if @pop_ptr == @buffer.size\n result_ = false\n else\n return false\n end\n elsif @pop_ptr.nil?\n @pop_ptr = @push_ptr\n end\n @buffer[@push_ptr] = object_\n @push_ptr += 1\n @push_ptr = 0 if @push_ptr == @buffer.size\n else\n @buffer.push(object_)\n end\n result_\n end","def pop()\n if @queue_out.size == 0 \n if @queue_in.size == 0 \n return \n end\n \n while @queue_in.size > 0 \n @queue_out.push(@queue_in.pop)\n end\n end\n \n @size -= 1\n return @queue_out.pop\n end","def unpop obj\n was_empty = @q.empty?\n case obj\n when SimultaneousQueueEntries\n case obj.size\n when 0\n was_empty = false # just to prevent the inc\n when 1\n @q.unshift obj.first\n else\n @q.unshift obj\n end\n else\n @q.unshift obj\n end\n @component.inc_queue_ready_count if was_empty\n end","def queue_front(request)\n request.hydra = self\n queued_requests.unshift request\n end","def queue; end","def queue; end","def unshift(link)\n if link\n validated.delete(link[0])\n to_validate[link[0]] = link[1]\n end\n end","def remove_from_queue(queue, data)\n prioritized?(queue) ? z_remove_from_queue(queue, data) : super\n end","def move_node_to_head(node) \n removed = remove_node(node)\n\n add_head(removed)\n end","def move; end","def move; end","def move_somewhere(bram, dead_space, astar, params)\n x = bram.head[0]\n y = bram.head[1]\n open_spot = []\n surrounding_cells_within_grid(x, y, params).each do |c|\n next if dead_space.include?(c) # do not under any circumstances move there\n open_spot.push(c)\n return c unless path_is_deadend?(bram, [bram.head, c], astar, dead_space)\n end\n open_spot.first # all are dead-ends so just pick an open spot\nend","def pour_out\n @queue.deq\n end","def place(queen, tile)\r\n tile.leave()\r\n queen.goto( tile, tile )\r\n end","def move(to)\n @moved = true\n super(to)\n end","def shift\n current_node = @head\n @head = current_node.next_node\n end","def pop()\n if @queue_out.size == 0\n if @queue_in.size == 0\n return\n end\n\n while @queue_in.size > 0\n @queue_out.push(@queue_in.pop)\n end\n end\n\n @size -= 1\n return @queue_out.pop\n end","def move!(end_pos)\n board.remove_piece(pos)\n\n if (pos[0] - end_pos[0]).abs == 2\n board.remove_piece(jumped_place(end_pos))\n end\n\n self.pos = end_pos\n board.place_piece(self, end_pos)\n\n maybe_promote\n end","def queue(&b)\n @queue << b\n end","def queue(message); end","def move(from, to, aux, disk_count)\n # base case\n if disk_count == 1 # we're only moving one disc\n disk = from.pop\n check_disk_sizes(disk, to.last)\n to.push(disk)\n print_state\n @step_counter += 1\n return\n end\n\n # otherwise we need to do some flippin aorund\n move(from, aux, to, disk_count - 1)\n move(from, to, aux, 1)\n move(aux, to, from, disk_count - 1)\n end","def pop\n @insert_point -= 1\n if (@insert_point < 0)\n return nil\n end\n check = @items[0]\n\n rc = pop_sync(check)\n new_head = @items[@insert_point]\n new_head.index = 0\n @items[0] = new_head\n @items[@insert_point] = nil\n\n # Rearrange the neighbor nodes and recalculate their attribs\n check.next_link.prev_link = check.prev_link\n check.prev_link.next_link = check.next_link\n check.next_link.recalculate\n check.prev_link.recalculate\n\n # Rearrange the heap\n heapify(0)\n heapify(check.next_link.index)\n heapify(check.prev_link.index)\n\n return rc\n end","def dequeue\n last_el = self.queue_var[-1]\n self.queue_var = self.queue_var[0...-1]\n last_el \n end","def test_orderOfElements\n @queue.enqueue(100)\n @queue.enqueue(200)\n assert_equal( 100, @queue.dequeue )\n assert_equal( 200, @queue.dequeue )\n end","def push_to_queue(queue, item)\n queue.push(item)\nrescue Exception => e\n puts \"Rescued #{e}\"\nend","def delete_front()\n if @queue.size > 0\n @queue.shift\n return true\n end\n false\n end","def remove\n @queue.pop\n end","def enqueue(node)\n #the double arrow means to PUSH the node into our q list\n @q << node\n end","def move!(target)\n @board[@pos] = nil\n @pos = target \n @board[@pos] = self\n true\n end"],"string":"[\n \"def queue_next\\n begin\\n link = to_validate.shift\\n return if not link\\n\\n queued[link[0]] = link[1]\\n\\n link[1].validate(@hydra) { |error: nil|\\n queued.delete(link[0])\\n\\n if error then invalidate(link[1], error[:type], error[:msg])\\n else validated[link[0]] = link[1]\\n end\\n }\\n link\\n rescue Exception\\n unshift(link)\\n raise $!\\n end\\n end\",\n \"def move_lower_in_queue\\n return unless lower_item_in_queue\\n\\n acts_as_queue_class.transaction do\\n lower_item_in_queue.decrement_queue_position\\n increment_queue_position\\n end\\n end\",\n \"def move_higher_in_queue\\n return unless higher_item_in_queue\\n\\n acts_as_queue_class.transaction do\\n higher_item_in_queue.increment_queue_position\\n decrement_queue_position\\n end\\n end\",\n \"def move_to_bottom_in_queue\\n return unless in_queue?\\n acts_as_queue_class.transaction do\\n decrement_queue_positions_on_lower_items\\n assume_bottom_queue_position\\n end\\n end\",\n \"def move_to_top_in_queue\\n return unless in_queue?\\n acts_as_queue_class.transaction do\\n increment_queue_positions_on_higher_items\\n assume_top_queue_position\\n end\\n end\",\n \"def shift()\\n # If our ttl is zero, skip\\n if @queue.length < 1\\n return nil\\n end\\n # Get next from queue\\n this = @queue.shift\\n puts \\\"QUEUE ->: %3d %s\\\" % [this['ttl'], this['url']]\\n # Do we already have this page?\\n if ! @store.exists?(this['url'])\\n # Get page and read links\\n p = Page.new(this['url'], nil, this['ttl'])\\n # Add each link to the queue (if it doesn't alreaady exist)\\n p.links.each do |l|\\n if l['ttl'] > 0 and !@store.exists?(l['href'])\\n self.push(l['href'], l['ttl'])\\n end\\n end\\n # Store the links\\n @store.add(this['url'], p.links)\\n end\\n end\",\n \"def blmove(source, destination, where_source, where_destination, timeout: T.unsafe(nil)); end\",\n \"def shift\\n @lock.synchronize do\\n @queue.shift\\n end\\n end\",\n \"def queue_video!(video)\\n queue_items.create(video: video, \\n position: new_queue_item_position) unless queued_video?(video)\\n end\",\n \"def move_later\\n nekst = self.next\\n self.append_to(nekst) if nekst\\n end\",\n \"def add(link)\\n @queue.add link\\n end\",\n \"def queue(a)\\n p \\\"Before: #{a}\\\"\\n a.push(6)\\n a.shift(1)\\n p \\\"After: #{a}\\\"\\nend\",\n \"def move_next\\n\\t\\tself.current = self.current&.next\\n\\tend\",\n \"def move_next\\n\\t\\tself.current = self.current&.next\\n\\tend\",\n \"def remove_from_queue\\n if in_queue?\\n decrement_queue_positions_on_lower_items\\n update_attribute queue_position_column, nil\\n end\\n end\",\n \"def remove\\n @queue.shift\\n end\",\n \"def blocking_redirect to, timeout = 0\\n brpoplpush(@key, key(:queue)/(to.kind_of?(RedisQueue::Simple) ? to.name : to), timeout)\\n end\",\n \"def shift!\\n shifted = @queue.shift\\n\\n return nil if shifted.nil?\\n shifted[0]\\n end\",\n \"def remove\\n @queue.shift\\n end\",\n \"def dequeue\\n\\t\\t@queue.shift\\n\\tend\",\n \"def update_link!(link)\\n key = link.key\\n val = link.val\\n @store.remove(key)\\n link = @store.append(key,val) #this is where you move the link to end of list\\n @map[key] = link\\n end\",\n \"def __ap4r_forward_by_queue_info(stored_message_id, queue_info, options)\\r\\n __ap4r_queue_put(queue_info[:queue_name], queue_info[:queue_message], queue_info[:queue_headers])\\r\\n StoredMessage.destroy_if_exists(stored_message_id, options)\\r\\n end\",\n \"def dequeue\\n @queue.shift\\n end\",\n \"def remove\\n @queue.shift\\n end\",\n \"def dequeue; @queue.pop end\",\n \"def queue(link)\\n\\t\\t####binding.pry\\n\\t\\treq = request(link)\\n\\t\\t######binding.pry\\n\\t\\treq.on_complete {|res| \\n\\t\\t\\t######binding.pry\\n\\t\\t\\thandle_response(req, res)\\n\\t\\t}\\n\\t\\t#####binding.pry\\n\\t\\thydra.queue(req)\\n\\t\\t####binding.pry\\n\\tend\",\n \"def _put_back_on_queue(message)\\n future = nil\\n _redis.multi do\\n _redis.rpush(@queue, message)\\n future = _redis.lrem(@in_progress_queue, 1, message)\\n end\\n removed = future.value\\n if removed !=1\\n RailsPipeline.logger.error \\\"ERROR: Didn't remove message from in_progress queue?!!!\\\"\\n end\\n end\",\n \"def regress_head\\n\\t\\t\\t# @queue[@head_index] = nil\\n\\t\\t\\t# @size -= 1 unless @size == 0\\n\\t\\t\\t\\n\\t\\t\\t# @head_index -= 1\\n\\t\\t\\t# @head_index = @queue.size-1 if @head_index < 0\\n\\t\\tend\",\n \"def queue(_); end\",\n \"def queue(_); end\",\n \"def brpoplpush(source, destination, timeout: T.unsafe(nil)); end\",\n \"def reposition_queue\\n task_queue = TaskQueue.where(user_id: user_id, task_type_id: task_type_id)\\n if task_queue.pluck(:position).any? {|pos| pos > position}\\n task_queue.where(\\\"position > ?\\\", position).each do |queue_item|\\n queue_item.update(:position => (queue_item.position - 1))\\n end\\n end\\n end\",\n \"def lmove(source, destination, where_source, where_destination); end\",\n \"def lmove(source, destination, where_source, where_destination); end\",\n \"def shift\\n return nil if empty?\\n @que.shift\\n end\",\n \"def step\\n @queue.enq nil\\n end\",\n \"def invalidate_link link\\r\\n @links.delete(link.condition)\\r\\n link.detach_and_revert\\r\\n end\",\n \"def move\\n move_by a, m\\n end\",\n \"def queue_links(links)\\n\\t\\tlinks.each do |link|\\n\\t\\t\\tqueue(link)\\n\\t\\tend\\n\\tend\",\n \"def pop()\\n @size -= 1 \\n @queue.shift\\n end\",\n \"def remove!(item)\\n @queue.delete(item)\\n end\",\n \"def pop()\\n @queue.shift\\n end\",\n \"def queue_link( tag, source )\\n return if tag.attributes['class'] && tag.attributes['class']['thickbox'] == 'thickbox'\\n return if tag.attributes['onclick']\\n dest = (tag.attributes['onclick'] =~ /^new Ajax.Updater\\\\(['\\\"].*?['\\\"], ['\\\"](.*?)['\\\"]/i) ? $1 : tag.attributes['href']\\n if !(dest =~ %r{^(mailto:|#|javascript:|http://|.*\\\\.jpg|aim:|ichat:|xmpp:)})\\n @links_to_visit << Link.new( dest, source )\\n end\\n end\",\n \"def smove(source, destination, member); end\",\n \"def smove(source, destination, member); end\",\n \"def move(from, to)\\n @tasks.insert(index(to), @tasks.delete_at(index(from)))\\n end\",\n \"def advance_head\\n\\t\\t\\t@head_index += 1\\n\\t\\t\\t@head_index = 0 if @head_index == @queue.size\\n\\t\\tend\",\n \"def dequeue\\n @q.shift\\n end\",\n \"def dequeue\\n @store.shift\\n end\",\n \"def place_link(link, dest, last_link)\\n # If there is no dest, we are meant to be \\n if dest.nil?\\n # If we have no last link, we are alone - and are head\\n # and link's prev remains nil\\n if last_link.nil?\\n self[:head_id] = link.id\\n # If we have the last link, we want to be after it\\n else\\n last_link.next = link\\n link.prev = last_link\\n end\\n # Otherwise, we want to be at dest\\n else\\n # If dest has no prev, we'll be it's prev and the head\\n if dest.prev_id.nil?\\n self[:head_id] = link.id\\n link.next = dest\\n dest.prev = link\\n # Otherwise, squeeze our way in\\n else\\n link.next = dest\\n link.prev = dest.prev\\n dest.prev = link\\n link.prev.next = link\\n end\\n end\\n end\",\n \"def drop_link\\n return @drop_link if @drop_link\\n to_link = @to_link\\n \\n # continue along the road (to_link and further down) as long as\\n # no choices must be made between roads\\n # (method: more connectors may connect a road to the same downstream road)\\n while to_link.outgoing_connectors.map{|conn|conn.to_link}.uniq.size == 1\\n to_link = to_link.outgoing_connectors.first.to_link\\n end\\n @drop_link = to_link\\n end\",\n \"def shift\\n deadline = Time.now + @timeout\\n\\n synchronize do\\n loop do\\n return @queue.shift unless @queue.empty?\\n wait = deadline - Time.now\\n raise Timeout::Error, \\\"Waited for #{@timeout} seconds for connection but none was pushed.\\\" if wait <= 0\\n @cond.wait(wait)\\n end\\n end\\n end\",\n \"def queue(*items)\\n\\t\\t\\t# insert @ tail\\n\\t\\t\\t# increment size (if able)\\n\\t\\t\\t# check size\\n\\t\\t\\t\\t# move head if necessary\\n\\t\\t\\t# move tail\\n\\t\\t\\t\\n\\t\\t\\titems.each do |i|\\n\\t\\t\\t\\t# puts \\\"head #{@head_index} tail #{@tail_index}\\\"\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t@queue[@tail_index] = i\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t@size += 1 unless @size == @queue.size\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tif @size == @queue.size\\n\\t\\t\\t\\t\\tadvance_head\\n\\t\\t\\t\\tend\\n\\t\\t\\t\\t\\n\\t\\t\\t\\tadvance_tail\\n\\t\\t\\tend\\n\\t\\tend\",\n \"def move(thing, to, check=true)\\n item = find(thing)\\n dest = find(to)\\n\\n return if item.nil?\\n if check && item.hidden?\\n puts \\\"You can't get to that right now\\\"\\n return\\n end\\n\\n return if dest.nil?\\n if check && (dest.hidden? || dest.open == false)\\n puts \\\"You can't put that there\\\"\\n return\\n end\\n\\n if dest.ancestors.include?(item)\\n puts \\\"Are you trying to destroy the universe?\\\"\\n return\\n end\\n\\n item.parent.children.delete(item)\\n dest.children << item\\n item.parent = dest\\n end\",\n \"def deq\\n @queued = false\\n nil\\n end\",\n \"def add!(item)\\n @queue[item] = item\\n end\",\n \"def move_left\\n tenacious_transaction do\\n move_to_left_of left_sibling.try(:lock!)\\n end\\n end\",\n \"def dequeue\\n @items.shift\\n end\",\n \"def complete_order\\n @queue.dequeue\\n end\",\n \"def test_move_under_single_lock\\n setup_hr\\n\\n lock = lock 'httplock/hr', :depth => RubyDav::INFINITY\\n\\n response = @request.move('httplock/hr/recruiting/resumes', 'httplock/hr/archives/resumes')\\n assert_equal '423', response.status\\n assert_exists 'httplock/hr/recruiting/resumes/'\\n assert_does_not_exist 'httplock/hr/archives/resumes/'\\n\\n if_hdr = lock.token\\n response = @request.move('httplock/hr/recruiting/resumes', 'httplock/hr/archives/resumes', false, :if => if_hdr)\\n assert_equal '201', response.status\\n assert_does_not_exist 'httplock/hr/recruiting/resumes/'\\n assert_exists 'httplock/hr/archives/resumes/'\\n\\n # cleanup\\n unlock('httplock/hr', lock.token)\\n delete_coll('httplock')\\n end\",\n \"def moveInQueue\\n # Don't bother unless the next car has cleared the end of the queue.\\n if carAhead && carAhead.tailInQueue\\n return false\\n end\\n\\n return false unless @currentLane.meterOK\\n\\n @bodyStart = 0\\n @bodyEnd = @bodyStart - @length\\n @nextSpeed = @driver.velocity(self)\\n @currentLane.updateMeter\\n\\n return true\\n end\",\n \"def dequeue\\n end\",\n \"def remove\\n if empty?\\n raise \\\"Can't remove if queue is empty\\\"\\n else\\n @info.shift\\n end\\n end\",\n \"def remove\\n if empty?\\n raise \\\"Can't remove if queue is empty\\\"\\n else\\n @info.shift\\n end\\n end\",\n \"def remove\\n if empty?\\n raise \\\"Can't remove if queue is empty\\\"\\n else\\n @info.shift\\n end\\n end\",\n \"def remove_link(link)\\n # If the_link is head, set head to nil\\n if self[:head_id] == link.id\\n self[:head_id] = link.next_id\\n end\\n if link.prev\\n # If things on both sides, link them\\n if link.next\\n link.prev.next_id = link.next_id\\n link.next.prev_id = link.prev_id \\n link.next = nil\\n link.prev = nil\\n # If no next id, clear prev's next\\n else\\n link.prev.next_id = nil\\n link.prev = nil\\n end\\n else\\n # If no prev id, clear next's prev\\n if link.next\\n link.next.prev_id = nil\\n link.next = nil\\n # It none on either side, do nothing\\n else\\n end\\n end\\n end\",\n \"def move_onto(a, b)\\n reveal(a)\\n reveal(b)\\n move_single(a, b)\\n end\",\n \"def watch_movie (queue)\\n queue.shift\\n queue\\nend\",\n \"def force_queue_to_vimeo\\n self.queue_transfer_to_vimeo(true)\\n true\\n end\",\n \"def requeue\\n __requeue__(\\\"RPUSH\\\")\\n end\",\n \"def remove\\n @nxt.prv = @prv if @nxt\\n @prv.nxt = @nxt if @prv\\n end\",\n \"def enqueue(object_)\\n result_ = true\\n if @push_ptr\\n if @pop_ptr == @push_ptr\\n if @drop_oldest\\n @pop_ptr += 1\\n @pop_ptr = 0 if @pop_ptr == @buffer.size\\n result_ = false\\n else\\n return false\\n end\\n elsif @pop_ptr.nil?\\n @pop_ptr = @push_ptr\\n end\\n @buffer[@push_ptr] = object_\\n @push_ptr += 1\\n @push_ptr = 0 if @push_ptr == @buffer.size\\n else\\n @buffer.push(object_)\\n end\\n result_\\n end\",\n \"def pop()\\n if @queue_out.size == 0 \\n if @queue_in.size == 0 \\n return \\n end\\n \\n while @queue_in.size > 0 \\n @queue_out.push(@queue_in.pop)\\n end\\n end\\n \\n @size -= 1\\n return @queue_out.pop\\n end\",\n \"def unpop obj\\n was_empty = @q.empty?\\n case obj\\n when SimultaneousQueueEntries\\n case obj.size\\n when 0\\n was_empty = false # just to prevent the inc\\n when 1\\n @q.unshift obj.first\\n else\\n @q.unshift obj\\n end\\n else\\n @q.unshift obj\\n end\\n @component.inc_queue_ready_count if was_empty\\n end\",\n \"def queue_front(request)\\n request.hydra = self\\n queued_requests.unshift request\\n end\",\n \"def queue; end\",\n \"def queue; end\",\n \"def unshift(link)\\n if link\\n validated.delete(link[0])\\n to_validate[link[0]] = link[1]\\n end\\n end\",\n \"def remove_from_queue(queue, data)\\n prioritized?(queue) ? z_remove_from_queue(queue, data) : super\\n end\",\n \"def move_node_to_head(node) \\n removed = remove_node(node)\\n\\n add_head(removed)\\n end\",\n \"def move; end\",\n \"def move; end\",\n \"def move_somewhere(bram, dead_space, astar, params)\\n x = bram.head[0]\\n y = bram.head[1]\\n open_spot = []\\n surrounding_cells_within_grid(x, y, params).each do |c|\\n next if dead_space.include?(c) # do not under any circumstances move there\\n open_spot.push(c)\\n return c unless path_is_deadend?(bram, [bram.head, c], astar, dead_space)\\n end\\n open_spot.first # all are dead-ends so just pick an open spot\\nend\",\n \"def pour_out\\n @queue.deq\\n end\",\n \"def place(queen, tile)\\r\\n tile.leave()\\r\\n queen.goto( tile, tile )\\r\\n end\",\n \"def move(to)\\n @moved = true\\n super(to)\\n end\",\n \"def shift\\n current_node = @head\\n @head = current_node.next_node\\n end\",\n \"def pop()\\n if @queue_out.size == 0\\n if @queue_in.size == 0\\n return\\n end\\n\\n while @queue_in.size > 0\\n @queue_out.push(@queue_in.pop)\\n end\\n end\\n\\n @size -= 1\\n return @queue_out.pop\\n end\",\n \"def move!(end_pos)\\n board.remove_piece(pos)\\n\\n if (pos[0] - end_pos[0]).abs == 2\\n board.remove_piece(jumped_place(end_pos))\\n end\\n\\n self.pos = end_pos\\n board.place_piece(self, end_pos)\\n\\n maybe_promote\\n end\",\n \"def queue(&b)\\n @queue << b\\n end\",\n \"def queue(message); end\",\n \"def move(from, to, aux, disk_count)\\n # base case\\n if disk_count == 1 # we're only moving one disc\\n disk = from.pop\\n check_disk_sizes(disk, to.last)\\n to.push(disk)\\n print_state\\n @step_counter += 1\\n return\\n end\\n\\n # otherwise we need to do some flippin aorund\\n move(from, aux, to, disk_count - 1)\\n move(from, to, aux, 1)\\n move(aux, to, from, disk_count - 1)\\n end\",\n \"def pop\\n @insert_point -= 1\\n if (@insert_point < 0)\\n return nil\\n end\\n check = @items[0]\\n\\n rc = pop_sync(check)\\n new_head = @items[@insert_point]\\n new_head.index = 0\\n @items[0] = new_head\\n @items[@insert_point] = nil\\n\\n # Rearrange the neighbor nodes and recalculate their attribs\\n check.next_link.prev_link = check.prev_link\\n check.prev_link.next_link = check.next_link\\n check.next_link.recalculate\\n check.prev_link.recalculate\\n\\n # Rearrange the heap\\n heapify(0)\\n heapify(check.next_link.index)\\n heapify(check.prev_link.index)\\n\\n return rc\\n end\",\n \"def dequeue\\n last_el = self.queue_var[-1]\\n self.queue_var = self.queue_var[0...-1]\\n last_el \\n end\",\n \"def test_orderOfElements\\n @queue.enqueue(100)\\n @queue.enqueue(200)\\n assert_equal( 100, @queue.dequeue )\\n assert_equal( 200, @queue.dequeue )\\n end\",\n \"def push_to_queue(queue, item)\\n queue.push(item)\\nrescue Exception => e\\n puts \\\"Rescued #{e}\\\"\\nend\",\n \"def delete_front()\\n if @queue.size > 0\\n @queue.shift\\n return true\\n end\\n false\\n end\",\n \"def remove\\n @queue.pop\\n end\",\n \"def enqueue(node)\\n #the double arrow means to PUSH the node into our q list\\n @q << node\\n end\",\n \"def move!(target)\\n @board[@pos] = nil\\n @pos = target \\n @board[@pos] = self\\n true\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.6881409","0.6479159","0.6250727","0.6175462","0.6158869","0.6153209","0.60790294","0.5987659","0.597337","0.59211755","0.584882","0.5823436","0.57847935","0.57847935","0.5767391","0.57355714","0.57271713","0.56752914","0.5672765","0.5657361","0.5654901","0.5634551","0.56315625","0.56139433","0.55681604","0.55667686","0.55654055","0.55493146","0.55486053","0.55486053","0.5501949","0.547892","0.54734683","0.54734683","0.5473268","0.5471098","0.5465054","0.5452606","0.5442654","0.5437201","0.5404802","0.5392974","0.53751755","0.535782","0.535782","0.5355933","0.5355493","0.5339451","0.53241146","0.53226715","0.5299838","0.52930164","0.52838016","0.5276663","0.5275863","0.5275135","0.5262952","0.52612495","0.52582777","0.52555805","0.5254325","0.5245184","0.5242684","0.5242684","0.5242684","0.52413434","0.5235848","0.5235184","0.52152646","0.5207521","0.5197166","0.5191473","0.51878613","0.51846665","0.5178492","0.51774585","0.51774585","0.51771057","0.51768255","0.5175283","0.51740587","0.51740587","0.5173297","0.51702845","0.5164631","0.5164116","0.5163191","0.51614434","0.5151257","0.5149957","0.5141963","0.5131751","0.5127251","0.5123049","0.51225775","0.51094425","0.51018035","0.5101392","0.50986856","0.5095319"],"string":"[\n \"0.6881409\",\n \"0.6479159\",\n \"0.6250727\",\n \"0.6175462\",\n \"0.6158869\",\n \"0.6153209\",\n \"0.60790294\",\n \"0.5987659\",\n \"0.597337\",\n \"0.59211755\",\n \"0.584882\",\n \"0.5823436\",\n \"0.57847935\",\n \"0.57847935\",\n \"0.5767391\",\n \"0.57355714\",\n \"0.57271713\",\n \"0.56752914\",\n \"0.5672765\",\n \"0.5657361\",\n \"0.5654901\",\n \"0.5634551\",\n \"0.56315625\",\n \"0.56139433\",\n \"0.55681604\",\n \"0.55667686\",\n \"0.55654055\",\n \"0.55493146\",\n \"0.55486053\",\n \"0.55486053\",\n \"0.5501949\",\n \"0.547892\",\n \"0.54734683\",\n \"0.54734683\",\n \"0.5473268\",\n \"0.5471098\",\n \"0.5465054\",\n \"0.5452606\",\n \"0.5442654\",\n \"0.5437201\",\n \"0.5404802\",\n \"0.5392974\",\n \"0.53751755\",\n \"0.535782\",\n \"0.535782\",\n \"0.5355933\",\n \"0.5355493\",\n \"0.5339451\",\n \"0.53241146\",\n \"0.53226715\",\n \"0.5299838\",\n \"0.52930164\",\n \"0.52838016\",\n \"0.5276663\",\n \"0.5275863\",\n \"0.5275135\",\n \"0.5262952\",\n \"0.52612495\",\n \"0.52582777\",\n \"0.52555805\",\n \"0.5254325\",\n \"0.5245184\",\n \"0.5242684\",\n \"0.5242684\",\n \"0.5242684\",\n \"0.52413434\",\n \"0.5235848\",\n \"0.5235184\",\n \"0.52152646\",\n \"0.5207521\",\n \"0.5197166\",\n \"0.5191473\",\n \"0.51878613\",\n \"0.51846665\",\n \"0.5178492\",\n \"0.51774585\",\n \"0.51774585\",\n \"0.51771057\",\n \"0.51768255\",\n \"0.5175283\",\n \"0.51740587\",\n \"0.51740587\",\n \"0.5173297\",\n \"0.51702845\",\n \"0.5164631\",\n \"0.5164116\",\n \"0.5163191\",\n \"0.51614434\",\n \"0.5151257\",\n \"0.5149957\",\n \"0.5141963\",\n \"0.5131751\",\n \"0.5127251\",\n \"0.5123049\",\n \"0.51225775\",\n \"0.51094425\",\n \"0.51018035\",\n \"0.5101392\",\n \"0.50986856\",\n \"0.5095319\"\n]"},"document_score":{"kind":"string","value":"0.524979"},"document_rank":{"kind":"string","value":"61"}}},{"rowIdx":1884,"cells":{"query":{"kind":"string","value":"put a link back onto the queue"},"document":{"kind":"string","value":"def unshift(link)\n if link\n validated.delete(link[0])\n to_validate[link[0]] = link[1]\n end\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def add(link)\n @queue.add link\n end","def shift()\n # If our ttl is zero, skip\n if @queue.length < 1\n return nil\n end\n # Get next from queue\n this = @queue.shift\n puts \"QUEUE ->: %3d %s\" % [this['ttl'], this['url']]\n # Do we already have this page?\n if ! @store.exists?(this['url'])\n # Get page and read links\n p = Page.new(this['url'], nil, this['ttl'])\n # Add each link to the queue (if it doesn't alreaady exist)\n p.links.each do |l|\n if l['ttl'] > 0 and !@store.exists?(l['href'])\n self.push(l['href'], l['ttl'])\n end\n end\n # Store the links\n @store.add(this['url'], p.links)\n end\n end","def dequeue; @queue.pop end","def blocking_redirect to, timeout = 0\n brpoplpush(@key, key(:queue)/(to.kind_of?(RedisQueue::Simple) ? to.name : to), timeout)\n end","def queue(link)\n\t\t####binding.pry\n\t\treq = request(link)\n\t\t######binding.pry\n\t\treq.on_complete {|res| \n\t\t\t######binding.pry\n\t\t\thandle_response(req, res)\n\t\t}\n\t\t#####binding.pry\n\t\thydra.queue(req)\n\t\t####binding.pry\n\tend","def queue(&b)\n @queue << b\n end","def queue(_); end","def queue(_); end","def dequeue\n @queue.shift\n end","def remove\n @queue.shift\n end","def queue; end","def queue; end","def dequeue\n\t\t@queue.shift\n\tend","def dequeue\n end","def remove\n @queue.shift\n end","def remove\n @queue.shift\n end","def deq\n @queued = false\n nil\n end","def queue(message); end","def pop()\n @queue.shift\n end","def _put_back_on_queue(message)\n future = nil\n _redis.multi do\n _redis.rpush(@queue, message)\n future = _redis.lrem(@in_progress_queue, 1, message)\n end\n removed = future.value\n if removed !=1\n RailsPipeline.logger.error \"ERROR: Didn't remove message from in_progress queue?!!!\"\n end\n end","def remove\n @queue.pop\n end","def queue_link( tag, source )\n return if tag.attributes['class'] && tag.attributes['class']['thickbox'] == 'thickbox'\n return if tag.attributes['onclick']\n dest = (tag.attributes['onclick'] =~ /^new Ajax.Updater\\(['\"].*?['\"], ['\"](.*?)['\"]/i) ? $1 : tag.attributes['href']\n if !(dest =~ %r{^(mailto:|#|javascript:|http://|.*\\.jpg|aim:|ichat:|xmpp:)})\n @links_to_visit << Link.new( dest, source )\n end\n end","def push(reference)\n if reference\n @lock.synchronize do\n @queue.push(reference)\n end\n end\n end","def add!(item)\n @queue[item] = item\n end","def dequeue\n @q.shift\n end","def bt\n @queue << \"bt\"\n end","def pop()\n @size -= 1 \n @queue.shift\n end","def queue_next\n begin\n link = to_validate.shift\n return if not link\n\n queued[link[0]] = link[1]\n\n link[1].validate(@hydra) { |error: nil|\n queued.delete(link[0])\n\n if error then invalidate(link[1], error[:type], error[:msg])\n else validated[link[0]] = link[1]\n end\n }\n link\n rescue Exception\n unshift(link)\n raise $!\n end\n end","def shift\n @lock.synchronize do\n @queue.shift\n end\n end","def on_queue(url)\n true\n end","def dequeue\n\t\t\tself.pop\n\t\tend","def dequeue\n @store.shift\n end","def retrieve(key); @amq.queue(key); end","def add_to_queue!(user)\n $redis.lpush(self.class.redis_key_for_user(user), to_redis_object)\n end","def delete\n @queue << \"delete\"\n end","def update_link!(link)\n key = link.key\n val = link.val\n @store.remove(key)\n link = @store.append(key,val) #this is where you move the link to end of list\n @map[key] = link\n end","def queue_links(links)\n\t\tlinks.each do |link|\n\t\t\tqueue(link)\n\t\tend\n\tend","def deliver\n @queue << self\n end","def complete_order\n @queue.dequeue\n end","def pour_out\n @queue.deq\n end","def update_queue (queue, movie)\n queue.push(movie)\nend","def next_event\n @queue.pop\n end","def step\n @queue.enq nil\n end","def dequeue\n @store.pop\n end","def dequeue\n @items.shift\n end","def push &put\n #Thread.pass while self.full?\n sleep 0.01 while self.full?\n self.push! &put\n end","def pop\n _exchange\n end","def enqueue(item)\n\t\t@queue << item\n\tend","def handle\n @queue << \"handle\"\n end","def pop\n @lock.synchronize do\n @queue.pop\n end\n end","def move_higher_in_queue\n return unless higher_item_in_queue\n\n acts_as_queue_class.transaction do\n higher_item_in_queue.increment_queue_position\n decrement_queue_position\n end\n end","def push(obj)\n @queue.put(obj)\n end","def flush; queue.close end","def requeue\n __requeue__(\"RPUSH\")\n end","def enqueue(item)\n end","def remove!(item)\n @queue.delete(item)\n end","def push(url, ttl)\n url= @store.sanitise(url)\n # Is it in robots?\n robot = false\n @robots.each do |r|\n if url.start_with?(r)\n robot = true\n end\n end\n # Do we already have it?, Is it in robots.txt?, Is it within our restriction\n exists = @store.exists?(url)\n if !exists and url.start_with?(@restrict) and !robot\n puts \"-> QUEUE: %3d %s\" % [ttl, url]\n @queue.push({\n 'url' => url,\n 'ttl' => ttl })\n end\n end","def push(element)\t\t\n\t\twhile !@q1.empty? do\n\t\t\t@q2.enq(@q1.pop) # Dequeue element from queue q1 and enque the same to q2\n\t\tend\n\t\t@q1.enq(element)\n\t\twhile !@q2.empty? do\n\t\t\t@q1.enq(@q2.pop) # Dequeue element from queue q2 and enque the same to q1\n\t\tend\t\n\tend","def queue(a)\n p \"Before: #{a}\"\n a.push(6)\n a.shift(1)\n p \"After: #{a}\"\nend","def dequeue\n @data.shift\n end","def pop &use\n #Thread.pass while self.empty?\n sleep 0.01 while self.empty?\n self.pop! &use\n end","def brpoplpush(source, destination, timeout: T.unsafe(nil)); end","def push_to_queue(queue, item)\n queue.push(item)\nrescue Exception => e\n puts \"Rescued #{e}\"\nend","def move_to_bottom_in_queue\n return unless in_queue?\n acts_as_queue_class.transaction do\n decrement_queue_positions_on_lower_items\n assume_bottom_queue_position\n end\n end","def queue\n @handle.queue_name if @handle\n end","def peek; @queue[-1] end","def dequeue!(user=nil)\n update_attribute(:queued, false)\n end","def queue() = @queue ||= CommandQueue.new","def enqueue(node)\n #the double arrow means to PUSH the node into our q list\n @q << node\n end","def dequeue\n add(queued_requests.shift) unless queued_requests.empty?\n end","def queue( name, &block )\n destination( name, :queue, @queues, &block )\n end","def queue_out\n @channel.queue('dns-out', durable: true)\n end","def enqueue(el)\n @queue << el\n el\n end","def link(url)\n if @_bucket.nil?\n raise \"Robots.link must be called inside of allow or disallow block\"\n else\n @_bucket.push(url.to_s)\n end\n end","def queue_out\n @channel.queue('out', durable: true)\n end","def queue_out\n @channel.queue('out', durable: true)\n end","def watch_movie (queue)\n queue.shift\n queue\nend","def push(obj)\n @mutex.synchronize{\n @que.push obj\n begin\n t = @waiting.shift\n t.wakeup if t\n rescue ThreadError\n retry\n end\n }\n end","def retrieve(key)\n @amq.queue(key)\n end","def dispatch\n @queue.pop.run while @queue.ready?\n end","def queue_video!(video)\n queue_items.create(video: video, \n position: new_queue_item_position) unless queued_video?(video)\n end","def finish\n @queue << \"finish\"\n end","def pop()\n @q.shift\n end","def dequeue\n last_el = self.queue_var[-1]\n self.queue_var = self.queue_var[0...-1]\n last_el \n end","def __ap4r_forward_by_queue_info(stored_message_id, queue_info, options)\r\n __ap4r_queue_put(queue_info[:queue_name], queue_info[:queue_message], queue_info[:queue_headers])\r\n StoredMessage.destroy_if_exists(stored_message_id, options)\r\n end","def move_lower_in_queue\n return unless lower_item_in_queue\n\n acts_as_queue_class.transaction do\n lower_item_in_queue.decrement_queue_position\n increment_queue_position\n end\n end","def requeue\n Sidekiq.redis { |conn| conn.rpush(QueueName.expand(queue_name), job) }\n end","def queue_job; end","def pop()\n new_queue = Queue.new\n until @queue.size == 1\n new_queue << @queue.pop\n end\n last = @queue.pop\n @queue = new_queue\n last\n end","def enqueue(object_)\n result_ = true\n if @push_ptr\n if @pop_ptr == @push_ptr\n if @drop_oldest\n @pop_ptr += 1\n @pop_ptr = 0 if @pop_ptr == @buffer.size\n result_ = false\n else\n return false\n end\n elsif @pop_ptr.nil?\n @pop_ptr = @push_ptr\n end\n @buffer[@push_ptr] = object_\n @push_ptr += 1\n @push_ptr = 0 if @push_ptr == @buffer.size\n else\n @buffer.push(object_)\n end\n result_\n end","def remove_link(from,to,tag)\n link = JiakLink.new(to.jiak.object.bucket, to.jiak.object.key, tag)\n has_link = from.jiak.object.links.include?(link)\n if has_link\n from.jiak.object.links.delete(link)\n if(from.auto_update? ||\n ((from.auto_update? != false) && from.class.auto_update?))\n put(from)\n end\n end\n has_link\n end","def push(event:)\n super\n\n @queue << event\n end","def push(x)\n @queue << x\n end","def remove_from_queue!(user)\n $redis.lrem(self.class.redis_key_for_user(user), 0, to_redis_object)\n end","def enqueue(el)\n @queue.push(el)\n true\n end","def merge!\n\t\t\twhile handle = @queue.pop\n\t\t\t\tnext if handle.cancelled?\n\t\t\t\t\n\t\t\t\t@sequence.push(handle)\n\t\t\tend\n\t\tend","def enqueue(element)\n # if queue is full or the element you're trying to add = nil, item cannot be added to the queue\n if full? or element.nil?\n nil\n else\n # 1 subtracted from @tail because the queue is going to be one item longer now\n @tail = @tail.pred\n # last element in the queue is set equal to the element you passed in as an argument\n @store[@tail] = element\n # returns the Queue\n self\n end\n end","def add_to_queue(playlist)\n @queue << playlist\n if @current_playlist.nil? \n @current_playlist = @queue.shift\n play @current_playlist\n end\n end","def push(obj)\n if @blocked\n raise \"Nothing can be added to queue. Queue is blocked.\"\n else\n super(obj)\n end\n end","def enqueue(el)\n @queue.push(el)\n end","def queue notification\n @notification_queue.unshift notification\n end"],"string":"[\n \"def add(link)\\n @queue.add link\\n end\",\n \"def shift()\\n # If our ttl is zero, skip\\n if @queue.length < 1\\n return nil\\n end\\n # Get next from queue\\n this = @queue.shift\\n puts \\\"QUEUE ->: %3d %s\\\" % [this['ttl'], this['url']]\\n # Do we already have this page?\\n if ! @store.exists?(this['url'])\\n # Get page and read links\\n p = Page.new(this['url'], nil, this['ttl'])\\n # Add each link to the queue (if it doesn't alreaady exist)\\n p.links.each do |l|\\n if l['ttl'] > 0 and !@store.exists?(l['href'])\\n self.push(l['href'], l['ttl'])\\n end\\n end\\n # Store the links\\n @store.add(this['url'], p.links)\\n end\\n end\",\n \"def dequeue; @queue.pop end\",\n \"def blocking_redirect to, timeout = 0\\n brpoplpush(@key, key(:queue)/(to.kind_of?(RedisQueue::Simple) ? to.name : to), timeout)\\n end\",\n \"def queue(link)\\n\\t\\t####binding.pry\\n\\t\\treq = request(link)\\n\\t\\t######binding.pry\\n\\t\\treq.on_complete {|res| \\n\\t\\t\\t######binding.pry\\n\\t\\t\\thandle_response(req, res)\\n\\t\\t}\\n\\t\\t#####binding.pry\\n\\t\\thydra.queue(req)\\n\\t\\t####binding.pry\\n\\tend\",\n \"def queue(&b)\\n @queue << b\\n end\",\n \"def queue(_); end\",\n \"def queue(_); end\",\n \"def dequeue\\n @queue.shift\\n end\",\n \"def remove\\n @queue.shift\\n end\",\n \"def queue; end\",\n \"def queue; end\",\n \"def dequeue\\n\\t\\t@queue.shift\\n\\tend\",\n \"def dequeue\\n end\",\n \"def remove\\n @queue.shift\\n end\",\n \"def remove\\n @queue.shift\\n end\",\n \"def deq\\n @queued = false\\n nil\\n end\",\n \"def queue(message); end\",\n \"def pop()\\n @queue.shift\\n end\",\n \"def _put_back_on_queue(message)\\n future = nil\\n _redis.multi do\\n _redis.rpush(@queue, message)\\n future = _redis.lrem(@in_progress_queue, 1, message)\\n end\\n removed = future.value\\n if removed !=1\\n RailsPipeline.logger.error \\\"ERROR: Didn't remove message from in_progress queue?!!!\\\"\\n end\\n end\",\n \"def remove\\n @queue.pop\\n end\",\n \"def queue_link( tag, source )\\n return if tag.attributes['class'] && tag.attributes['class']['thickbox'] == 'thickbox'\\n return if tag.attributes['onclick']\\n dest = (tag.attributes['onclick'] =~ /^new Ajax.Updater\\\\(['\\\"].*?['\\\"], ['\\\"](.*?)['\\\"]/i) ? $1 : tag.attributes['href']\\n if !(dest =~ %r{^(mailto:|#|javascript:|http://|.*\\\\.jpg|aim:|ichat:|xmpp:)})\\n @links_to_visit << Link.new( dest, source )\\n end\\n end\",\n \"def push(reference)\\n if reference\\n @lock.synchronize do\\n @queue.push(reference)\\n end\\n end\\n end\",\n \"def add!(item)\\n @queue[item] = item\\n end\",\n \"def dequeue\\n @q.shift\\n end\",\n \"def bt\\n @queue << \\\"bt\\\"\\n end\",\n \"def pop()\\n @size -= 1 \\n @queue.shift\\n end\",\n \"def queue_next\\n begin\\n link = to_validate.shift\\n return if not link\\n\\n queued[link[0]] = link[1]\\n\\n link[1].validate(@hydra) { |error: nil|\\n queued.delete(link[0])\\n\\n if error then invalidate(link[1], error[:type], error[:msg])\\n else validated[link[0]] = link[1]\\n end\\n }\\n link\\n rescue Exception\\n unshift(link)\\n raise $!\\n end\\n end\",\n \"def shift\\n @lock.synchronize do\\n @queue.shift\\n end\\n end\",\n \"def on_queue(url)\\n true\\n end\",\n \"def dequeue\\n\\t\\t\\tself.pop\\n\\t\\tend\",\n \"def dequeue\\n @store.shift\\n end\",\n \"def retrieve(key); @amq.queue(key); end\",\n \"def add_to_queue!(user)\\n $redis.lpush(self.class.redis_key_for_user(user), to_redis_object)\\n end\",\n \"def delete\\n @queue << \\\"delete\\\"\\n end\",\n \"def update_link!(link)\\n key = link.key\\n val = link.val\\n @store.remove(key)\\n link = @store.append(key,val) #this is where you move the link to end of list\\n @map[key] = link\\n end\",\n \"def queue_links(links)\\n\\t\\tlinks.each do |link|\\n\\t\\t\\tqueue(link)\\n\\t\\tend\\n\\tend\",\n \"def deliver\\n @queue << self\\n end\",\n \"def complete_order\\n @queue.dequeue\\n end\",\n \"def pour_out\\n @queue.deq\\n end\",\n \"def update_queue (queue, movie)\\n queue.push(movie)\\nend\",\n \"def next_event\\n @queue.pop\\n end\",\n \"def step\\n @queue.enq nil\\n end\",\n \"def dequeue\\n @store.pop\\n end\",\n \"def dequeue\\n @items.shift\\n end\",\n \"def push &put\\n #Thread.pass while self.full?\\n sleep 0.01 while self.full?\\n self.push! &put\\n end\",\n \"def pop\\n _exchange\\n end\",\n \"def enqueue(item)\\n\\t\\t@queue << item\\n\\tend\",\n \"def handle\\n @queue << \\\"handle\\\"\\n end\",\n \"def pop\\n @lock.synchronize do\\n @queue.pop\\n end\\n end\",\n \"def move_higher_in_queue\\n return unless higher_item_in_queue\\n\\n acts_as_queue_class.transaction do\\n higher_item_in_queue.increment_queue_position\\n decrement_queue_position\\n end\\n end\",\n \"def push(obj)\\n @queue.put(obj)\\n end\",\n \"def flush; queue.close end\",\n \"def requeue\\n __requeue__(\\\"RPUSH\\\")\\n end\",\n \"def enqueue(item)\\n end\",\n \"def remove!(item)\\n @queue.delete(item)\\n end\",\n \"def push(url, ttl)\\n url= @store.sanitise(url)\\n # Is it in robots?\\n robot = false\\n @robots.each do |r|\\n if url.start_with?(r)\\n robot = true\\n end\\n end\\n # Do we already have it?, Is it in robots.txt?, Is it within our restriction\\n exists = @store.exists?(url)\\n if !exists and url.start_with?(@restrict) and !robot\\n puts \\\"-> QUEUE: %3d %s\\\" % [ttl, url]\\n @queue.push({\\n 'url' => url,\\n 'ttl' => ttl })\\n end\\n end\",\n \"def push(element)\\t\\t\\n\\t\\twhile !@q1.empty? do\\n\\t\\t\\t@q2.enq(@q1.pop) # Dequeue element from queue q1 and enque the same to q2\\n\\t\\tend\\n\\t\\t@q1.enq(element)\\n\\t\\twhile !@q2.empty? do\\n\\t\\t\\t@q1.enq(@q2.pop) # Dequeue element from queue q2 and enque the same to q1\\n\\t\\tend\\t\\n\\tend\",\n \"def queue(a)\\n p \\\"Before: #{a}\\\"\\n a.push(6)\\n a.shift(1)\\n p \\\"After: #{a}\\\"\\nend\",\n \"def dequeue\\n @data.shift\\n end\",\n \"def pop &use\\n #Thread.pass while self.empty?\\n sleep 0.01 while self.empty?\\n self.pop! &use\\n end\",\n \"def brpoplpush(source, destination, timeout: T.unsafe(nil)); end\",\n \"def push_to_queue(queue, item)\\n queue.push(item)\\nrescue Exception => e\\n puts \\\"Rescued #{e}\\\"\\nend\",\n \"def move_to_bottom_in_queue\\n return unless in_queue?\\n acts_as_queue_class.transaction do\\n decrement_queue_positions_on_lower_items\\n assume_bottom_queue_position\\n end\\n end\",\n \"def queue\\n @handle.queue_name if @handle\\n end\",\n \"def peek; @queue[-1] end\",\n \"def dequeue!(user=nil)\\n update_attribute(:queued, false)\\n end\",\n \"def queue() = @queue ||= CommandQueue.new\",\n \"def enqueue(node)\\n #the double arrow means to PUSH the node into our q list\\n @q << node\\n end\",\n \"def dequeue\\n add(queued_requests.shift) unless queued_requests.empty?\\n end\",\n \"def queue( name, &block )\\n destination( name, :queue, @queues, &block )\\n end\",\n \"def queue_out\\n @channel.queue('dns-out', durable: true)\\n end\",\n \"def enqueue(el)\\n @queue << el\\n el\\n end\",\n \"def link(url)\\n if @_bucket.nil?\\n raise \\\"Robots.link must be called inside of allow or disallow block\\\"\\n else\\n @_bucket.push(url.to_s)\\n end\\n end\",\n \"def queue_out\\n @channel.queue('out', durable: true)\\n end\",\n \"def queue_out\\n @channel.queue('out', durable: true)\\n end\",\n \"def watch_movie (queue)\\n queue.shift\\n queue\\nend\",\n \"def push(obj)\\n @mutex.synchronize{\\n @que.push obj\\n begin\\n t = @waiting.shift\\n t.wakeup if t\\n rescue ThreadError\\n retry\\n end\\n }\\n end\",\n \"def retrieve(key)\\n @amq.queue(key)\\n end\",\n \"def dispatch\\n @queue.pop.run while @queue.ready?\\n end\",\n \"def queue_video!(video)\\n queue_items.create(video: video, \\n position: new_queue_item_position) unless queued_video?(video)\\n end\",\n \"def finish\\n @queue << \\\"finish\\\"\\n end\",\n \"def pop()\\n @q.shift\\n end\",\n \"def dequeue\\n last_el = self.queue_var[-1]\\n self.queue_var = self.queue_var[0...-1]\\n last_el \\n end\",\n \"def __ap4r_forward_by_queue_info(stored_message_id, queue_info, options)\\r\\n __ap4r_queue_put(queue_info[:queue_name], queue_info[:queue_message], queue_info[:queue_headers])\\r\\n StoredMessage.destroy_if_exists(stored_message_id, options)\\r\\n end\",\n \"def move_lower_in_queue\\n return unless lower_item_in_queue\\n\\n acts_as_queue_class.transaction do\\n lower_item_in_queue.decrement_queue_position\\n increment_queue_position\\n end\\n end\",\n \"def requeue\\n Sidekiq.redis { |conn| conn.rpush(QueueName.expand(queue_name), job) }\\n end\",\n \"def queue_job; end\",\n \"def pop()\\n new_queue = Queue.new\\n until @queue.size == 1\\n new_queue << @queue.pop\\n end\\n last = @queue.pop\\n @queue = new_queue\\n last\\n end\",\n \"def enqueue(object_)\\n result_ = true\\n if @push_ptr\\n if @pop_ptr == @push_ptr\\n if @drop_oldest\\n @pop_ptr += 1\\n @pop_ptr = 0 if @pop_ptr == @buffer.size\\n result_ = false\\n else\\n return false\\n end\\n elsif @pop_ptr.nil?\\n @pop_ptr = @push_ptr\\n end\\n @buffer[@push_ptr] = object_\\n @push_ptr += 1\\n @push_ptr = 0 if @push_ptr == @buffer.size\\n else\\n @buffer.push(object_)\\n end\\n result_\\n end\",\n \"def remove_link(from,to,tag)\\n link = JiakLink.new(to.jiak.object.bucket, to.jiak.object.key, tag)\\n has_link = from.jiak.object.links.include?(link)\\n if has_link\\n from.jiak.object.links.delete(link)\\n if(from.auto_update? ||\\n ((from.auto_update? != false) && from.class.auto_update?))\\n put(from)\\n end\\n end\\n has_link\\n end\",\n \"def push(event:)\\n super\\n\\n @queue << event\\n end\",\n \"def push(x)\\n @queue << x\\n end\",\n \"def remove_from_queue!(user)\\n $redis.lrem(self.class.redis_key_for_user(user), 0, to_redis_object)\\n end\",\n \"def enqueue(el)\\n @queue.push(el)\\n true\\n end\",\n \"def merge!\\n\\t\\t\\twhile handle = @queue.pop\\n\\t\\t\\t\\tnext if handle.cancelled?\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t@sequence.push(handle)\\n\\t\\t\\tend\\n\\t\\tend\",\n \"def enqueue(element)\\n # if queue is full or the element you're trying to add = nil, item cannot be added to the queue\\n if full? or element.nil?\\n nil\\n else\\n # 1 subtracted from @tail because the queue is going to be one item longer now\\n @tail = @tail.pred\\n # last element in the queue is set equal to the element you passed in as an argument\\n @store[@tail] = element\\n # returns the Queue\\n self\\n end\\n end\",\n \"def add_to_queue(playlist)\\n @queue << playlist\\n if @current_playlist.nil? \\n @current_playlist = @queue.shift\\n play @current_playlist\\n end\\n end\",\n \"def push(obj)\\n if @blocked\\n raise \\\"Nothing can be added to queue. Queue is blocked.\\\"\\n else\\n super(obj)\\n end\\n end\",\n \"def enqueue(el)\\n @queue.push(el)\\n end\",\n \"def queue notification\\n @notification_queue.unshift notification\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.73733264","0.6955292","0.6735756","0.67130184","0.66893166","0.6653917","0.6616847","0.6616847","0.6570856","0.6567809","0.6546701","0.6546701","0.6535376","0.6522527","0.65144753","0.64977074","0.6428081","0.6401439","0.63853294","0.6369037","0.63337654","0.63167006","0.626524","0.6261363","0.62339073","0.6209732","0.61691535","0.61600196","0.6146505","0.6128095","0.6109104","0.60783","0.6072872","0.6069465","0.6064713","0.6051915","0.6023382","0.6022664","0.601301","0.60009134","0.59925026","0.5963659","0.59507126","0.59343386","0.5932071","0.5931611","0.5926478","0.5919275","0.59187484","0.58948976","0.5871502","0.5864935","0.58583814","0.5852346","0.5841691","0.58326495","0.5830807","0.58245647","0.58221626","0.5820358","0.5818735","0.5803106","0.5799821","0.5777787","0.5774616","0.57620025","0.57606304","0.5753554","0.57453495","0.57437056","0.5739218","0.5737206","0.5713048","0.57088476","0.5706566","0.5706566","0.57054454","0.5692888","0.56857735","0.56822985","0.56816715","0.5680343","0.5677172","0.566602","0.56659484","0.5656438","0.56542003","0.5650326","0.5630112","0.5627122","0.56255406","0.5625166","0.56183875","0.56169164","0.5615522","0.56117964","0.5601287","0.55995935","0.5588768","0.5580341","0.5579331"],"string":"[\n \"0.73733264\",\n \"0.6955292\",\n \"0.6735756\",\n \"0.67130184\",\n \"0.66893166\",\n \"0.6653917\",\n \"0.6616847\",\n \"0.6616847\",\n \"0.6570856\",\n \"0.6567809\",\n \"0.6546701\",\n \"0.6546701\",\n \"0.6535376\",\n \"0.6522527\",\n \"0.65144753\",\n \"0.64977074\",\n \"0.6428081\",\n \"0.6401439\",\n \"0.63853294\",\n \"0.6369037\",\n \"0.63337654\",\n \"0.63167006\",\n \"0.626524\",\n \"0.6261363\",\n \"0.62339073\",\n \"0.6209732\",\n \"0.61691535\",\n \"0.61600196\",\n \"0.6146505\",\n \"0.6128095\",\n \"0.6109104\",\n \"0.60783\",\n \"0.6072872\",\n \"0.6069465\",\n \"0.6064713\",\n \"0.6051915\",\n \"0.6023382\",\n \"0.6022664\",\n \"0.601301\",\n \"0.60009134\",\n \"0.59925026\",\n \"0.5963659\",\n \"0.59507126\",\n \"0.59343386\",\n \"0.5932071\",\n \"0.5931611\",\n \"0.5926478\",\n \"0.5919275\",\n \"0.59187484\",\n \"0.58948976\",\n \"0.5871502\",\n \"0.5864935\",\n \"0.58583814\",\n \"0.5852346\",\n \"0.5841691\",\n \"0.58326495\",\n \"0.5830807\",\n \"0.58245647\",\n \"0.58221626\",\n \"0.5820358\",\n \"0.5818735\",\n \"0.5803106\",\n \"0.5799821\",\n \"0.5777787\",\n \"0.5774616\",\n \"0.57620025\",\n \"0.57606304\",\n \"0.5753554\",\n \"0.57453495\",\n \"0.57437056\",\n \"0.5739218\",\n \"0.5737206\",\n \"0.5713048\",\n \"0.57088476\",\n \"0.5706566\",\n \"0.5706566\",\n \"0.57054454\",\n \"0.5692888\",\n \"0.56857735\",\n \"0.56822985\",\n \"0.56816715\",\n \"0.5680343\",\n \"0.5677172\",\n \"0.566602\",\n \"0.56659484\",\n \"0.5656438\",\n \"0.56542003\",\n \"0.5650326\",\n \"0.5630112\",\n \"0.5627122\",\n \"0.56255406\",\n \"0.5625166\",\n \"0.56183875\",\n \"0.56169164\",\n \"0.5615522\",\n \"0.56117964\",\n \"0.5601287\",\n \"0.55995935\",\n \"0.5588768\",\n \"0.5580341\",\n \"0.5579331\"\n]"},"document_score":{"kind":"string","value":"0.0"},"document_rank":{"kind":"string","value":"-1"}}},{"rowIdx":1885,"cells":{"query":{"kind":"string","value":"indique le nombre de point de vie"},"document":{"kind":"string","value":"def show_state\n puts \"#{@name} a #{@life_points} de PV\"\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def points; end","def points\n 1\n end","def points\n -1\n end","def position=(point); end","def pos() end","def pos() end","def pos() end","def pos() end","def pos; end","def pos; end","def pos; end","def pos; end","def pos; end","def pos; end","def pos\n end","def pos\n end","def pos\n end","def base_points\n points\n end","def pos=(p0) end","def pos=(p0) end","def pos=(p0) end","def pos=(p0) end","def vel\n @velocidad\n end","def add_point\n end","def subtract_point \n\t\t@lives -= 1\n\tend","def draw(type=1,index=1)\n DCL.sgplzv(vx,vy,type,index)\n end","def vertices\n end","def vertices\n end","def vat_number; end","def position; end","def position; end","def position; end","def position; end","def position; end","def position; end","def position; end","def position; end","def points\n MSPhysics::Newton::CurvySlider.get_points(@address)\n end","def points\n MSPhysics::Newton::CurvySlider.get_points(@address)\n end","def update(point)\n\t\t\t\t\n\t\t\tend","def position\n V[x, y]\n end","def points #:nodoc:\n [self]\n end","def points #:nodoc:\n [self]\n end","def vin; end","def pos()\n #This is a stub, used for indexing\n end","def pos()\n #This is a stub, used for indexing\n end","def vertices\n\tend","def addPoints(points) \n\t\t@points += points\n\tend","def up\n Point.new(@x, @y + 1)\n end","def up\n Point.new(@x, @y + 1)\n end","def x_offset; end","def pos()\n #This is a stub, used for indexing\n end","def update_visualization(point)\n\t\t\t\t\n\t\t\tend","def pos=\n end","def pos=\n end","def pos=(pos); end","def add_point(color) \n @owner = color\n @points += 1 \n @image = @@images[@owner+@points.to_s]#Gosu::Image.new(@@gosu_window, 'media/grid/'+@points.to_s+'.'+@owner+'.png', true) if @points < 4\n if over_max?(@points, @x,@y, @width-1,@height-1)\n @points = 0 \n @array[@x-1][@y].add_point(color) if @x > 0\n @array[@x+1][@y].add_point(color) if @x < @width -1\n @array[@x][@y-1].add_point(color) if @y > 0\n @array[@x][@y+1].add_point(color) if @y < @height-1\n @image = @@images[@owner+@points.to_s]#Gosu::Image.new(@@gosu_window, 'media/grid/'+@points.to_s+'.'+@owner+'.png', true) \n end\n end","def update(point)\n\t\t\n\tend","def update(point)\n\t\t\n\tend","def n\n points.size\n end","def points()\n\t\t\tfilter()\n\t\t\treturn @points_floor + @points_ceil.reverse\n\t\tend","def current_pts\n self.score\n end","def fly(x,y,z) #remeber these start with 0 in numbering!! \n\t\t@@v_row[y][x].sub!(\"#{@@v_row[y][x]}\", \"#{z}\") #find the point, and then replace with object's symbol. #FIXME Fix'd 12/16\n\t\t@position = x, y\n\tend","def source_pts; end","def add_point(point)\n return if point.x < 1 || point.y < 1 || point.x > @max_x-1 || point.y > @max_y-1\n if @glade['toolbar_move'].active?\n if @first_point \n @start = point\n @first_point = false\n @points = [@start]\n print\n else\n @finish = point\n @points = []\n move\n end\n elsif @glade['toolbar_record_points'].active?\n if @x_coords[point.x]\n @glade['statusbar'].push(@context, \"Este programa não suporta 2 ou mais pontos com mesma X-coordenada!\")\n else\n @points << point\n @x_coords[point.x] = point\n end\n print\n end\n end","def points\n []\n end","def coords_to_pos(point)\n (size - 1 - point.y) * size + point.x\n end","def get_point_position(index)\n MSPhysics::Newton::CurvySlider.get_point_position(@address, index)\n end","def get_point_position(index)\n MSPhysics::Newton::CurvySlider.get_point_position(@address, index)\n end","def x\n @point[0]\n end","def index2point(x)\n\t\treturn (@tam_ancho/2-x)\n\tend","def draw_point_id(point)\n draw_point(@points[point])\n end","def draw \n\t\tsuper(\"Lives: #{@lives.to_s}\", X, Y, 5)\n\tend","def add_to_point! point\n vectors.each do |v|\n point.add! v\n end\n point\n end","def point_x\n self.coord.split(\"_\")[0]\n end","def set_point(pt)\r\n if @point_1 == nil\r\n @point_1=pt\r\n elsif @point_2 == nil\r\n @point_2 = pt\r\n @xvect=@point_2-@point_1\r\n @bd_width.value = @xvect.length / $m2inch\r\n @yvect=Geom::Vector3d.new(0,0,1).cross(@xvect.normalize)\r\n @yvect.length =@bd_depth.value * $m2inch\r\n elsif @point_3 == nil\r\n @point_3 = pt\r\n @yvect.length=(@point_3-@point_1).length\r\n @bd_depth.value = @yvect.length / $m2inch\r\n elsif @point_4 == nil\r\n @point_4 = pt\r\n @zvect.length=(@point_4-@point_1).length\r\n @bd_height = @zvect.length / $m2inch\r\n return false\r\n end\r\n true\r\n end","def flip_range_xy(points); points.collect{ |v| Vertex.new(-v.y,-v.x)}; end","def screen_x1; @point1.screen_x; end","def index(p0) end","def index(p0) end","def point(index)\n return [index % Grid::MaxCol, index / Grid::MaxCol]\n end","def update_visualization(point)\n\t\t\n\tend","def update_visualization(point)\n\t\t\n\tend","def update_visualization(point)\n\t\t\n\tend","def update_visualization(point)\n\t\t\n\tend","def num_points\n @size * @size\n end","def initialize()\n @points = []\n end","def deco_pos; end","def rand_point()\n \n end","def vector_to(point2)\n end","def x_location_vertex\n return @ob_vx_location\n end","def relative_range_era(points)\n relative_range = []\n player = $game_player\n x,y = player.x, player.y\n points.each do |v|\n relative_range.push(Vertex.new(v.x + x, v.y + y))\n end\n relative_range\n end","def add_point(player)\n end","def at(p0) end","def total_point\n lecture.etcs_point\n end","def size\n self.points.count\n end","def add!(point)\r\n @x += point.x\r\n @y += point.y\r\n end","def initialize(points, colour) #position, points, colour)\n super(colour) #position, colour)\n @points = points\n #puts \"PointsPart\"\n #@points.each { |p| puts \"(#{p.x}, #{p.y})\" }\n end","def point(x,y)\n [x,y]\nend","def points\n object.polygon.points\n end","def points\n [top_left, top_right, bottom_left, bottom_right]\n end"],"string":"[\n \"def points; end\",\n \"def points\\n 1\\n end\",\n \"def points\\n -1\\n end\",\n \"def position=(point); end\",\n \"def pos() end\",\n \"def pos() end\",\n \"def pos() end\",\n \"def pos() end\",\n \"def pos; end\",\n \"def pos; end\",\n \"def pos; end\",\n \"def pos; end\",\n \"def pos; end\",\n \"def pos; end\",\n \"def pos\\n end\",\n \"def pos\\n end\",\n \"def pos\\n end\",\n \"def base_points\\n points\\n end\",\n \"def pos=(p0) end\",\n \"def pos=(p0) end\",\n \"def pos=(p0) end\",\n \"def pos=(p0) end\",\n \"def vel\\n @velocidad\\n end\",\n \"def add_point\\n end\",\n \"def subtract_point \\n\\t\\t@lives -= 1\\n\\tend\",\n \"def draw(type=1,index=1)\\n DCL.sgplzv(vx,vy,type,index)\\n end\",\n \"def vertices\\n end\",\n \"def vertices\\n end\",\n \"def vat_number; end\",\n \"def position; end\",\n \"def position; end\",\n \"def position; end\",\n \"def position; end\",\n \"def position; end\",\n \"def position; end\",\n \"def position; end\",\n \"def position; end\",\n \"def points\\n MSPhysics::Newton::CurvySlider.get_points(@address)\\n end\",\n \"def points\\n MSPhysics::Newton::CurvySlider.get_points(@address)\\n end\",\n \"def update(point)\\n\\t\\t\\t\\t\\n\\t\\t\\tend\",\n \"def position\\n V[x, y]\\n end\",\n \"def points #:nodoc:\\n [self]\\n end\",\n \"def points #:nodoc:\\n [self]\\n end\",\n \"def vin; end\",\n \"def pos()\\n #This is a stub, used for indexing\\n end\",\n \"def pos()\\n #This is a stub, used for indexing\\n end\",\n \"def vertices\\n\\tend\",\n \"def addPoints(points) \\n\\t\\t@points += points\\n\\tend\",\n \"def up\\n Point.new(@x, @y + 1)\\n end\",\n \"def up\\n Point.new(@x, @y + 1)\\n end\",\n \"def x_offset; end\",\n \"def pos()\\n #This is a stub, used for indexing\\n end\",\n \"def update_visualization(point)\\n\\t\\t\\t\\t\\n\\t\\t\\tend\",\n \"def pos=\\n end\",\n \"def pos=\\n end\",\n \"def pos=(pos); end\",\n \"def add_point(color) \\n @owner = color\\n @points += 1 \\n @image = @@images[@owner+@points.to_s]#Gosu::Image.new(@@gosu_window, 'media/grid/'+@points.to_s+'.'+@owner+'.png', true) if @points < 4\\n if over_max?(@points, @x,@y, @width-1,@height-1)\\n @points = 0 \\n @array[@x-1][@y].add_point(color) if @x > 0\\n @array[@x+1][@y].add_point(color) if @x < @width -1\\n @array[@x][@y-1].add_point(color) if @y > 0\\n @array[@x][@y+1].add_point(color) if @y < @height-1\\n @image = @@images[@owner+@points.to_s]#Gosu::Image.new(@@gosu_window, 'media/grid/'+@points.to_s+'.'+@owner+'.png', true) \\n end\\n end\",\n \"def update(point)\\n\\t\\t\\n\\tend\",\n \"def update(point)\\n\\t\\t\\n\\tend\",\n \"def n\\n points.size\\n end\",\n \"def points()\\n\\t\\t\\tfilter()\\n\\t\\t\\treturn @points_floor + @points_ceil.reverse\\n\\t\\tend\",\n \"def current_pts\\n self.score\\n end\",\n \"def fly(x,y,z) #remeber these start with 0 in numbering!! \\n\\t\\t@@v_row[y][x].sub!(\\\"#{@@v_row[y][x]}\\\", \\\"#{z}\\\") #find the point, and then replace with object's symbol. #FIXME Fix'd 12/16\\n\\t\\t@position = x, y\\n\\tend\",\n \"def source_pts; end\",\n \"def add_point(point)\\n return if point.x < 1 || point.y < 1 || point.x > @max_x-1 || point.y > @max_y-1\\n if @glade['toolbar_move'].active?\\n if @first_point \\n @start = point\\n @first_point = false\\n @points = [@start]\\n print\\n else\\n @finish = point\\n @points = []\\n move\\n end\\n elsif @glade['toolbar_record_points'].active?\\n if @x_coords[point.x]\\n @glade['statusbar'].push(@context, \\\"Este programa não suporta 2 ou mais pontos com mesma X-coordenada!\\\")\\n else\\n @points << point\\n @x_coords[point.x] = point\\n end\\n print\\n end\\n end\",\n \"def points\\n []\\n end\",\n \"def coords_to_pos(point)\\n (size - 1 - point.y) * size + point.x\\n end\",\n \"def get_point_position(index)\\n MSPhysics::Newton::CurvySlider.get_point_position(@address, index)\\n end\",\n \"def get_point_position(index)\\n MSPhysics::Newton::CurvySlider.get_point_position(@address, index)\\n end\",\n \"def x\\n @point[0]\\n end\",\n \"def index2point(x)\\n\\t\\treturn (@tam_ancho/2-x)\\n\\tend\",\n \"def draw_point_id(point)\\n draw_point(@points[point])\\n end\",\n \"def draw \\n\\t\\tsuper(\\\"Lives: #{@lives.to_s}\\\", X, Y, 5)\\n\\tend\",\n \"def add_to_point! point\\n vectors.each do |v|\\n point.add! v\\n end\\n point\\n end\",\n \"def point_x\\n self.coord.split(\\\"_\\\")[0]\\n end\",\n \"def set_point(pt)\\r\\n if @point_1 == nil\\r\\n @point_1=pt\\r\\n elsif @point_2 == nil\\r\\n @point_2 = pt\\r\\n @xvect=@point_2-@point_1\\r\\n @bd_width.value = @xvect.length / $m2inch\\r\\n @yvect=Geom::Vector3d.new(0,0,1).cross(@xvect.normalize)\\r\\n @yvect.length =@bd_depth.value * $m2inch\\r\\n elsif @point_3 == nil\\r\\n @point_3 = pt\\r\\n @yvect.length=(@point_3-@point_1).length\\r\\n @bd_depth.value = @yvect.length / $m2inch\\r\\n elsif @point_4 == nil\\r\\n @point_4 = pt\\r\\n @zvect.length=(@point_4-@point_1).length\\r\\n @bd_height = @zvect.length / $m2inch\\r\\n return false\\r\\n end\\r\\n true\\r\\n end\",\n \"def flip_range_xy(points); points.collect{ |v| Vertex.new(-v.y,-v.x)}; end\",\n \"def screen_x1; @point1.screen_x; end\",\n \"def index(p0) end\",\n \"def index(p0) end\",\n \"def point(index)\\n return [index % Grid::MaxCol, index / Grid::MaxCol]\\n end\",\n \"def update_visualization(point)\\n\\t\\t\\n\\tend\",\n \"def update_visualization(point)\\n\\t\\t\\n\\tend\",\n \"def update_visualization(point)\\n\\t\\t\\n\\tend\",\n \"def update_visualization(point)\\n\\t\\t\\n\\tend\",\n \"def num_points\\n @size * @size\\n end\",\n \"def initialize()\\n @points = []\\n end\",\n \"def deco_pos; end\",\n \"def rand_point()\\n \\n end\",\n \"def vector_to(point2)\\n end\",\n \"def x_location_vertex\\n return @ob_vx_location\\n end\",\n \"def relative_range_era(points)\\n relative_range = []\\n player = $game_player\\n x,y = player.x, player.y\\n points.each do |v|\\n relative_range.push(Vertex.new(v.x + x, v.y + y))\\n end\\n relative_range\\n end\",\n \"def add_point(player)\\n end\",\n \"def at(p0) end\",\n \"def total_point\\n lecture.etcs_point\\n end\",\n \"def size\\n self.points.count\\n end\",\n \"def add!(point)\\r\\n @x += point.x\\r\\n @y += point.y\\r\\n end\",\n \"def initialize(points, colour) #position, points, colour)\\n super(colour) #position, colour)\\n @points = points\\n #puts \\\"PointsPart\\\"\\n #@points.each { |p| puts \\\"(#{p.x}, #{p.y})\\\" }\\n end\",\n \"def point(x,y)\\n [x,y]\\nend\",\n \"def points\\n object.polygon.points\\n end\",\n \"def points\\n [top_left, top_right, bottom_left, bottom_right]\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.7319244","0.6943422","0.6928855","0.6703674","0.6554638","0.6554638","0.6554638","0.6554638","0.6466883","0.6466883","0.6466883","0.6466883","0.6466883","0.6466883","0.6367322","0.6367322","0.6367322","0.6361447","0.6324097","0.6324097","0.6324097","0.6324097","0.62462467","0.6234002","0.6197398","0.61579555","0.61404455","0.61404455","0.6126536","0.60967755","0.60967755","0.60967755","0.60967755","0.60967755","0.60967755","0.60967755","0.60967755","0.6083183","0.6083183","0.6068725","0.6063675","0.6062458","0.6062458","0.6050478","0.6047474","0.6047474","0.60210925","0.598274","0.5979955","0.5979955","0.5964709","0.5964195","0.5961826","0.5958073","0.5958073","0.59561914","0.59552145","0.5953566","0.5953566","0.59449655","0.5942389","0.59340024","0.592479","0.5917921","0.59120655","0.59091294","0.59063184","0.5899032","0.5899032","0.5898473","0.5879836","0.5869854","0.5863411","0.58578753","0.58458614","0.5844325","0.5842734","0.582464","0.5813522","0.5813522","0.5810841","0.577465","0.577465","0.577465","0.577465","0.5759315","0.57591254","0.5746762","0.57446027","0.57395256","0.57387865","0.5733755","0.5733044","0.5732512","0.5726867","0.5718277","0.5716424","0.5715397","0.57024163","0.56920165","0.56868845"],"string":"[\n \"0.7319244\",\n \"0.6943422\",\n \"0.6928855\",\n \"0.6703674\",\n \"0.6554638\",\n \"0.6554638\",\n \"0.6554638\",\n \"0.6554638\",\n \"0.6466883\",\n \"0.6466883\",\n \"0.6466883\",\n \"0.6466883\",\n \"0.6466883\",\n \"0.6466883\",\n \"0.6367322\",\n \"0.6367322\",\n \"0.6367322\",\n \"0.6361447\",\n \"0.6324097\",\n \"0.6324097\",\n \"0.6324097\",\n \"0.6324097\",\n \"0.62462467\",\n \"0.6234002\",\n \"0.6197398\",\n \"0.61579555\",\n \"0.61404455\",\n \"0.61404455\",\n \"0.6126536\",\n \"0.60967755\",\n \"0.60967755\",\n \"0.60967755\",\n \"0.60967755\",\n \"0.60967755\",\n \"0.60967755\",\n \"0.60967755\",\n \"0.60967755\",\n \"0.6083183\",\n \"0.6083183\",\n \"0.6068725\",\n \"0.6063675\",\n \"0.6062458\",\n \"0.6062458\",\n \"0.6050478\",\n \"0.6047474\",\n \"0.6047474\",\n \"0.60210925\",\n \"0.598274\",\n \"0.5979955\",\n \"0.5979955\",\n \"0.5964709\",\n \"0.5964195\",\n \"0.5961826\",\n \"0.5958073\",\n \"0.5958073\",\n \"0.59561914\",\n \"0.59552145\",\n \"0.5953566\",\n \"0.5953566\",\n \"0.59449655\",\n \"0.5942389\",\n \"0.59340024\",\n \"0.592479\",\n \"0.5917921\",\n \"0.59120655\",\n \"0.59091294\",\n \"0.59063184\",\n \"0.5899032\",\n \"0.5899032\",\n \"0.5898473\",\n \"0.5879836\",\n \"0.5869854\",\n \"0.5863411\",\n \"0.58578753\",\n \"0.58458614\",\n \"0.5844325\",\n \"0.5842734\",\n \"0.582464\",\n \"0.5813522\",\n \"0.5813522\",\n \"0.5810841\",\n \"0.577465\",\n \"0.577465\",\n \"0.577465\",\n \"0.577465\",\n \"0.5759315\",\n \"0.57591254\",\n \"0.5746762\",\n \"0.57446027\",\n \"0.57395256\",\n \"0.57387865\",\n \"0.5733755\",\n \"0.5733044\",\n \"0.5732512\",\n \"0.5726867\",\n \"0.5718277\",\n \"0.5716424\",\n \"0.5715397\",\n \"0.57024163\",\n \"0.56920165\",\n \"0.56868845\"\n]"},"document_score":{"kind":"string","value":"0.0"},"document_rank":{"kind":"string","value":"-1"}}},{"rowIdx":1886,"cells":{"query":{"kind":"string","value":"Create an empty page with necessary assets for project +p+"},"document":{"kind":"string","value":"def create_empty_page(p)\n cli.say 'Creating project page'\n FileUtils.mkdir_p(browse_file(p, '.'))\n %w[favicon-32.png style.css].each do |i|\n FileUtils.cp(template_file(i), browse_file(p, i))\n end\n write_file(p, 'about.html') do\n build_from_template('about.html', citation: MiGA::MiGA.CITATION)\n end\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def generate_project_page(p)\n # Redirect page\n write_file(p, '../index.html') { build_from_template('redirect.html') }\n\n # Summaries\n summaries = Dir[\"#{p.path}/*.tsv\"].map do |i|\n b = File.basename(i, '.tsv')\n generate_summary_page(i, p)\n \"

  • #{format_name(b)}
  • \"\n end.join('')\n\n # Project index page\n data = {\n project_active: 'active',\n information: format_metadata(p),\n summaries: summaries.empty? ? 'None' : \"
      #{summaries}
    \",\n results: format_results(p)\n }\n write_file(p, 'index.html') { build_from_template('index.html', data) }\n end","def create(p)\n puts \"Creating page #{p}\"\n Dir.mkdir p unless File.exists? p\n Content.new(\"#{@dir}\", @extension).page p\n end","def create\r\n html=params[:page][:html]\r\n @page = Page.new(params[:page])\r\n respond_to do |format|\r\n if @page.save\r\n format.html { redirect_to @page, notice: 'Page was successfully created.' }\r\n format.json { render json: @page, status: :created, location: @page }\r\n target = \"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\"\r\n if !File.directory?(\"#{Rails.public_path}/#{@page.project_id}\")\r\n Dir.mkdir(\"#{Rails.public_path}/#{@page.project_id}\")\r\n Dir.mkdir(\"#{Rails.public_path}/#{@page.project_id}/images\")\r\n end\r\n File.open(target, \"w+\") do |f|\r\n f.write(html)\r\n end\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @page.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end","def setup\n @page = pages(:homepage)\n end","def create_base_project\n puts \"creating base project\"\n directory \"templates\", \"#{app_path}\"\n end","def generate\n # Ensure site is a directory\n FileUtils.mkdir_p site_path\n\n # If there is more than one language, then we need to create\n # multiple files, one for each language.\n if languages.size >= 1\n\n # Enter the most dastardly loop. \n # Create a View::Document with sections only containing the \n # specified language. \n languages.map do |language|\n document_views = documents.map do |document|\n document.sections = document.sections.map do |section|\n section.examples = section.examples.select {|ex| ex.language.blank? || ex.language == language }\n section\n end\n\n Views::Document.new document\n end\n\n # Use Mustache to create the file\n page = Page.new\n page.title = title\n page.logo = File.basename logo if logo\n page.documents = document_views\n\n File.open(\"#{site_path}/#{language.underscore}.html\", \"w\") do |file|\n file.puts page.render\n end\n end\n\n # copy the default language to the index and were done!\n FileUtils.cp \"#{site_path}/#{default.underscore}.html\", \"#{site_path}/index.html\"\n\n # There are no languages specified, so we can just create one page\n # using a collection of Document::View.\n else \n document_views = documents.map do |document|\n Views::Document.new document\n end\n\n page = Page.new\n page.title = title\n page.logo = File.basename logo if logo\n page.documents = document_views\n\n File.open(\"#{site_path}/index.html\", \"w\") do |file|\n file.puts page.render\n end\n end\n\n # Copy the logo if specified\n FileUtils.cp \"#{logo}\", \"#{site_path}/#{File.basename(logo)}\" if logo\n\n # Copy all the stylesheets into the static directory and that's it!\n resources_path = File.expand_path \"../resources\", __FILE__\n\n FileUtils.cp \"#{resources_path}/style.css\", \"#{site_path}/style.css\"\n FileUtils.cp \"#{resources_path}/syntax.css\", \"#{site_path}/syntax.css\"\n end","def write_page\n contents = [people,projects,events].inject({}) { |x,y| x.merge(y) }\n File.open('index.html','w') do |f|\n f.write(@template.render(contents))\n end\n end","def create_default_template_file\n unless self.description.redirection_required?\n self.localizations.each do |page_localization|\n file_path = File.join(Rails.root, \"app\", \"views\" , \"pages\" , \"#{self.view}.#{page_localization.locale.slug}.html.haml\" )\n unless File.exists?(file_path)\n file = File.new(file_path, \"w\")\n\n page_localization.contents.each do |content|\n file.puts(\"= @page.easy_contents(:#{content.section_name})\")\n end\n file.close\n end\n end\n end\n end","def generate_page file\n setup\n\n template_file = @template_dir + 'page.rhtml'\n\n out_file = @outputdir + file.path\n debug_msg \" working on %s (%s)\" % [file.full_name, out_file]\n rel_prefix = @outputdir.relative_path_from out_file.dirname\n search_index_rel_prefix = rel_prefix\n search_index_rel_prefix += @asset_rel_path if @file_output\n\n current = file\n asset_rel_prefix = rel_prefix + @asset_rel_path\n\n @title = \"#{file.page_name} - #{@options.title}\"\n\n debug_msg \" rendering #{out_file}\"\n render_template template_file, out_file do |io|\n here = binding\n # suppress 1.9.3 warning\n here.local_variable_set(:current, current)\n here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)\n here\n end\n end","def generate_main_page_with(specs)\n main_page = Amy::Model::Main.new\n specs['resources'].each_pair { |resource, options|\n main_page.add_resource( { 'resource' => resource, 'title' => options['title'] } )\n }\n main_page.links = specs['links'] || []\n main_page.version = specs['api_version']\n main_page.base_url = specs['base_url']\n @generator.do(\"#{Amy::BASE_DIR}/views/main.erb.html\", main_page)\n end","def webpage\n render(:webpage, layout:false) and return\n end","def create\n flash[:notice] = 'The page was successfully created.' if page.save\n respond_with(page, location: project_page_path(page.project, page))\n end","def new\n @project = Project.new\n\n render :layout => \"empty\"\n end","def create_test_page(options = {})\n no_part = options.delete(:no_part)\n page = super(options)\n unless no_part\n part = PagePart.new part_params(:name => 'body', :content => 'test')\n page.parts << part\n page.save\n part.save\n end\n page\n end","def create_project\n empty_directory(project)\n end","def new\n @page = @site.pages.new\n @page.parts << PagePart.new(:name => \"body\")\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end","def first_mandate\n # renders static page\n end","def testem_page\n testem_fields(\n \"#{Prawn::DATADIR}/images/reports/CEM2030-2012_Page_01.pdf\"\n # \"#{Rails.root}/app/assets/images/reports/testem_fields.pdf\"\n # \"#{Rails.root}/app/assets/pdfs/testem.png\"\n )\n start_new_page\n end","def init\n @title_page = 'Pine app'\n erb :welcome, layout: :template\nend","def default_page\n\t\t\t\tDir.chdir File.join(self.source, @site_name)\n\t\t\t\tFile.open Settings::PAGES_TEMPLATE + '/page.md', 'r' do |file|\n\n\t\t\t\t\tfront_matter = {\n\t\t\t\t\t\t'title' => 'Home Page',\n\t\t\t\t\t\t'date' => Time.now.strftime(\"%Y-%m-%d\"),\n\t\t\t\t\t\t'author' => 'Your Name',\n\t\t\t\t\t\t'template' => 'page'\n\t\t\t\t\t}\n\n\t\t\t\t\tcontents = Liquid::Template.parse(file.read).render front_matter \n\t\t\t\t\tFile.open(File.join(\"pages\", \"index.md\"), \"w\") do |f|\n\t\t\t\t\t\tf.write contents\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tFileUtils.mkdir_p(File.join(self.source, @site_name, \"media/images\", \"index\"))\n\t\t\tend","def create_project(tx)\n Installer.copy(tx, \"#{@service_dir}/pieces/public\", get_path(:web))\n true\n end","def add_template_pages; end","def build\r\n self.ehtml, self.ecss, self.ejs = self.theme.page_layout.build_content() \r\n return self.ehtml, self.ecss, self.ejs\r\n end","def create\r\n @project = current_user.projects.new(project_params)\r\n new_page = @project.pages.new({ name: generate_new_page_name})\r\n @project.startpage = new_page\r\n @project.date_created = Time.now\r\n @project.last_modified = Time.now\r\n respond_to do |format|\r\n if @project.save\r\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\r\n format.json { render action: 'show', status: :created, location: @project }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @project.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end","def to_page\n \n u = User.find_by_login(authorid)\n \n UserActionObserver.current_user = u\n \n page = Page.new(\n :title => title,\n :created_at => lastmod,\n :updated_at => lastmod,\n :slug => url_title,\n :status => Status[:published],\n :breadcrumb => title,\n :published_at => posted, \n :enable_comments => annotate.to_s,\n :keywords => keywords,\n :created_by => u,\n :updated_by => u\n )\n \n page.parts << PagePart.new(:name => 'body', :filter_id => \"Textile\", :content => body )\n page.parts << PagePart.new(:name => 'intro', :filter_id => \"Textile\", :content => body.split(/\\r\\n\\s*\\r\\n/).first)\n \n page\n end","def create_page\n segments = self.slug.split('/').find_all { |segment| segment != '' }\n max_segments = segments.size\n\n while segment = segments.pop do\n _options = self.page_options(slug: segment, translated: false)\n file_path = File.join(pages_path, segments, segment)\n\n # the content type option is never deleted for the first segment (the requested template)\n _options.delete(:content_type) unless segments.size == (max_segments - 1)\n\n template 'template.liquid.tt', \"#{file_path}.liquid\", _options\n\n self.other_locales.each do |locale|\n _options[:translated] = true\n template 'template.liquid.tt', \"#{file_path}.#{locale}.liquid\", _options\n end\n end\n end","def load_index_page\n @page ||= Language.current_root_page\n render template: \"alchemy/welcome\", layout: false if signup_required?\n end","def files_to_page\n insert_to_page('div', html)\n insert_to_page('script', js, false)\n insert_to_page('style', style, false)\n end","def create_base_project\n raise GeneratorArgumentsError if app_path.nil?\n puts \"creating base project\"\n directory \"templates\", \"#{app_path}\"\n end","def create_page\n @outfile.puts <<'EOF'\n\n\n \n Fun Fun Fun\n \nEOF\n\n include_stylesheets\n include_javascript\n add_data(@batch)\n @outfile.puts <<'EOF'\n \n \n \n \n \n\nEOF\n end","def index\n @page = Page.new\n end","def new\n @brigade_project = BrigadeProject.new\n general_static_response(@brigade_project)\n end","def create_page(site, source_file, relative_dir, file_name, langcode, includelang = false, process = true)\n # Don't process underscore files.\n return if relative_dir =~ /^_/\n\n case source_file\n when /\\.(markdown|html)|sitemap\\.xml|feed\\.xml/\n # Markdown is our main content language, create a page.\n page = LanguagePage.new(site, site.source, relative_dir, file_name, langcode, includelang)\n site.pages << page if process\n page\n when /\\.(png|jpg|gif|css|mp4|webm|vtt|svg|mp3)/\n # Copy across other assets.\n asset = LanguageAsset.new(site, site.source, relative_dir, file_name, langcode, includelang)\n site.static_files << asset if process\n nil\n end\n end","def create_theme\n empty_directory(VIEW_PATH)\n\n if partial\n if partial.index('/')\n (extra_dirs, partial_name) = partial.match(/^(.*)\\/(.*)$/).captures\n\n empty_directory(\"#{VIEW_PATH}/#{file_name}/#{extra_dirs}\")\n\n copy_file(\n \"#{extra_dirs}/_#{partial_name.match(/^text_as_/) ? 'text' : partial_name}.html.erb\",\n \"#{VIEW_PATH}/#{file_name}/#{extra_dirs}/_#{partial_name}.html.erb\"\n )\n else\n copy_file(\"_#{partial}.html.erb\", \"#{VIEW_PATH}/#{file_name}/_#{partial}.html.erb\")\n end\n else\n directory('', \"#{VIEW_PATH}/#{file_name}\")\n end\n end","def generate_project_file\n template_file = @template_dir + 'hhp_file.hhp.rhtml'\n\n @values = { :title => @options.title, :opname => @outputdir.basename }\n \n static_files = ['index.html', 'classindex.html', 'fileindex.html']\n @values[:html_files] = static_files + (@generated_files+@classes).map{|f| f.path}.uniq\n \n out_file = @outputdir + @project_name\n debug_msg \" rendering #{out_file}\"\n render_template template_file, out_file do |io| binding end\n end","def create_default_page_template\n PageTemplate.create(:name => 'default')\n end","def index_prebuilt!\n Dir.glob(\"#{PREBUILT_DIR}/**/[^_]*.*\") do |filename|\n config.add_page(filename.sub(\"#{PREBUILT_DIR}/\", ''), file: filename, digest: true)\n end\n end","def new\n \t@pagenav = Page.find_all_by_published('true')\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end","def write_pages\n pages = Dir[\"#{source_path}/*.html\"].each do |p_name|\n page = Page.new(source_path, File.basename(p_name))\n # TODO allow user to specify which layouts a page should use \n page.render(site_payload, layouts.select{|x| x.name == \"application.html\"})\n page.write(destination_path)\n end\n end","def html_page\n <<-END.gsub(/^\\s+/, '')\n \n Why Fixturing Is Annoying\n \n \n \n
    \n \n END\n end","def prepare_project_header_and_footer\n @header_text = @project.templets.find_by_name('PAGE_HEADER').render( @project )\n @footer_text = @project.templets.find_by_name('PAGE_FOOTER').render( @project )\n end","def new\n @pages = Page.new\n #renders new.html.erb\n end","def new\n @page = Page.new\n @pagelist = @club.all_pages\n \n @page_title = \"New Page\"\n @site_section = \"admin\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end","def build( special_contexts=[] )\r\n\r\n self.ehtmls, self.ecss, self.ejs = self.theme.original_page_layout_root.build_content(special_contexts)\r\n self.ehtml = self.ehtmls.first\r\n\r\n end","def new\n @project = Project.new\n @title = \"New Project\"\n end","def new\r\n @event = Event.new\r\n #@pages = Page.all\r\n @projects_pages = []\r\n projects = Project.all.sort{|a,b| a.name <=> b.name}\r\n projects.each do |project|\r\n @projects_pages << [\"#{project.name}\", project.pages.exclude_placeholder] unless project.pages.blank?\r\n end\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @event }\r\n end\r\n end","def build_page(path, silent: false)\n page = sitemap[path]\n out_fname = File.join(BUILD_DIR, path)\n puts \"Rendering #{out_fname}...\" unless silent\n\n # Check page data for info on how to build this path\n if page['template'].present?\n ctx = TemplateContext.new(@config)\n ctx.page = page\n # Check if we have a layout defined, use it\n layout = ctx.page.key?('layout') ? ctx.page['layout'] : config['layout']\n\n # Make sure to render the template inside the layout render so code in the\n # erb layout and template are executed in a sensible order.\n content =\n if layout.present?\n ctx.render(layout) { ctx.render(ctx.page['template']) }\n else\n ctx.render(ctx.page['template'])\n end\n elsif page['json'].present?\n content = page['json'].to_json\n elsif page['file'].present?\n content = File.read(page['file'])\n else\n raise(\n ArgumentError,\n \"Page '#{path}' missing one of required attributes: 'template', 'json', 'file'.\"\n )\n end\n\n # If page data includes a digest flag, add sha1 digest to output filename\n if page['digest'] == true\n ext = VizBuilder.fullextname(path)\n fname = File.basename(path, ext)\n dir = File.dirname(path)\n digest = Digest::SHA1.hexdigest(content)\n digest_fname = \"#{fname}-#{digest}#{ext}\"\n page['digest_path'] = \"#{dir}/#{digest_fname}\"\n out_fname = File.join(BUILD_DIR, dir, digest_fname)\n end\n\n FileUtils.mkdir_p(File.dirname(out_fname))\n File.write(out_fname, content)\n content\n end","def new\n #creates a new page only in memory\n @page = Page.new\n end","def generate\n verify_path\n \n self.layouts.each {|layout| layout.write_file}\n self.pages.each {|page| page.write_file}\n \n Webby.site.content_dir = self.content_dir\n Webby.site.layout_dir = self.layout_dir\n Webby.site.template_dir = self.template_dir\n Webby.site.output_dir = self.output_dir\n \n Merb.logger.debug \"content_dir: #{Webby.site.content_dir}\"\n Merb.logger.debug \"layout_dir: #{Webby.site.layout_dir}\"\n Merb.logger.debug \"template_dir: #{Webby.site.template_dir}\"\n Merb.logger.debug \"output_dir: #{Webby.site.output_dir}\"\n \n # Use directory => '.' option to generate the site in output_dir\n Webby.site.page_defaults = {'layout' => self.default_layout.relative_path,\n 'directory' => '.',\n 'collision' => :force}\n \n Merb.logger.debug \"page_defaults: #{Webby.site.page_defaults}\" \n # returns nil if success \n # Webby::Builder.run\n Webby::Builder.run :rebuild => true\n end","def template_page(site); end","def about\n # Static Page\n end","def index\n @pages = Page.all\n render layout: 'application'\n end","def generate_Song_Pages\n template_doc = File.open(\"lib/templates/song.html.erb\")\n template = ERB.new(template_doc.read)\n Song.all.each do |song|\n File.write(\"_site/song/#{song.url}\", template.result(binding))\n end\n end","def new\n @page = Page.new\n end","def new\n @page = Page.new\n end","def new\n @page = Page.new\n end","def new\n @page = Page.new\n end","def index\n @dynamic_project_pages = DynamicProjectPage.all\n end","def generate_content\n @pdf = Prawn::Document.new(\n info: self.metadata,\n top_margin: @format[:header_size] + @format[:top_margin],\n bottom_margin: @format[:footer_size] + @format[:bottom_margin]\n )\n add_page_body\n add_page_header\n add_page_footer\n add_page_numbering\n end","def create_blank_post(path, title)\n # Create the directories to this path if needed\n FileUtils.mkpath(File.dirname(path))\n\n # Write the template to the file\n File.open(path, \"w\") do |f|\n f << <<-EOS.gsub(/^ /, '')\n ---\n layout: post\n title: #{title}\n published: false\n ---\n\n EOS\n end\nend","def new\n add_breadcrumb \"Nouveau\"\n @project = Project.new\n end","def generate\n add_intro\n add_blood_pressure_intro\n add_blood_pressure_list\n add_blood_pressure_outro\n add_medications_intro\n add_medications_list\n add_about\n\n @pdf\n end","def initialize(options) #:not-new:\n @options = options\n load_html_template\n @main_page_path = nil\n end","def new\r\n session[:from_page] = params[:from_page]\r\n session[:from_event] = params[:from_event]\r\n\r\n @project = Project.new\r\n @project.build_project_image\r\n @project.project_web_links.build\r\n @funders = Funder.all\r\n\r\n respond_to do |format|\r\n format.html {render :layout => 'backend'} # new.html.erb\r\n format.xml { render :xml => @project }\r\n end\r\n end","def new_page\n @vendor = Vendor.find(current_user)\n @page = Page.new\n @page.site_id = params[:site_id]\n @page.template_id = 1\n @page.page_name = \"PAGE\"\n @page.language = \"en\"\n @page.theme_id = 1 \n respond_to do |format|\n if @page.save\n #Construct the path for the destination page file\n @page_path = 'public/sites/' + @vendor.id.to_s + \"/\" + @page.site_id.to_s + \"/\" + @page.id.to_s + '.html' \n File.open(@page_path, \"w+\") do |f|\n f.write(\"Page \" + @page.id.to_s + \"\") \n end\n #redirect to the view and render the partial\n format.html { redirect_to page_manage_path}\n format.js\n format.json { render json: @page, \n status: :created, location: @page }\n else \n format.html { render action: \"new\" }\n format.json { render json: @page.errors,\n status: :unprocessable_entity }\n end\n end\n end","def pages\n plantuml_files.map { |static_file| page_from_static_file(static_file) }\n end","def create\n #Each Page could be tied to an ApiKey or set of ApiKeys for security\n @page = Page.new(page_params)\n #Render the object created or errors\n respond_to do |format|\n if @page.save\n #Cache bust pages\n Rails.cache.delete(\"pages\")\n format.json { render action: 'show', status: :created, location: api_page_url(@page) }\n else\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end","def create_all!\n if title_card_path.exist?\n Dir\n .glob(story.screenshots.join(\"*page*.png\"))\n .sort_by { |path| path.scan(/\\d+/).first.to_i }\n .each do |path|\n\n path.slice! File.extname(path) # drop the extension\n @paths[:pages] << absolute(path) # store the result in the index\n end\n return\n end\n\n FileUtils.mkdir_p story.screenshots\n browser.add_script_tag content: <<~JS\n pageflow.ready.then(function() {\n $('.multimedia_alert').remove()\n })\n JS\n\n # Grab all navigable pages.\n browser.goto story.url\n sleep 10\n pages = browser.css('#scrollytelling-navigation a')\n puts \"#{pages.length} screenshots in #{story.screenshots}\"\n\n pages.each_with_index do |link, index|\n perma_id = link.attribute('href')[/#(\\d*)\\z/, 1]\n url = [story.url, link.attribute('href')].join\n filename = [story.slug, 'page', index + 1, \"#{perma_id}.png\"].join('-')\n next if File.exist?(story.screenshots.join(filename))\n\n print \"#{url} \"\n browser.goto url\n sleep 3\n\n until browser.at_css('body').attribute('class').include? 'finished-loading'\n sleep 1\n end\n\n browser.screenshot(path: story.screenshots.join(filename))\n @paths[:pages] << absolute(story.screenshots.join(filename))\n puts \"✅ #{filename}\"\n end\n\n # Grab the opening page; when this exists, all screens are complete.\n browser.goto story.url\n sleep 10\n\n browser.screenshot(full: true, path: title_card_path)\n @paths[:title] = absolute(title_card_path)\n\n browser.quit\n end","def generate_index\n setup\n\n template_file = @template_dir + 'index.rhtml'\n return unless template_file.exist?\n\n debug_msg \"Rendering the index page...\"\n\n out_file = @base_dir + @options.op_dir + 'index.html'\n rel_prefix = @outputdir.relative_path_from out_file.dirname\n search_index_rel_prefix = rel_prefix\n search_index_rel_prefix += @asset_rel_path if @file_output\n\n asset_rel_prefix = rel_prefix + @asset_rel_path\n\n @title = @options.title\n\n render_template template_file, out_file do |io|\n here = binding\n # suppress 1.9.3 warning\n here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)\n here\n end\n rescue => e\n error = RDoc::Error.new \\\n \"error generating index.html: #{e.message} (#{e.class})\"\n error.set_backtrace e.backtrace\n\n raise error\n end","def render_pages(static_path)\n puts \" Rendering pages\"\n Page.all.each do |p|\n if p.published? && (body = p.render)\n dir, filename = p.url, \"index.html\"\n dir, filename = p.parent.url, p.slug if p.slug =~ /\\.[^.]+$/i # File with extension (e.g. styles.css)\n FileUtils.mkdir_p(File.join(static_path, dir))\n File.open(File.join(static_path, dir, filename), 'w') { |io| io.print(body) }\n else\n puts \" ! Not rendering #{p.id} - #{p.status.name} - #{p.url}\"\n end\n end\nend","def index\n @main_page = \"Pessoal\"\n @page_title = \"Projetos\"\n @projects = Project.all\n @current_projects = Project.current_projects\n end","def generate_all\n copy_template_dir('layouts', 'layouts')\n copy_template_dir('content/bootstrap', 'content/bootstrap')\n copy_template_dir('content/content', 'content/content')\n delete_target_file('lib/default.rb')\n copy_template_dir('lib', 'lib')\n delete_target_file('Rules')\n copy_template_file('Rules', 'Rules')\n copy_template_file('.gitignore', '.gitignore')\n copy_template_file('cg_config.rb', 'cg_config.rb')\n copy_template_file('cg_config.rb_sample', 'cg_config.rb_sample')\n delete_target_file('content/stylesheet.css')\n delete_target_file('content/index.html')\n delete_target_file('layouts/default.html')\n create_empty_dir('content/images')\n end","def new\n\t\t\tlogger.debug \"******* paths loaded are #{Rails.application.config.assets.paths}\"\n\t\t\t@landing_page = LandingPage.new\n\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html # new.html.erb\n\t\t\t\tformat.json { render json: @landing_page }\n\t\t\tend\n\t\tend","def execute!\n make_web_directory\n generate_universe\n generate_html\n print_success_message\n end","def create\n redirect_to pages_path\n end","def create_blank_post(path, title)\n # Create the directories to this path if needed\n FileUtils.mkpath(File.dirname(path))\n\n # Write the template to the file\n File.open(path, \"w\") do |f|\n f << <<-EOS.gsub(/^ /, '')\n ---\n layout: post\n title: #{title}\n published: false\n categories:\n ---\n\n EOS\n end\nend","def create_blank_post(path, title, date)\n # Create the directories to this path if needed\n FileUtils.mkpath(File.dirname(path))\n\n # Write the template to the file\n File.open(path, \"w\") do |f|\n f << <<-EOS.gsub(/^ /, '')\n ---\n title: #{title}\n category: Code\n layout: post\n date: #{date}\n ---\n\n EOS\n end\nend","def generate()\n prepare\n ::Dir.mkdir(@output_path) unless ::File.exists? @output_path\n\n @pages.each do |name, page|\n SiteLog.debug(\"Starting page generation - #{name}\")\n page.generate(@output_path, @version, @preserve_tree)\n SiteLog.debug(\"Finished page generation - #{name}\")\n end\n\n @files.each do |path, data|\n path = ::File.join(@output_path, path)\n ::FileUtils.mkdir_p(::File.dirname(path))\n ::File.open(path, \"w\") do |f|\n f.write(data)\n end\n end\n end","def add_blank_page_if_needed\n pdf_generator.generate(\n Summary::BlankPage.new(c100_application), copies: 1\n ) if has_forms_data?\n end","def new\n @page = Page.new\n #render :new - app/views/pages/new.html.erb\n end","def designer\r\n @page = Page.find(params[:id])\r\n data = File.read(\"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\")\r\n @page.update_attribute(:html , data)\r\n render 'designer'\r\n end","def new\n @page = Page.new\n # render new.html.erb\n end","def new\n @page = Page.new\n # render new.html.erb\n end","def new\n @isgrey = true;\n @current_page = \"ADD PROJECT\"\n @project = Project.new\n @project_attachment = @project.project_attachments.build\n @slider_object = @project.slider_objects.build\n @project_field = @project.project_fields.build\n @project_other_field = @project.project_other_fields.build\n\n @types = Type.all\n @new_nav = true;\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end","def generate!\n controllers = (Rails.application.routes.routes.map do |route|\n controller_name = \"#{route.requirements[:controller].camelize}Controller\"\n ActiveSupport::Dependencies.ref(controller_name).get\n end).insert(0, ApplicationController).uniq\n\n valid_controllers = valid_controllers()\n valid_locales = valid_locales()\n\n controllers.each do |controller|\n controller_path = controller.controller_path\n if controller.respond_to?(:managable_content_for) && valid_controllers.include?(controller_path)\n Page.transaction do\n valid_locales.each do |locale|\n # Create Page if it does not exist yet\n page = Page.where(:controller_path => controller_path, :locale => locale).first || Page.new()\n if page.new_record?\n page.controller_path = controller_path\n page.locale = locale\n page.save!\n end\n\n # Create PageContent if it does not exist yet\n contents = (controller == ApplicationController) ? controller.managable_layout_content_for : controller.managable_content_for\n contents.each do |key|\n if page.page_contents.where(:key => key).first.nil?\n page_content = page.page_contents.build\n page_content.key = key\n page_content.save!\n end\n end\n end\n end\n end\n end\n end","def new\n\t\t@project = Project.new({:project_state_type_id => ProjectStateType.find_by_code('preparation').id})\n\t\tputs @project.inspect\n\t\tmake_breadcrumbs\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.json { render json: @project }\n\t\tend\n\tend","def write\n if root?\n index_file = File.join(page_dir, 'index.html')\n notice \"Writing top level index file at #{index_file}\"\n File.open(index_file, 'w') {|f| f.puts content}\n else\n # First create the index page\n index_file = File.join(page_dir, name + '.html')\n notice \"Writing index file for directory #{path} at #{index_file}\"\n File.open(index_file, 'w') {|f| f.puts content}\n\n # Create a directory to contain index pages for any child directories\n Dir.mkdir(File.join(page_dir, name))\n end\n dirs.sort.each{|dir| dir.write}\n\n # Determine if the page assets directory is necessary, to avoid clutter\n writing_page_assets = true\n begin\n # Detect whether the write_page_assets method is overridden\n # In case this explodes in 1.8.6 we'll always create the directory\n writing_page_assets = renderer.class.instance_method(:write_page_assets).owner != DirRenderer\n rescue\n end\n\n # The renderer knows what assets are linked to and what needs to be available\n # to display the page properly\n if writing_page_assets\n Dir.mkdir(page_assets_dir)\n renderer.write_page_assets(self)\n end\n end","def copy_page\n File.open(Rails.root.join('public', 'testing.html'), 'wb') { |f| f << page.body }\n end","def new\n @page = Page.new\n # render :new app/views/pages/new.html.erb\n end","def test_create_page\n file = Configuration.TEST_PAGE\n \n # This test depends on a succesfull login\n if test_correct_login\n token = make_login Configuration.USER, Configuration.PASSWORD\n else\n return false\n end\n \n page_key = 'page-test-' + random_string(Configuration.PAGE_KEY_RS_SIZE)\n res = post_page file, token, page_key, 'test-tag', 'This is a Test Page'\n \n # Remove the just created page\n remove_page page_key, token\n \n puts \"\\nTester#test_create_page:\\n#{res}\" if Configuration.VERBOSE\n res == Constants.SUCCESS_MESSAGE\n end","def create\n url = params['url']\n doc = Crawl::PageHandler.fetch_page(url)\n page_data = Crawl::PageHandler.parse_page(url, doc)\n page = Page.create(url: url,\n chksum: Zlib.crc32(url),\n parsed: page_data.to_json)\n render json: { url: page[:url],\n chksum: page[:chksum],\n parsed: page[:parsed] }\n end","def isite\n render layout: 'parallax'\n end","def init\t\n\tenable :static\n\tset :statics_folder, 'statics'\n\tset :deep_or_flat_structure, 'flat'\n\n\tset :public_folder, settings.statics_folder\n\n\tset :page_pool, page_pool()\nend","def generate_html\n # the individual descriptions for files and classes\n gen_into(@files)\n gen_into(@classes)\n # and the index files\n gen_file_index\n gen_class_index\n gen_method_index\n gen_main_index\n\n # this method is defined in the template file\n write_extra_pages if defined? write_extra_pages\n end","def new\n @content_page = ContentPage.new :page_layout => \"default\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @content_page }\n end\n end","def splash_page\n end","def index\n\t @title = \"Miradi Data Server\"\n\t \"Welcome to the Miradi Data Server!
    \" +\n\t\t\"
    \" + \n\t\t\"Project Name: \" +\n\t\t\"\" + \n\t\t\"
    \"\n\tend","def preview\n \n # @lg = PageTag::PageGenerator.previewer( @menu, @theme, {:resource=>(@resource.nil? ? nil:@resource),:controller=>self})\n # html = @lg.generate\n # css,js = @lg.generate_assets \n #insert css to html\n # style = %Q!!\n #editor_panel require @theme, @editors, @editor ...\n # html.insert(html.index(\"\"),style)\n # html.insert(html.index(\"\"),@editor_panel)\n # respond_to do |format|\n # format.html {render :text => html}\n # end\n \n end","def show\n \n if Page.count==0\n ensure_homepage\n else\n @page = @page || Page.find_by_alias(app_path)\n # TODO: add the ability for the user to choose whether to render the page or use it as a redirect\n #path = @page.path == '/' ? 'index' : @page.path\n #redirect_to @page.url unless path==app_path\n end\n\n if @page.nil?\n if admin?\n flash[:notice]=\"The page you requested does not exist. Would you like to create it?\"\n @page = Page.new(:path=>app_path)\n @page_template = \"admin\"\n render :action=>'new'\n else\n render :file => \"#{RAILS_ROOT}/public/404.html\", :layout => false, :status => 404\n end\n else\n @app_path=@page.path\n @title = @page.title\n @page_description = @page.description\n\n # Even though the printable pages are rendered in a different layout\n # they also need a different template, since this template should only\n # have a single column\n \n if params[:print] && params[:print] == \"true\"\n @page_template = \"print\"\n elsif @page.url =~ /moving_from_caregivers_menu/\n @page_template = \"template_caregivers\"\n elsif @page.url =~ /moving_from_providers_menu/\n @page_template = \"template_providers\"\n else\n @page_template = @page.template.name\n end\n \n # This isn't really necessary, but it makes the print view very clean\n @pages = [@page]\n\n if params[:popup] && params[:popup] == \"true\"\n render :action => \"show\", :layout => false\n end \n\n if params[:save] && params[:save] == \"true\"\n render_for_save\n end \n \n #Setting the body_id to caregivers to access Noah's customized css. \n #Setting the body_id to caregivers to access Noah's customized css. \n if @page.template.name == 'template_caregivers'\n @body_id = \"Caregivers\" \n @other_perspective, @other_persepective_title = 'moving_from_providers_menu' + $1, 'Health Care Provider Perspective' if @page.url =~ /moving_from_caregivers_menu(.*)/\n elsif @page.template.name == 'template_providers'\n @body_id = \"Providers\" \n @other_perspective, @other_persepective_title = 'moving_from_caregivers_menu' + $1, 'Family Caregiver Perspective' if @page.url =~ /moving_from_providers_menu(.*)/\n elsif @page.template.name == 'template_caregivers_no_menu'\n @body_id = \"Caregivers\" \n elsif @page.template.name == 'template_providers_no_menu'\n @body_id = \"Providers\" \n elsif @page.template.name == 'template_index'\n @body_id = \"Home\" \n end\n \n @left_top_menu = Page.find_by_path 'left_top_menu' \n @left_bottom_menu = Page.find_by_path 'left_bottom_menu' \n \n \n @page_template, @page_type = 'template_pdf', 1 if @page.path == 'CaregiverTool'\n @page_template, @page_type = 'template_pdf', 2 if @page.path == 'ProviderTool'\n \n end\n end","def site_populate\n # Get site\n site = Nanoc3::Site.new('.')\n data_source = site.data_sources[0]\n\n # Create home page\n data_source.create_item(\n DEFAULT_ITEM,\n { :title => \"Home\" },\n '/'\n )\n\n # Create stylesheet\n data_source.create_item(\n DEFAULT_STYLESHEET,\n {},\n '/stylesheet/'\n )\n\n # Create layout\n data_source.create_layout(\n DEFAULT_LAYOUT,\n {},\n '/default/'\n )\n\n # Create code\n FileUtils.mkdir_p('lib')\n File.open('lib/default.rb', 'w') do |io|\n io.write \"\\# All files in the 'lib' directory will be loaded\\n\"\n io.write \"\\# before nanoc starts compiling.\\n\"\n end\n end"],"string":"[\n \"def generate_project_page(p)\\n # Redirect page\\n write_file(p, '../index.html') { build_from_template('redirect.html') }\\n\\n # Summaries\\n summaries = Dir[\\\"#{p.path}/*.tsv\\\"].map do |i|\\n b = File.basename(i, '.tsv')\\n generate_summary_page(i, p)\\n \\\"
  • #{format_name(b)}
  • \\\"\\n end.join('')\\n\\n # Project index page\\n data = {\\n project_active: 'active',\\n information: format_metadata(p),\\n summaries: summaries.empty? ? 'None' : \\\"
      #{summaries}
    \\\",\\n results: format_results(p)\\n }\\n write_file(p, 'index.html') { build_from_template('index.html', data) }\\n end\",\n \"def create(p)\\n puts \\\"Creating page #{p}\\\"\\n Dir.mkdir p unless File.exists? p\\n Content.new(\\\"#{@dir}\\\", @extension).page p\\n end\",\n \"def create\\r\\n html=params[:page][:html]\\r\\n @page = Page.new(params[:page])\\r\\n respond_to do |format|\\r\\n if @page.save\\r\\n format.html { redirect_to @page, notice: 'Page was successfully created.' }\\r\\n format.json { render json: @page, status: :created, location: @page }\\r\\n target = \\\"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\\\"\\r\\n if !File.directory?(\\\"#{Rails.public_path}/#{@page.project_id}\\\")\\r\\n Dir.mkdir(\\\"#{Rails.public_path}/#{@page.project_id}\\\")\\r\\n Dir.mkdir(\\\"#{Rails.public_path}/#{@page.project_id}/images\\\")\\r\\n end\\r\\n File.open(target, \\\"w+\\\") do |f|\\r\\n f.write(html)\\r\\n end\\r\\n else\\r\\n format.html { render action: \\\"new\\\" }\\r\\n format.json { render json: @page.errors, status: :unprocessable_entity }\\r\\n end\\r\\n end\\r\\n end\",\n \"def setup\\n @page = pages(:homepage)\\n end\",\n \"def create_base_project\\n puts \\\"creating base project\\\"\\n directory \\\"templates\\\", \\\"#{app_path}\\\"\\n end\",\n \"def generate\\n # Ensure site is a directory\\n FileUtils.mkdir_p site_path\\n\\n # If there is more than one language, then we need to create\\n # multiple files, one for each language.\\n if languages.size >= 1\\n\\n # Enter the most dastardly loop. \\n # Create a View::Document with sections only containing the \\n # specified language. \\n languages.map do |language|\\n document_views = documents.map do |document|\\n document.sections = document.sections.map do |section|\\n section.examples = section.examples.select {|ex| ex.language.blank? || ex.language == language }\\n section\\n end\\n\\n Views::Document.new document\\n end\\n\\n # Use Mustache to create the file\\n page = Page.new\\n page.title = title\\n page.logo = File.basename logo if logo\\n page.documents = document_views\\n\\n File.open(\\\"#{site_path}/#{language.underscore}.html\\\", \\\"w\\\") do |file|\\n file.puts page.render\\n end\\n end\\n\\n # copy the default language to the index and were done!\\n FileUtils.cp \\\"#{site_path}/#{default.underscore}.html\\\", \\\"#{site_path}/index.html\\\"\\n\\n # There are no languages specified, so we can just create one page\\n # using a collection of Document::View.\\n else \\n document_views = documents.map do |document|\\n Views::Document.new document\\n end\\n\\n page = Page.new\\n page.title = title\\n page.logo = File.basename logo if logo\\n page.documents = document_views\\n\\n File.open(\\\"#{site_path}/index.html\\\", \\\"w\\\") do |file|\\n file.puts page.render\\n end\\n end\\n\\n # Copy the logo if specified\\n FileUtils.cp \\\"#{logo}\\\", \\\"#{site_path}/#{File.basename(logo)}\\\" if logo\\n\\n # Copy all the stylesheets into the static directory and that's it!\\n resources_path = File.expand_path \\\"../resources\\\", __FILE__\\n\\n FileUtils.cp \\\"#{resources_path}/style.css\\\", \\\"#{site_path}/style.css\\\"\\n FileUtils.cp \\\"#{resources_path}/syntax.css\\\", \\\"#{site_path}/syntax.css\\\"\\n end\",\n \"def write_page\\n contents = [people,projects,events].inject({}) { |x,y| x.merge(y) }\\n File.open('index.html','w') do |f|\\n f.write(@template.render(contents))\\n end\\n end\",\n \"def create_default_template_file\\n unless self.description.redirection_required?\\n self.localizations.each do |page_localization|\\n file_path = File.join(Rails.root, \\\"app\\\", \\\"views\\\" , \\\"pages\\\" , \\\"#{self.view}.#{page_localization.locale.slug}.html.haml\\\" )\\n unless File.exists?(file_path)\\n file = File.new(file_path, \\\"w\\\")\\n\\n page_localization.contents.each do |content|\\n file.puts(\\\"= @page.easy_contents(:#{content.section_name})\\\")\\n end\\n file.close\\n end\\n end\\n end\\n end\",\n \"def generate_page file\\n setup\\n\\n template_file = @template_dir + 'page.rhtml'\\n\\n out_file = @outputdir + file.path\\n debug_msg \\\" working on %s (%s)\\\" % [file.full_name, out_file]\\n rel_prefix = @outputdir.relative_path_from out_file.dirname\\n search_index_rel_prefix = rel_prefix\\n search_index_rel_prefix += @asset_rel_path if @file_output\\n\\n current = file\\n asset_rel_prefix = rel_prefix + @asset_rel_path\\n\\n @title = \\\"#{file.page_name} - #{@options.title}\\\"\\n\\n debug_msg \\\" rendering #{out_file}\\\"\\n render_template template_file, out_file do |io|\\n here = binding\\n # suppress 1.9.3 warning\\n here.local_variable_set(:current, current)\\n here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)\\n here\\n end\\n end\",\n \"def generate_main_page_with(specs)\\n main_page = Amy::Model::Main.new\\n specs['resources'].each_pair { |resource, options|\\n main_page.add_resource( { 'resource' => resource, 'title' => options['title'] } )\\n }\\n main_page.links = specs['links'] || []\\n main_page.version = specs['api_version']\\n main_page.base_url = specs['base_url']\\n @generator.do(\\\"#{Amy::BASE_DIR}/views/main.erb.html\\\", main_page)\\n end\",\n \"def webpage\\n render(:webpage, layout:false) and return\\n end\",\n \"def create\\n flash[:notice] = 'The page was successfully created.' if page.save\\n respond_with(page, location: project_page_path(page.project, page))\\n end\",\n \"def new\\n @project = Project.new\\n\\n render :layout => \\\"empty\\\"\\n end\",\n \"def create_test_page(options = {})\\n no_part = options.delete(:no_part)\\n page = super(options)\\n unless no_part\\n part = PagePart.new part_params(:name => 'body', :content => 'test')\\n page.parts << part\\n page.save\\n part.save\\n end\\n page\\n end\",\n \"def create_project\\n empty_directory(project)\\n end\",\n \"def new\\n @page = @site.pages.new\\n @page.parts << PagePart.new(:name => \\\"body\\\")\\n\\n respond_to do |format|\\n format.html # new.html.erb\\n format.xml { render :xml => @page }\\n end\\n end\",\n \"def first_mandate\\n # renders static page\\n end\",\n \"def testem_page\\n testem_fields(\\n \\\"#{Prawn::DATADIR}/images/reports/CEM2030-2012_Page_01.pdf\\\"\\n # \\\"#{Rails.root}/app/assets/images/reports/testem_fields.pdf\\\"\\n # \\\"#{Rails.root}/app/assets/pdfs/testem.png\\\"\\n )\\n start_new_page\\n end\",\n \"def init\\n @title_page = 'Pine app'\\n erb :welcome, layout: :template\\nend\",\n \"def default_page\\n\\t\\t\\t\\tDir.chdir File.join(self.source, @site_name)\\n\\t\\t\\t\\tFile.open Settings::PAGES_TEMPLATE + '/page.md', 'r' do |file|\\n\\n\\t\\t\\t\\t\\tfront_matter = {\\n\\t\\t\\t\\t\\t\\t'title' => 'Home Page',\\n\\t\\t\\t\\t\\t\\t'date' => Time.now.strftime(\\\"%Y-%m-%d\\\"),\\n\\t\\t\\t\\t\\t\\t'author' => 'Your Name',\\n\\t\\t\\t\\t\\t\\t'template' => 'page'\\n\\t\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t\\tcontents = Liquid::Template.parse(file.read).render front_matter \\n\\t\\t\\t\\t\\tFile.open(File.join(\\\"pages\\\", \\\"index.md\\\"), \\\"w\\\") do |f|\\n\\t\\t\\t\\t\\t\\tf.write contents\\n\\t\\t\\t\\t\\tend\\n\\t\\t\\t\\tend\\n\\t\\t\\t\\tFileUtils.mkdir_p(File.join(self.source, @site_name, \\\"media/images\\\", \\\"index\\\"))\\n\\t\\t\\tend\",\n \"def create_project(tx)\\n Installer.copy(tx, \\\"#{@service_dir}/pieces/public\\\", get_path(:web))\\n true\\n end\",\n \"def add_template_pages; end\",\n \"def build\\r\\n self.ehtml, self.ecss, self.ejs = self.theme.page_layout.build_content() \\r\\n return self.ehtml, self.ecss, self.ejs\\r\\n end\",\n \"def create\\r\\n @project = current_user.projects.new(project_params)\\r\\n new_page = @project.pages.new({ name: generate_new_page_name})\\r\\n @project.startpage = new_page\\r\\n @project.date_created = Time.now\\r\\n @project.last_modified = Time.now\\r\\n respond_to do |format|\\r\\n if @project.save\\r\\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\\r\\n format.json { render action: 'show', status: :created, location: @project }\\r\\n else\\r\\n format.html { render action: 'new' }\\r\\n format.json { render json: @project.errors, status: :unprocessable_entity }\\r\\n end\\r\\n end\\r\\n end\",\n \"def to_page\\n \\n u = User.find_by_login(authorid)\\n \\n UserActionObserver.current_user = u\\n \\n page = Page.new(\\n :title => title,\\n :created_at => lastmod,\\n :updated_at => lastmod,\\n :slug => url_title,\\n :status => Status[:published],\\n :breadcrumb => title,\\n :published_at => posted, \\n :enable_comments => annotate.to_s,\\n :keywords => keywords,\\n :created_by => u,\\n :updated_by => u\\n )\\n \\n page.parts << PagePart.new(:name => 'body', :filter_id => \\\"Textile\\\", :content => body )\\n page.parts << PagePart.new(:name => 'intro', :filter_id => \\\"Textile\\\", :content => body.split(/\\\\r\\\\n\\\\s*\\\\r\\\\n/).first)\\n \\n page\\n end\",\n \"def create_page\\n segments = self.slug.split('/').find_all { |segment| segment != '' }\\n max_segments = segments.size\\n\\n while segment = segments.pop do\\n _options = self.page_options(slug: segment, translated: false)\\n file_path = File.join(pages_path, segments, segment)\\n\\n # the content type option is never deleted for the first segment (the requested template)\\n _options.delete(:content_type) unless segments.size == (max_segments - 1)\\n\\n template 'template.liquid.tt', \\\"#{file_path}.liquid\\\", _options\\n\\n self.other_locales.each do |locale|\\n _options[:translated] = true\\n template 'template.liquid.tt', \\\"#{file_path}.#{locale}.liquid\\\", _options\\n end\\n end\\n end\",\n \"def load_index_page\\n @page ||= Language.current_root_page\\n render template: \\\"alchemy/welcome\\\", layout: false if signup_required?\\n end\",\n \"def files_to_page\\n insert_to_page('div', html)\\n insert_to_page('script', js, false)\\n insert_to_page('style', style, false)\\n end\",\n \"def create_base_project\\n raise GeneratorArgumentsError if app_path.nil?\\n puts \\\"creating base project\\\"\\n directory \\\"templates\\\", \\\"#{app_path}\\\"\\n end\",\n \"def create_page\\n @outfile.puts <<'EOF'\\n\\n\\n \\n Fun Fun Fun\\n \\nEOF\\n\\n include_stylesheets\\n include_javascript\\n add_data(@batch)\\n @outfile.puts <<'EOF'\\n \\n \\n \\n \\n \\n\\nEOF\\n end\",\n \"def index\\n @page = Page.new\\n end\",\n \"def new\\n @brigade_project = BrigadeProject.new\\n general_static_response(@brigade_project)\\n end\",\n \"def create_page(site, source_file, relative_dir, file_name, langcode, includelang = false, process = true)\\n # Don't process underscore files.\\n return if relative_dir =~ /^_/\\n\\n case source_file\\n when /\\\\.(markdown|html)|sitemap\\\\.xml|feed\\\\.xml/\\n # Markdown is our main content language, create a page.\\n page = LanguagePage.new(site, site.source, relative_dir, file_name, langcode, includelang)\\n site.pages << page if process\\n page\\n when /\\\\.(png|jpg|gif|css|mp4|webm|vtt|svg|mp3)/\\n # Copy across other assets.\\n asset = LanguageAsset.new(site, site.source, relative_dir, file_name, langcode, includelang)\\n site.static_files << asset if process\\n nil\\n end\\n end\",\n \"def create_theme\\n empty_directory(VIEW_PATH)\\n\\n if partial\\n if partial.index('/')\\n (extra_dirs, partial_name) = partial.match(/^(.*)\\\\/(.*)$/).captures\\n\\n empty_directory(\\\"#{VIEW_PATH}/#{file_name}/#{extra_dirs}\\\")\\n\\n copy_file(\\n \\\"#{extra_dirs}/_#{partial_name.match(/^text_as_/) ? 'text' : partial_name}.html.erb\\\",\\n \\\"#{VIEW_PATH}/#{file_name}/#{extra_dirs}/_#{partial_name}.html.erb\\\"\\n )\\n else\\n copy_file(\\\"_#{partial}.html.erb\\\", \\\"#{VIEW_PATH}/#{file_name}/_#{partial}.html.erb\\\")\\n end\\n else\\n directory('', \\\"#{VIEW_PATH}/#{file_name}\\\")\\n end\\n end\",\n \"def generate_project_file\\n template_file = @template_dir + 'hhp_file.hhp.rhtml'\\n\\n @values = { :title => @options.title, :opname => @outputdir.basename }\\n \\n static_files = ['index.html', 'classindex.html', 'fileindex.html']\\n @values[:html_files] = static_files + (@generated_files+@classes).map{|f| f.path}.uniq\\n \\n out_file = @outputdir + @project_name\\n debug_msg \\\" rendering #{out_file}\\\"\\n render_template template_file, out_file do |io| binding end\\n end\",\n \"def create_default_page_template\\n PageTemplate.create(:name => 'default')\\n end\",\n \"def index_prebuilt!\\n Dir.glob(\\\"#{PREBUILT_DIR}/**/[^_]*.*\\\") do |filename|\\n config.add_page(filename.sub(\\\"#{PREBUILT_DIR}/\\\", ''), file: filename, digest: true)\\n end\\n end\",\n \"def new\\n \\t@pagenav = Page.find_all_by_published('true')\\n @project = Project.new\\n\\n respond_to do |format|\\n format.html # new.html.erb\\n format.json { render json: @project }\\n end\\n end\",\n \"def write_pages\\n pages = Dir[\\\"#{source_path}/*.html\\\"].each do |p_name|\\n page = Page.new(source_path, File.basename(p_name))\\n # TODO allow user to specify which layouts a page should use \\n page.render(site_payload, layouts.select{|x| x.name == \\\"application.html\\\"})\\n page.write(destination_path)\\n end\\n end\",\n \"def html_page\\n <<-END.gsub(/^\\\\s+/, '')\\n \\n Why Fixturing Is Annoying\\n \\n \\n \\n
    \\n \\n END\\n end\",\n \"def prepare_project_header_and_footer\\n @header_text = @project.templets.find_by_name('PAGE_HEADER').render( @project )\\n @footer_text = @project.templets.find_by_name('PAGE_FOOTER').render( @project )\\n end\",\n \"def new\\n @pages = Page.new\\n #renders new.html.erb\\n end\",\n \"def new\\n @page = Page.new\\n @pagelist = @club.all_pages\\n \\n @page_title = \\\"New Page\\\"\\n @site_section = \\\"admin\\\"\\n respond_to do |format|\\n format.html # new.html.erb\\n format.xml { render :xml => @page }\\n end\\n end\",\n \"def build( special_contexts=[] )\\r\\n\\r\\n self.ehtmls, self.ecss, self.ejs = self.theme.original_page_layout_root.build_content(special_contexts)\\r\\n self.ehtml = self.ehtmls.first\\r\\n\\r\\n end\",\n \"def new\\n @project = Project.new\\n @title = \\\"New Project\\\"\\n end\",\n \"def new\\r\\n @event = Event.new\\r\\n #@pages = Page.all\\r\\n @projects_pages = []\\r\\n projects = Project.all.sort{|a,b| a.name <=> b.name}\\r\\n projects.each do |project|\\r\\n @projects_pages << [\\\"#{project.name}\\\", project.pages.exclude_placeholder] unless project.pages.blank?\\r\\n end\\r\\n respond_to do |format|\\r\\n format.html # new.html.erb\\r\\n format.xml { render :xml => @event }\\r\\n end\\r\\n end\",\n \"def build_page(path, silent: false)\\n page = sitemap[path]\\n out_fname = File.join(BUILD_DIR, path)\\n puts \\\"Rendering #{out_fname}...\\\" unless silent\\n\\n # Check page data for info on how to build this path\\n if page['template'].present?\\n ctx = TemplateContext.new(@config)\\n ctx.page = page\\n # Check if we have a layout defined, use it\\n layout = ctx.page.key?('layout') ? ctx.page['layout'] : config['layout']\\n\\n # Make sure to render the template inside the layout render so code in the\\n # erb layout and template are executed in a sensible order.\\n content =\\n if layout.present?\\n ctx.render(layout) { ctx.render(ctx.page['template']) }\\n else\\n ctx.render(ctx.page['template'])\\n end\\n elsif page['json'].present?\\n content = page['json'].to_json\\n elsif page['file'].present?\\n content = File.read(page['file'])\\n else\\n raise(\\n ArgumentError,\\n \\\"Page '#{path}' missing one of required attributes: 'template', 'json', 'file'.\\\"\\n )\\n end\\n\\n # If page data includes a digest flag, add sha1 digest to output filename\\n if page['digest'] == true\\n ext = VizBuilder.fullextname(path)\\n fname = File.basename(path, ext)\\n dir = File.dirname(path)\\n digest = Digest::SHA1.hexdigest(content)\\n digest_fname = \\\"#{fname}-#{digest}#{ext}\\\"\\n page['digest_path'] = \\\"#{dir}/#{digest_fname}\\\"\\n out_fname = File.join(BUILD_DIR, dir, digest_fname)\\n end\\n\\n FileUtils.mkdir_p(File.dirname(out_fname))\\n File.write(out_fname, content)\\n content\\n end\",\n \"def new\\n #creates a new page only in memory\\n @page = Page.new\\n end\",\n \"def generate\\n verify_path\\n \\n self.layouts.each {|layout| layout.write_file}\\n self.pages.each {|page| page.write_file}\\n \\n Webby.site.content_dir = self.content_dir\\n Webby.site.layout_dir = self.layout_dir\\n Webby.site.template_dir = self.template_dir\\n Webby.site.output_dir = self.output_dir\\n \\n Merb.logger.debug \\\"content_dir: #{Webby.site.content_dir}\\\"\\n Merb.logger.debug \\\"layout_dir: #{Webby.site.layout_dir}\\\"\\n Merb.logger.debug \\\"template_dir: #{Webby.site.template_dir}\\\"\\n Merb.logger.debug \\\"output_dir: #{Webby.site.output_dir}\\\"\\n \\n # Use directory => '.' option to generate the site in output_dir\\n Webby.site.page_defaults = {'layout' => self.default_layout.relative_path,\\n 'directory' => '.',\\n 'collision' => :force}\\n \\n Merb.logger.debug \\\"page_defaults: #{Webby.site.page_defaults}\\\" \\n # returns nil if success \\n # Webby::Builder.run\\n Webby::Builder.run :rebuild => true\\n end\",\n \"def template_page(site); end\",\n \"def about\\n # Static Page\\n end\",\n \"def index\\n @pages = Page.all\\n render layout: 'application'\\n end\",\n \"def generate_Song_Pages\\n template_doc = File.open(\\\"lib/templates/song.html.erb\\\")\\n template = ERB.new(template_doc.read)\\n Song.all.each do |song|\\n File.write(\\\"_site/song/#{song.url}\\\", template.result(binding))\\n end\\n end\",\n \"def new\\n @page = Page.new\\n end\",\n \"def new\\n @page = Page.new\\n end\",\n \"def new\\n @page = Page.new\\n end\",\n \"def new\\n @page = Page.new\\n end\",\n \"def index\\n @dynamic_project_pages = DynamicProjectPage.all\\n end\",\n \"def generate_content\\n @pdf = Prawn::Document.new(\\n info: self.metadata,\\n top_margin: @format[:header_size] + @format[:top_margin],\\n bottom_margin: @format[:footer_size] + @format[:bottom_margin]\\n )\\n add_page_body\\n add_page_header\\n add_page_footer\\n add_page_numbering\\n end\",\n \"def create_blank_post(path, title)\\n # Create the directories to this path if needed\\n FileUtils.mkpath(File.dirname(path))\\n\\n # Write the template to the file\\n File.open(path, \\\"w\\\") do |f|\\n f << <<-EOS.gsub(/^ /, '')\\n ---\\n layout: post\\n title: #{title}\\n published: false\\n ---\\n\\n EOS\\n end\\nend\",\n \"def new\\n add_breadcrumb \\\"Nouveau\\\"\\n @project = Project.new\\n end\",\n \"def generate\\n add_intro\\n add_blood_pressure_intro\\n add_blood_pressure_list\\n add_blood_pressure_outro\\n add_medications_intro\\n add_medications_list\\n add_about\\n\\n @pdf\\n end\",\n \"def initialize(options) #:not-new:\\n @options = options\\n load_html_template\\n @main_page_path = nil\\n end\",\n \"def new\\r\\n session[:from_page] = params[:from_page]\\r\\n session[:from_event] = params[:from_event]\\r\\n\\r\\n @project = Project.new\\r\\n @project.build_project_image\\r\\n @project.project_web_links.build\\r\\n @funders = Funder.all\\r\\n\\r\\n respond_to do |format|\\r\\n format.html {render :layout => 'backend'} # new.html.erb\\r\\n format.xml { render :xml => @project }\\r\\n end\\r\\n end\",\n \"def new_page\\n @vendor = Vendor.find(current_user)\\n @page = Page.new\\n @page.site_id = params[:site_id]\\n @page.template_id = 1\\n @page.page_name = \\\"PAGE\\\"\\n @page.language = \\\"en\\\"\\n @page.theme_id = 1 \\n respond_to do |format|\\n if @page.save\\n #Construct the path for the destination page file\\n @page_path = 'public/sites/' + @vendor.id.to_s + \\\"/\\\" + @page.site_id.to_s + \\\"/\\\" + @page.id.to_s + '.html' \\n File.open(@page_path, \\\"w+\\\") do |f|\\n f.write(\\\"Page \\\" + @page.id.to_s + \\\"\\\") \\n end\\n #redirect to the view and render the partial\\n format.html { redirect_to page_manage_path}\\n format.js\\n format.json { render json: @page, \\n status: :created, location: @page }\\n else \\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @page.errors,\\n status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def pages\\n plantuml_files.map { |static_file| page_from_static_file(static_file) }\\n end\",\n \"def create\\n #Each Page could be tied to an ApiKey or set of ApiKeys for security\\n @page = Page.new(page_params)\\n #Render the object created or errors\\n respond_to do |format|\\n if @page.save\\n #Cache bust pages\\n Rails.cache.delete(\\\"pages\\\")\\n format.json { render action: 'show', status: :created, location: api_page_url(@page) }\\n else\\n format.json { render json: @page.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def create_all!\\n if title_card_path.exist?\\n Dir\\n .glob(story.screenshots.join(\\\"*page*.png\\\"))\\n .sort_by { |path| path.scan(/\\\\d+/).first.to_i }\\n .each do |path|\\n\\n path.slice! File.extname(path) # drop the extension\\n @paths[:pages] << absolute(path) # store the result in the index\\n end\\n return\\n end\\n\\n FileUtils.mkdir_p story.screenshots\\n browser.add_script_tag content: <<~JS\\n pageflow.ready.then(function() {\\n $('.multimedia_alert').remove()\\n })\\n JS\\n\\n # Grab all navigable pages.\\n browser.goto story.url\\n sleep 10\\n pages = browser.css('#scrollytelling-navigation a')\\n puts \\\"#{pages.length} screenshots in #{story.screenshots}\\\"\\n\\n pages.each_with_index do |link, index|\\n perma_id = link.attribute('href')[/#(\\\\d*)\\\\z/, 1]\\n url = [story.url, link.attribute('href')].join\\n filename = [story.slug, 'page', index + 1, \\\"#{perma_id}.png\\\"].join('-')\\n next if File.exist?(story.screenshots.join(filename))\\n\\n print \\\"#{url} \\\"\\n browser.goto url\\n sleep 3\\n\\n until browser.at_css('body').attribute('class').include? 'finished-loading'\\n sleep 1\\n end\\n\\n browser.screenshot(path: story.screenshots.join(filename))\\n @paths[:pages] << absolute(story.screenshots.join(filename))\\n puts \\\"✅ #{filename}\\\"\\n end\\n\\n # Grab the opening page; when this exists, all screens are complete.\\n browser.goto story.url\\n sleep 10\\n\\n browser.screenshot(full: true, path: title_card_path)\\n @paths[:title] = absolute(title_card_path)\\n\\n browser.quit\\n end\",\n \"def generate_index\\n setup\\n\\n template_file = @template_dir + 'index.rhtml'\\n return unless template_file.exist?\\n\\n debug_msg \\\"Rendering the index page...\\\"\\n\\n out_file = @base_dir + @options.op_dir + 'index.html'\\n rel_prefix = @outputdir.relative_path_from out_file.dirname\\n search_index_rel_prefix = rel_prefix\\n search_index_rel_prefix += @asset_rel_path if @file_output\\n\\n asset_rel_prefix = rel_prefix + @asset_rel_path\\n\\n @title = @options.title\\n\\n render_template template_file, out_file do |io|\\n here = binding\\n # suppress 1.9.3 warning\\n here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)\\n here\\n end\\n rescue => e\\n error = RDoc::Error.new \\\\\\n \\\"error generating index.html: #{e.message} (#{e.class})\\\"\\n error.set_backtrace e.backtrace\\n\\n raise error\\n end\",\n \"def render_pages(static_path)\\n puts \\\" Rendering pages\\\"\\n Page.all.each do |p|\\n if p.published? && (body = p.render)\\n dir, filename = p.url, \\\"index.html\\\"\\n dir, filename = p.parent.url, p.slug if p.slug =~ /\\\\.[^.]+$/i # File with extension (e.g. styles.css)\\n FileUtils.mkdir_p(File.join(static_path, dir))\\n File.open(File.join(static_path, dir, filename), 'w') { |io| io.print(body) }\\n else\\n puts \\\" ! Not rendering #{p.id} - #{p.status.name} - #{p.url}\\\"\\n end\\n end\\nend\",\n \"def index\\n @main_page = \\\"Pessoal\\\"\\n @page_title = \\\"Projetos\\\"\\n @projects = Project.all\\n @current_projects = Project.current_projects\\n end\",\n \"def generate_all\\n copy_template_dir('layouts', 'layouts')\\n copy_template_dir('content/bootstrap', 'content/bootstrap')\\n copy_template_dir('content/content', 'content/content')\\n delete_target_file('lib/default.rb')\\n copy_template_dir('lib', 'lib')\\n delete_target_file('Rules')\\n copy_template_file('Rules', 'Rules')\\n copy_template_file('.gitignore', '.gitignore')\\n copy_template_file('cg_config.rb', 'cg_config.rb')\\n copy_template_file('cg_config.rb_sample', 'cg_config.rb_sample')\\n delete_target_file('content/stylesheet.css')\\n delete_target_file('content/index.html')\\n delete_target_file('layouts/default.html')\\n create_empty_dir('content/images')\\n end\",\n \"def new\\n\\t\\t\\tlogger.debug \\\"******* paths loaded are #{Rails.application.config.assets.paths}\\\"\\n\\t\\t\\t@landing_page = LandingPage.new\\n\\n\\t\\t\\trespond_to do |format|\\n\\t\\t\\t\\tformat.html # new.html.erb\\n\\t\\t\\t\\tformat.json { render json: @landing_page }\\n\\t\\t\\tend\\n\\t\\tend\",\n \"def execute!\\n make_web_directory\\n generate_universe\\n generate_html\\n print_success_message\\n end\",\n \"def create\\n redirect_to pages_path\\n end\",\n \"def create_blank_post(path, title)\\n # Create the directories to this path if needed\\n FileUtils.mkpath(File.dirname(path))\\n\\n # Write the template to the file\\n File.open(path, \\\"w\\\") do |f|\\n f << <<-EOS.gsub(/^ /, '')\\n ---\\n layout: post\\n title: #{title}\\n published: false\\n categories:\\n ---\\n\\n EOS\\n end\\nend\",\n \"def create_blank_post(path, title, date)\\n # Create the directories to this path if needed\\n FileUtils.mkpath(File.dirname(path))\\n\\n # Write the template to the file\\n File.open(path, \\\"w\\\") do |f|\\n f << <<-EOS.gsub(/^ /, '')\\n ---\\n title: #{title}\\n category: Code\\n layout: post\\n date: #{date}\\n ---\\n\\n EOS\\n end\\nend\",\n \"def generate()\\n prepare\\n ::Dir.mkdir(@output_path) unless ::File.exists? @output_path\\n\\n @pages.each do |name, page|\\n SiteLog.debug(\\\"Starting page generation - #{name}\\\")\\n page.generate(@output_path, @version, @preserve_tree)\\n SiteLog.debug(\\\"Finished page generation - #{name}\\\")\\n end\\n\\n @files.each do |path, data|\\n path = ::File.join(@output_path, path)\\n ::FileUtils.mkdir_p(::File.dirname(path))\\n ::File.open(path, \\\"w\\\") do |f|\\n f.write(data)\\n end\\n end\\n end\",\n \"def add_blank_page_if_needed\\n pdf_generator.generate(\\n Summary::BlankPage.new(c100_application), copies: 1\\n ) if has_forms_data?\\n end\",\n \"def new\\n @page = Page.new\\n #render :new - app/views/pages/new.html.erb\\n end\",\n \"def designer\\r\\n @page = Page.find(params[:id])\\r\\n data = File.read(\\\"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\\\")\\r\\n @page.update_attribute(:html , data)\\r\\n render 'designer'\\r\\n end\",\n \"def new\\n @page = Page.new\\n # render new.html.erb\\n end\",\n \"def new\\n @page = Page.new\\n # render new.html.erb\\n end\",\n \"def new\\n @isgrey = true;\\n @current_page = \\\"ADD PROJECT\\\"\\n @project = Project.new\\n @project_attachment = @project.project_attachments.build\\n @slider_object = @project.slider_objects.build\\n @project_field = @project.project_fields.build\\n @project_other_field = @project.project_other_fields.build\\n\\n @types = Type.all\\n @new_nav = true;\\n\\n respond_to do |format|\\n format.html # new.html.erb\\n format.json { render json: @project }\\n end\\n end\",\n \"def generate!\\n controllers = (Rails.application.routes.routes.map do |route|\\n controller_name = \\\"#{route.requirements[:controller].camelize}Controller\\\"\\n ActiveSupport::Dependencies.ref(controller_name).get\\n end).insert(0, ApplicationController).uniq\\n\\n valid_controllers = valid_controllers()\\n valid_locales = valid_locales()\\n\\n controllers.each do |controller|\\n controller_path = controller.controller_path\\n if controller.respond_to?(:managable_content_for) && valid_controllers.include?(controller_path)\\n Page.transaction do\\n valid_locales.each do |locale|\\n # Create Page if it does not exist yet\\n page = Page.where(:controller_path => controller_path, :locale => locale).first || Page.new()\\n if page.new_record?\\n page.controller_path = controller_path\\n page.locale = locale\\n page.save!\\n end\\n\\n # Create PageContent if it does not exist yet\\n contents = (controller == ApplicationController) ? controller.managable_layout_content_for : controller.managable_content_for\\n contents.each do |key|\\n if page.page_contents.where(:key => key).first.nil?\\n page_content = page.page_contents.build\\n page_content.key = key\\n page_content.save!\\n end\\n end\\n end\\n end\\n end\\n end\\n end\",\n \"def new\\n\\t\\t@project = Project.new({:project_state_type_id => ProjectStateType.find_by_code('preparation').id})\\n\\t\\tputs @project.inspect\\n\\t\\tmake_breadcrumbs\\n\\t\\t\\n\\t\\trespond_to do |format|\\n\\t\\t\\tformat.html # new.html.erb\\n\\t\\t\\tformat.json { render json: @project }\\n\\t\\tend\\n\\tend\",\n \"def write\\n if root?\\n index_file = File.join(page_dir, 'index.html')\\n notice \\\"Writing top level index file at #{index_file}\\\"\\n File.open(index_file, 'w') {|f| f.puts content}\\n else\\n # First create the index page\\n index_file = File.join(page_dir, name + '.html')\\n notice \\\"Writing index file for directory #{path} at #{index_file}\\\"\\n File.open(index_file, 'w') {|f| f.puts content}\\n\\n # Create a directory to contain index pages for any child directories\\n Dir.mkdir(File.join(page_dir, name))\\n end\\n dirs.sort.each{|dir| dir.write}\\n\\n # Determine if the page assets directory is necessary, to avoid clutter\\n writing_page_assets = true\\n begin\\n # Detect whether the write_page_assets method is overridden\\n # In case this explodes in 1.8.6 we'll always create the directory\\n writing_page_assets = renderer.class.instance_method(:write_page_assets).owner != DirRenderer\\n rescue\\n end\\n\\n # The renderer knows what assets are linked to and what needs to be available\\n # to display the page properly\\n if writing_page_assets\\n Dir.mkdir(page_assets_dir)\\n renderer.write_page_assets(self)\\n end\\n end\",\n \"def copy_page\\n File.open(Rails.root.join('public', 'testing.html'), 'wb') { |f| f << page.body }\\n end\",\n \"def new\\n @page = Page.new\\n # render :new app/views/pages/new.html.erb\\n end\",\n \"def test_create_page\\n file = Configuration.TEST_PAGE\\n \\n # This test depends on a succesfull login\\n if test_correct_login\\n token = make_login Configuration.USER, Configuration.PASSWORD\\n else\\n return false\\n end\\n \\n page_key = 'page-test-' + random_string(Configuration.PAGE_KEY_RS_SIZE)\\n res = post_page file, token, page_key, 'test-tag', 'This is a Test Page'\\n \\n # Remove the just created page\\n remove_page page_key, token\\n \\n puts \\\"\\\\nTester#test_create_page:\\\\n#{res}\\\" if Configuration.VERBOSE\\n res == Constants.SUCCESS_MESSAGE\\n end\",\n \"def create\\n url = params['url']\\n doc = Crawl::PageHandler.fetch_page(url)\\n page_data = Crawl::PageHandler.parse_page(url, doc)\\n page = Page.create(url: url,\\n chksum: Zlib.crc32(url),\\n parsed: page_data.to_json)\\n render json: { url: page[:url],\\n chksum: page[:chksum],\\n parsed: page[:parsed] }\\n end\",\n \"def isite\\n render layout: 'parallax'\\n end\",\n \"def init\\t\\n\\tenable :static\\n\\tset :statics_folder, 'statics'\\n\\tset :deep_or_flat_structure, 'flat'\\n\\n\\tset :public_folder, settings.statics_folder\\n\\n\\tset :page_pool, page_pool()\\nend\",\n \"def generate_html\\n # the individual descriptions for files and classes\\n gen_into(@files)\\n gen_into(@classes)\\n # and the index files\\n gen_file_index\\n gen_class_index\\n gen_method_index\\n gen_main_index\\n\\n # this method is defined in the template file\\n write_extra_pages if defined? write_extra_pages\\n end\",\n \"def new\\n @content_page = ContentPage.new :page_layout => \\\"default\\\"\\n\\n respond_to do |format|\\n format.html # new.html.erb\\n format.xml { render :xml => @content_page }\\n end\\n end\",\n \"def splash_page\\n end\",\n \"def index\\n\\t @title = \\\"Miradi Data Server\\\"\\n\\t \\\"Welcome to the Miradi Data Server!
    \\\" +\\n\\t\\t\\\"
    \\\" + \\n\\t\\t\\\"Project Name: \\\" +\\n\\t\\t\\\"\\\" + \\n\\t\\t\\\"
    \\\"\\n\\tend\",\n \"def preview\\n \\n # @lg = PageTag::PageGenerator.previewer( @menu, @theme, {:resource=>(@resource.nil? ? nil:@resource),:controller=>self})\\n # html = @lg.generate\\n # css,js = @lg.generate_assets \\n #insert css to html\\n # style = %Q!!\\n #editor_panel require @theme, @editors, @editor ...\\n # html.insert(html.index(\\\"\\\"),style)\\n # html.insert(html.index(\\\"\\\"),@editor_panel)\\n # respond_to do |format|\\n # format.html {render :text => html}\\n # end\\n \\n end\",\n \"def show\\n \\n if Page.count==0\\n ensure_homepage\\n else\\n @page = @page || Page.find_by_alias(app_path)\\n # TODO: add the ability for the user to choose whether to render the page or use it as a redirect\\n #path = @page.path == '/' ? 'index' : @page.path\\n #redirect_to @page.url unless path==app_path\\n end\\n\\n if @page.nil?\\n if admin?\\n flash[:notice]=\\\"The page you requested does not exist. Would you like to create it?\\\"\\n @page = Page.new(:path=>app_path)\\n @page_template = \\\"admin\\\"\\n render :action=>'new'\\n else\\n render :file => \\\"#{RAILS_ROOT}/public/404.html\\\", :layout => false, :status => 404\\n end\\n else\\n @app_path=@page.path\\n @title = @page.title\\n @page_description = @page.description\\n\\n # Even though the printable pages are rendered in a different layout\\n # they also need a different template, since this template should only\\n # have a single column\\n \\n if params[:print] && params[:print] == \\\"true\\\"\\n @page_template = \\\"print\\\"\\n elsif @page.url =~ /moving_from_caregivers_menu/\\n @page_template = \\\"template_caregivers\\\"\\n elsif @page.url =~ /moving_from_providers_menu/\\n @page_template = \\\"template_providers\\\"\\n else\\n @page_template = @page.template.name\\n end\\n \\n # This isn't really necessary, but it makes the print view very clean\\n @pages = [@page]\\n\\n if params[:popup] && params[:popup] == \\\"true\\\"\\n render :action => \\\"show\\\", :layout => false\\n end \\n\\n if params[:save] && params[:save] == \\\"true\\\"\\n render_for_save\\n end \\n \\n #Setting the body_id to caregivers to access Noah's customized css. \\n #Setting the body_id to caregivers to access Noah's customized css. \\n if @page.template.name == 'template_caregivers'\\n @body_id = \\\"Caregivers\\\" \\n @other_perspective, @other_persepective_title = 'moving_from_providers_menu' + $1, 'Health Care Provider Perspective' if @page.url =~ /moving_from_caregivers_menu(.*)/\\n elsif @page.template.name == 'template_providers'\\n @body_id = \\\"Providers\\\" \\n @other_perspective, @other_persepective_title = 'moving_from_caregivers_menu' + $1, 'Family Caregiver Perspective' if @page.url =~ /moving_from_providers_menu(.*)/\\n elsif @page.template.name == 'template_caregivers_no_menu'\\n @body_id = \\\"Caregivers\\\" \\n elsif @page.template.name == 'template_providers_no_menu'\\n @body_id = \\\"Providers\\\" \\n elsif @page.template.name == 'template_index'\\n @body_id = \\\"Home\\\" \\n end\\n \\n @left_top_menu = Page.find_by_path 'left_top_menu' \\n @left_bottom_menu = Page.find_by_path 'left_bottom_menu' \\n \\n \\n @page_template, @page_type = 'template_pdf', 1 if @page.path == 'CaregiverTool'\\n @page_template, @page_type = 'template_pdf', 2 if @page.path == 'ProviderTool'\\n \\n end\\n end\",\n \"def site_populate\\n # Get site\\n site = Nanoc3::Site.new('.')\\n data_source = site.data_sources[0]\\n\\n # Create home page\\n data_source.create_item(\\n DEFAULT_ITEM,\\n { :title => \\\"Home\\\" },\\n '/'\\n )\\n\\n # Create stylesheet\\n data_source.create_item(\\n DEFAULT_STYLESHEET,\\n {},\\n '/stylesheet/'\\n )\\n\\n # Create layout\\n data_source.create_layout(\\n DEFAULT_LAYOUT,\\n {},\\n '/default/'\\n )\\n\\n # Create code\\n FileUtils.mkdir_p('lib')\\n File.open('lib/default.rb', 'w') do |io|\\n io.write \\\"\\\\# All files in the 'lib' directory will be loaded\\\\n\\\"\\n io.write \\\"\\\\# before nanoc starts compiling.\\\\n\\\"\\n end\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.702871","0.67735654","0.6353886","0.6273523","0.6258971","0.6180119","0.613617","0.6118454","0.6103431","0.6102516","0.6098231","0.6093809","0.6092664","0.60811114","0.60627323","0.6057448","0.6052244","0.60504496","0.6045839","0.6034876","0.59940636","0.5942914","0.5938164","0.59338003","0.59038603","0.5897831","0.5892447","0.58901954","0.58868366","0.58585703","0.5826539","0.58194464","0.58079356","0.5800072","0.57899106","0.5776027","0.5769312","0.5765812","0.57622904","0.5758534","0.5736312","0.57325524","0.57225657","0.5722343","0.57071507","0.5704333","0.57034934","0.56958616","0.5694009","0.56926864","0.56921774","0.5686585","0.5685797","0.5685793","0.5685177","0.5685177","0.5685177","0.56786954","0.5675779","0.5674549","0.56664574","0.56644464","0.5660984","0.56603485","0.5659347","0.5658833","0.5658208","0.5648638","0.5646214","0.5637822","0.56377953","0.5633723","0.560851","0.5605414","0.56053","0.56047946","0.56026894","0.5599755","0.55987203","0.5595127","0.5586591","0.557781","0.557781","0.5575103","0.5569682","0.55688536","0.55662364","0.5560026","0.55579937","0.55486023","0.5548475","0.55475676","0.55461776","0.5524698","0.55234593","0.5522188","0.5516674","0.5515853","0.551407","0.5513456"],"string":"[\n \"0.702871\",\n \"0.67735654\",\n \"0.6353886\",\n \"0.6273523\",\n \"0.6258971\",\n \"0.6180119\",\n \"0.613617\",\n \"0.6118454\",\n \"0.6103431\",\n \"0.6102516\",\n \"0.6098231\",\n \"0.6093809\",\n \"0.6092664\",\n \"0.60811114\",\n \"0.60627323\",\n \"0.6057448\",\n \"0.6052244\",\n \"0.60504496\",\n \"0.6045839\",\n \"0.6034876\",\n \"0.59940636\",\n \"0.5942914\",\n \"0.5938164\",\n \"0.59338003\",\n \"0.59038603\",\n \"0.5897831\",\n \"0.5892447\",\n \"0.58901954\",\n \"0.58868366\",\n \"0.58585703\",\n \"0.5826539\",\n \"0.58194464\",\n \"0.58079356\",\n \"0.5800072\",\n \"0.57899106\",\n \"0.5776027\",\n \"0.5769312\",\n \"0.5765812\",\n \"0.57622904\",\n \"0.5758534\",\n \"0.5736312\",\n \"0.57325524\",\n \"0.57225657\",\n \"0.5722343\",\n \"0.57071507\",\n \"0.5704333\",\n \"0.57034934\",\n \"0.56958616\",\n \"0.5694009\",\n \"0.56926864\",\n \"0.56921774\",\n \"0.5686585\",\n \"0.5685797\",\n \"0.5685793\",\n \"0.5685177\",\n \"0.5685177\",\n \"0.5685177\",\n \"0.56786954\",\n \"0.5675779\",\n \"0.5674549\",\n \"0.56664574\",\n \"0.56644464\",\n \"0.5660984\",\n \"0.56603485\",\n \"0.5659347\",\n \"0.5658833\",\n \"0.5658208\",\n \"0.5648638\",\n \"0.5646214\",\n \"0.5637822\",\n \"0.56377953\",\n \"0.5633723\",\n \"0.560851\",\n \"0.5605414\",\n \"0.56053\",\n \"0.56047946\",\n \"0.56026894\",\n \"0.5599755\",\n \"0.55987203\",\n \"0.5595127\",\n \"0.5586591\",\n \"0.557781\",\n \"0.557781\",\n \"0.5575103\",\n \"0.5569682\",\n \"0.55688536\",\n \"0.55662364\",\n \"0.5560026\",\n \"0.55579937\",\n \"0.55486023\",\n \"0.5548475\",\n \"0.55475676\",\n \"0.55461776\",\n \"0.5524698\",\n \"0.55234593\",\n \"0.5522188\",\n \"0.5516674\",\n \"0.5515853\",\n \"0.551407\",\n \"0.5513456\"\n]"},"document_score":{"kind":"string","value":"0.8454481"},"document_rank":{"kind":"string","value":"0"}}},{"rowIdx":1887,"cells":{"query":{"kind":"string","value":"Create landing page for project +p+"},"document":{"kind":"string","value":"def generate_project_page(p)\n # Redirect page\n write_file(p, '../index.html') { build_from_template('redirect.html') }\n\n # Summaries\n summaries = Dir[\"#{p.path}/*.tsv\"].map do |i|\n b = File.basename(i, '.tsv')\n generate_summary_page(i, p)\n \"
  • #{format_name(b)}
  • \"\n end.join('')\n\n # Project index page\n data = {\n project_active: 'active',\n information: format_metadata(p),\n summaries: summaries.empty? ? 'None' : \"
      #{summaries}
    \",\n results: format_results(p)\n }\n write_file(p, 'index.html') { build_from_template('index.html', data) }\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def create_empty_page(p)\n cli.say 'Creating project page'\n FileUtils.mkdir_p(browse_file(p, '.'))\n %w[favicon-32.png style.css].each do |i|\n FileUtils.cp(template_file(i), browse_file(p, i))\n end\n write_file(p, 'about.html') do\n build_from_template('about.html', citation: MiGA::MiGA.CITATION)\n end\n end","def index\n @main_page = \"Pessoal\"\n @page_title = \"Projetos\"\n @projects = Project.all\n @current_projects = Project.current_projects\n end","def index\n\t @title = \"Miradi Data Server\"\n\t \"Welcome to the Miradi Data Server!
    \" +\n\t\t\"
    \" + \n\t\t\"Project Name: \" +\n\t\t\"\" + \n\t\t\"
    \"\n\tend","def create\r\n @project = current_user.projects.new(project_params)\r\n new_page = @project.pages.new({ name: generate_new_page_name})\r\n @project.startpage = new_page\r\n @project.date_created = Time.now\r\n @project.last_modified = Time.now\r\n respond_to do |format|\r\n if @project.save\r\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\r\n format.json { render action: 'show', status: :created, location: @project }\r\n else\r\n format.html { render action: 'new' }\r\n format.json { render json: @project.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end","def home\n error_404 unless (@page = Page.where(:link_url => '/').first).present?\n \n call_back\n \n @test = @profile\n @test2 = @current_patner.nil?\n \n # Member.project; Project.hoster\n \n if !Project.all.empty?\n @projects = Project.all\n end\n end","def create_landing\r\n\r\n end","def new\n @brigade_project = BrigadeProject.new\n general_static_response(@brigade_project)\n end","def index\n #respond(\"
    \" + request.env.inspect + \"
    \")\n @title = \"Welcome to Pastr!\"\n end","def new\r\n session[:from_page] = params[:from_page]\r\n session[:from_event] = params[:from_event]\r\n\r\n @project = Project.new\r\n @project.build_project_image\r\n @project.project_web_links.build\r\n @funders = Funder.all\r\n\r\n respond_to do |format|\r\n format.html {render :layout => 'backend'} # new.html.erb\r\n format.xml { render :xml => @project }\r\n end\r\n end","def new\n @project = Project.new\n @title = \"New Project\"\n end","def new\n @project = Project.new\n\n render :layout => \"empty\"\n end","def create\n @project = Project.new(project_params)\n if @project.save\n redirect_to \"/charity_lp/landingpage\", notice: 'Research Form was successfully created.'\n # format.json { render :show, status: :created, location: @project }\n else\n render 'new'\n\n # format.html {redirect_to \"/projects/new\", notice: 'Errors in submition, please ensure all fields are filled in correctly' }\n # format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end","def new\n\t\t@project = Project.new({:project_state_type_id => ProjectStateType.find_by_code('preparation').id})\n\t\tputs @project.inspect\n\t\tmake_breadcrumbs\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.json { render json: @project }\n\t\tend\n\tend","def first_mandate\n # renders static page\n end","def new_project\n @request = Request.new(data_type: :project)\n @request.build_contact\n @request.build_project\n @request.build_general_information\n\n render 'new'\n end","def home\n @projects = Project.all.where('published = true')\n @header = \"Published Projects\"\n end","def load_index_page\n @page ||= Language.current_root_page\n render template: \"alchemy/welcome\", layout: false if signup_required?\n end","def show\n @page_title = \"Voluntips | Projekt: \" + @project.title\n set_show_keywords\n end","def show\n @project = Project.find params[:id]\n @page_title = \"Project #{@project.name}\"\n end","def home\n\t\t# Home Page\n\tend","def new\n \t@pagenav = Page.find_all_by_published('true')\n @project = Project.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end","def index\n redirect_to index_project_path\n end","def write_page\n contents = [people,projects,events].inject({}) { |x,y| x.merge(y) }\n File.open('index.html','w') do |f|\n f.write(@template.render(contents))\n end\n end","def new\n redirect_to project_path id: new_project_from_hash('transient' => true,\n 'name' => 'Untitled Project',\n 'default_workspace' => {\n 'name' => 'Untitled Workspace'\n }).id\n end","def url_for_page( project, opts )\n setup_project_urls( project )\n if (opts[:page_name])\n raise \"No bulletin provided!\" if (! opts[:bulletin])\n url_for :controller => 'content', :action => 'page',\n :project_name => project.name, \n :bulletin_title => opts[:bulletin].title,\n :page_name => opts[:page_name],\n :layout => opts[:layout]\n \n end\n end","def create\n flash[:notice] = 'The page was successfully created.' if page.save\n respond_with(page, location: project_page_path(page.project, page))\n end","def create\n @urlroot = Designax::Application.config.urlroot\n if params[:pk] == \"new\" and params[:name] == \"project_name\"\n project_name = params[:value]\n @project = Project.new()\n @project.project_name = project_name\n else\n @project = Project.new(params[:project])\n end\n\n respond_to do |format|\n if @project.save\n redirect_url = @urlroot + \"/projects\"\n response_url = { \"url\" => redirect_url }\n format.json { render json: response_url, status: 200 }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end","def new\n add_breadcrumb \"Nouveau\"\n @project = Project.new\n end","def show\n # turn ruby database into json\n # route to the project 3 page with this json\n # id = 1\n end","def front\n @title = \"a community for DIY environmental investigation\"\n render :template => \"home/home-2\"\n end","def create\n if @project.save\n flash[:success] = 'Project was saved!'\n redirect_to root_path\n else\n render 'new'\n end\n end","def project_new\n new_project.click\n end","def new\n\t\t\tlogger.debug \"******* paths loaded are #{Rails.application.config.assets.paths}\"\n\t\t\t@landing_page = LandingPage.new\n\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html # new.html.erb\n\t\t\t\tformat.json { render json: @landing_page }\n\t\t\tend\n\t\tend","def new\n @isgrey = true;\n @current_page = \"ADD PROJECT\"\n @project = Project.new\n @project_attachment = @project.project_attachments.build\n @slider_object = @project.slider_objects.build\n @project_field = @project.project_fields.build\n @project_other_field = @project.project_other_fields.build\n\n @types = Type.all\n @new_nav = true;\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end","def new\n @project = Project.new\n \n respond_to do |format|\n format.html # new.html.erb\n end\n end","def show\n @project = Project.find(params[:id])\n @page_title = \"Project: \" + @project.title\n end","def home\n @events = Event.published.confirmed.ordered.tease\n @teaser = Teaser.current.limit(1).first\n @sponsors = Sponsor.order(\"position\").all\n @about = Content.find_by_id(6)\n @donate = Content.find_by_id(7)\n render :layout => \"homepage\"\n end","def index\n prepare_projects_display\n \n end","def create\r\n\t\t\t@project = params[:id].present? ? Project.find(params[:id]) : Project.new(create_step: 0)\r\n\t\t\t\r\n\t\t\t# Author\r\n\t\t\tif @project.new_record?\r\n\t\t\t\tauthorize! :create, @project\r\n\t\t\telse\r\n\t\t\t\tauthorize! :edit, @project\r\n\t\t\tend\r\n\r\n\t\t\trender layout: 'layout_back'\r\n\t\tend","def new\r\n # This can and probably SHOULD be replaced with some URL rewrite magic\r\n # now that the project loader is Redmine project based.\r\n find_project()\r\n end","def create\t\t\t\t\t\t\t\t\t# Creates record in db and redirects (porbably to index)\n\t\t@project = Project.new(projects_params)\t# Passes only title and desc.\n\n \trespond_to do |format|\t\t\t\t\t# All this is doing is rendering stuff in case of json\n \t\tif @project.save\n \t\tformat.html { redirect_to @project, notice: 'Created a new project!' }\n \t\tformat.json { render :show, status: :created, location: @project }\n \t\telse\n \t\tformat.html { render :new }\n \t\t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n \t\tend\n \tend\n\tend","def create\n redirect_to pages_path\n end","def new\r\n @event = Event.new\r\n #@pages = Page.all\r\n @projects_pages = []\r\n projects = Project.all.sort{|a,b| a.name <=> b.name}\r\n projects.each do |project|\r\n @projects_pages << [\"#{project.name}\", project.pages.exclude_placeholder] unless project.pages.blank?\r\n end\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.xml { render :xml => @event }\r\n end\r\n end","def show\r\n @new_page = Page.new({project: @project, name: generate_new_page_name})\r\n @new_data_source = DataSource.new({project: @project})\r\n @pages_list = @project.pages.map {|i| [i.id, i.name]}\r\n @data_sources = @project.data_sources.includes(:data_source_type)\r\n end","def create\n @project = Project.new(project_params)\n\n if @project.save\n redirect_to action: 'index'\n else\n render 'new'\n end\n end","def create\n cmp = AzCompany.find(params[:az_project][:owner_id])\n @project = AzProject.create(params[:az_project][:name], cmp, current_user, params[:az_project][:public_access])\n\n @title = 'Создание нового сайта'\n\n respond_to do |format|\n if @project.id\n flash[:notice] = 'Проект успешно создан.'\n format.html { redirect_to(@project) }\n else\n format.html { render :template => 'az_projects/new', :owner_id => cmp.id }\n end\n end\n end","def new\n # == Admin restriction == #\n admin_restriction_area\n @title_admin = \"projets\"\n @project = Project.new\n end","def create_village_project\n iframe_src = \"

    This project created with #{ENV[\"APP_NAME\"]} and updated on \" + @project.updated_at.strftime(\"%A, %B %-d at %-I:%M %p\") +\"

    \"\n iframe_src = iframe_src.html_safe.to_str\n village_user_ids = @project.village_user_ids\n response = access_token.post(\"/api/projects\", params: {project: {name: @project.title, project_type_id: 15, source: \"original\", description: iframe_src, thumbnail_file_id: 769508, user_ids: village_user_ids} })\n village_project_id = response.parsed[\"project\"][\"id\"]\n @project.update_attributes(:village_id => village_project_id)\n end","def create\n \tif user_signed_in? then\n\t\t\t@project = Project.new(params[:project])\n authorize @project\n\t\t\tif @project.dmptemplate.nil? && params[:project][:funder_id] != \"\" then # this shouldn't be necessary - see setter for funder_id in project.rb\n\t\t\t\tfunder = Organisation.find(params[:project][:funder_id])\n\t\t\t\tif funder.dmptemplates.count == 1 then\n\t\t\t\t\t@project.dmptemplate = funder.published_templates.first\n\t\t\t\tend\n\t\t\telsif @project.dmptemplate.nil? || params[:default_tag] == 'true' then\n\t\t\t\tif @project.organisation.nil? || params[:default_tag] == 'true' || @project.organisation.published_templates.first.nil? then\n\t\t\t\t\t@project.dmptemplate = Dmptemplate.find_by_is_default(true)\n\t\t\t\telse\n\t\t\t\t\t@project.dmptemplate = @project.organisation.published_templates.first\n\t\t\t\tend\n\t\t\tend\n\t\t\t@project.principal_investigator = current_user.name(false)\n\n\t\t\t@project.title = I18n.t('helpers.project.my_project_name')+' ('+@project.dmptemplate.title+')'\n\t\t\t@project.assign_creator(current_user.id)\n\t\t\trespond_to do |format|\n\t\t\t\tif @project.save\n\t\t\t\t\tformat.html { redirect_to({:action => \"show\", :id => @project.slug, :show_form => \"yes\"}, {:notice => I18n.t('helpers.project.success')}) }\n\t\t\t\telse\n\t\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\trender(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)\n\t\tend\n\tend","def create(p)\n puts \"Creating page #{p}\"\n Dir.mkdir p unless File.exists? p\n Content.new(\"#{@dir}\", @extension).page p\n end","def index\n if spartan_signed_in?\n if current_spartan.admin\n @projects = Project.all()\n @header = \"All Projects\"\n else\n @projects = current_spartan.projects.all()\n @header = \"Your Projects\"\n end\n else\n redirect_to '/home'\n end\n \n end","def show\n @project = Project.find(@perk.project_id)\n add_breadcrumb @project.name.to_s, '/projects/' + @project.id.to_s\n end","def create\n visit(CentralAdmin).create_institutional_proposal\n on ProposalLogLookup do |look|\n look.proposal_number.set @proposal_number\n look.search\n look.select_item @proposal_number\n end\n on InstitutionalProposal do |create|\n create.expand_all\n @document_id=create.document_id\n @doc_header=create.doc_title\n @proposal_number=create.institutional_proposal_number\n fill_out create, :proposal_type, :award_id, :activity_type, :project_title, :description\n set_sponsor_code\n create.save\n end\n if @proposal_log && $current_page.errors.size==0\n pi = make ProjectPersonnelObject, principal_name: @proposal_log.principal_investigator,\n full_name: @proposal_log.pi_full_name,\n document_id: @document_id,\n lookup_class: @lookup_class,\n search_key: @search_key,\n doc_header: @doc_header\n @project_personnel << pi\n view :contacts\n @project_personnel.principal_investigator.set_up_units\n end\n end","def create\r\n html=params[:page][:html]\r\n @page = Page.new(params[:page])\r\n respond_to do |format|\r\n if @page.save\r\n format.html { redirect_to @page, notice: 'Page was successfully created.' }\r\n format.json { render json: @page, status: :created, location: @page }\r\n target = \"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\"\r\n if !File.directory?(\"#{Rails.public_path}/#{@page.project_id}\")\r\n Dir.mkdir(\"#{Rails.public_path}/#{@page.project_id}\")\r\n Dir.mkdir(\"#{Rails.public_path}/#{@page.project_id}/images\")\r\n end\r\n File.open(target, \"w+\") do |f|\r\n f.write(html)\r\n end\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @page.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end","def splash_page\n end","def home\n # check if signed_in and then display (you are currently signed in, view your profile)\n # automatically renders page 'users/home'\n if signed_in?\n redirect_to current_user\n else\n @event = Event.find(ENV['demopage'].to_i)\n @event_code = @event.event_code\n @url = demo_record_vg_url(:event_code => @event.event_code)\n\n\n @first_plan = Plan.find_by_my_plan_id(plan_set_one) # sets @first_plan the first plan object ACCORDING TO MY LEGEND (with my_plan_id)\n @second_plan = Plan.find_by_my_plan_id(plan_set_two)\n @third_plan = Plan.find_by_my_plan_id(plan_set_three)\n render :unsigned_home, :layout => nil\n end\n\n end","def generate_main_page_with(specs)\n main_page = Amy::Model::Main.new\n specs['resources'].each_pair { |resource, options|\n main_page.add_resource( { 'resource' => resource, 'title' => options['title'] } )\n }\n main_page.links = specs['links'] || []\n main_page.version = specs['api_version']\n main_page.base_url = specs['base_url']\n @generator.do(\"#{Amy::BASE_DIR}/views/main.erb.html\", main_page)\n end","def about\n # Static Page\n end","def create\n @new_nav = true;\n @project = Project.new(project_params)\n\n respond_to do |format|\n if @project.save\n if params[:project_attachments]\n create_attachments\n end\n\n if params[:project_fields]\n create_fields\n end\n\n if params[:slider_objects]\n create_slider_objects\n end\n\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\n format.json { render json: @project, status: :created, location: @project }\n else\n format.html { render action: \"new\" }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end","def new_voyage_port\n return if authorise_for_web(program_name?,'create')== false\n render_new_voyage_port\n end","def create\n if DeterLab.join_project(app_session.current_user_id, params[:project_id])\n redirect_to :dashboard, notice: t(\".success\")\n else\n flash.now.alert = t(\".failure\")\n render :new\n end\n rescue DeterLab::RequestError => e\n show_form e.message\n rescue DeterLab::Error => e\n show_form t(\".unknown_failure\")\n end","def create\r\n @project = Project.new(params[:project])\r\n @funders = Funder.all\r\n\r\n unless @project.has_outreach\t\t\t\r\n @placeholder_page = Page.new\r\n params[:funder_ids].to_a.each do |funder_id|\r\n @placeholder_page.funders << Funder.find_by_id(funder_id)\r\n end\r\n @placeholder_page.name = \"PLACEHOLDER PAGE - \" + @project.name\r\n @placeholder_page.is_placeholder = true\r\n @placeholder_page.has_outreach = false\r\n end\r\n\r\n respond_to do |format|\r\n if @project.save\r\n\r\n unless @project.has_outreach\r\n @placeholder_page.project = @project\r\n @placeholder_page.save!\r\n end\r\n\r\n expire_fragment('all_projects')\r\n if params[:project][:project_image_attributes].blank? || params[:project][:project_image_attributes][:image].blank?\r\n if session[:from_event] && session[:from_page]\r\n session[:from_page] = nil\r\n flash[:notice] = \"#{$projects_name_replacement.singularize.capitalize} was successfully created.\"\r\n format.html { redirect_to(:controller => 'pages', :action => 'new', :from_event => true)}\r\n elsif session[:from_page]\r\n session[:from_page] = nil\r\n format.html { redirect_to(new_page_path, :notice => \"#{$projects_name_replacement.singularize.capitalize} was successfully created.\") }\r\n else\r\n format.html { redirect_to( \"/users/manage_#{$projects_name_replacement}\", :notice => \"#{$projects_name_replacement.singularize.capitalize} was successfully created.\") }\r\n end\r\n format.xml { render :xml => @project, :status => :created, :location => @project }\r\n else\r\n format.html { render :action => \"crop_image\", :layout => 'backend' }\r\n end\r\n else\r\n @project.build_project_image\r\n\r\n format.html { render :action => \"new\", :layout => 'backend' }\r\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end","def index\n @current_page = \"PROJECTS\"\n @projects = Project.all\n @projects_for_review = Project.pending_review if current_user\n @new_nav = true;\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @projects }\n end\n end","def generate_project_file\n template_file = @template_dir + 'hhp_file.hhp.rhtml'\n\n @values = { :title => @options.title, :opname => @outputdir.basename }\n \n static_files = ['index.html', 'classindex.html', 'fileindex.html']\n @values[:html_files] = static_files + (@generated_files+@classes).map{|f| f.path}.uniq\n \n out_file = @outputdir + @project_name\n debug_msg \" rendering #{out_file}\"\n render_template template_file, out_file do |io| binding end\n end","def project; end","def create\n\t\t@project = Project.new(params[:project].merge({:user_id => present_user.id}))\n\t\tmake_breadcrumbs\n\n\t\trespond_to do |format|\n\t\t\tif @project.save\n\t\t\t\tformat.html { redirect_to @project, notice: t('app.projects.created') }\n\t\t\t\tformat.json { render json: @project, status: :created, location: @project }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @project.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend","def new\n # Agrega el breadcrumb de la pagina new de proyecto\n add_breadcrumb I18n.t('project.new'), :controller => \"projects\", :action => \"new\"\n @project = Project.new\n end","def projectinfo_for(p)\n res = sitemap.find_resource_by_page_id(\"projectinfo/#{project_slug(p)}\")\n if res\n return res.render\n end\n end","def project_based_concept_planning_fulfillment\n @project = Project.find_by_id params[:project_id] \n \n add_breadcrumb \"Project Management\", 'projects_url' \n set_breadcrumb_for @project, 'concept_planning_fulfillment_url' + \"(#{@project.id})\", \n \"Concept Planning\"\n \n # render :file => \"projects/job_requests/concept_planning/concept_planning_fulfillment\"\n end","def index\n standard_index(Project, params[:page], false, \"\", :name, false, true)\n end","def add_project\n\n\t\t@projects = Project.new(project_params)\n\t\tif @projects.save\n\t\t\tredirect_to '/details'\n\t\telse\n\t\t\trender 'index'\n\t\tend\n\tend","def default_page\n\t\t\t\tDir.chdir File.join(self.source, @site_name)\n\t\t\t\tFile.open Settings::PAGES_TEMPLATE + '/page.md', 'r' do |file|\n\n\t\t\t\t\tfront_matter = {\n\t\t\t\t\t\t'title' => 'Home Page',\n\t\t\t\t\t\t'date' => Time.now.strftime(\"%Y-%m-%d\"),\n\t\t\t\t\t\t'author' => 'Your Name',\n\t\t\t\t\t\t'template' => 'page'\n\t\t\t\t\t}\n\n\t\t\t\t\tcontents = Liquid::Template.parse(file.read).render front_matter \n\t\t\t\t\tFile.open(File.join(\"pages\", \"index.md\"), \"w\") do |f|\n\t\t\t\t\t\tf.write contents\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tFileUtils.mkdir_p(File.join(self.source, @site_name, \"media/images\", \"index\"))\n\t\t\tend","def homepage\n end","def homepage\n end","def index\t\t\t\t\t\t\t\t\t# Index is a list of things or ...basically your index page.\n\t\t@projects = Project.all\t\t\t\t\t# Make a variable that can be seen by the view! with the @ - IT'S PLURAL!\n\tend","def new\n @page = Page.new\n @pagelist = @club.all_pages\n \n @page_title = \"New Page\"\n @site_section = \"admin\"\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @page }\n end\n end","def template_page(site); end","def index\n #@projects = Project.all\n PivotalTracker::Client.token = current_user.setting.pt_api_key\n logger.debug current_user.setting.pt_api_key\n @projects = PivotalTracker::Project.all\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @projects }\n end\n end","def landing\n \n end","def landing\n \n end","def to_page\n \n u = User.find_by_login(authorid)\n \n UserActionObserver.current_user = u\n \n page = Page.new(\n :title => title,\n :created_at => lastmod,\n :updated_at => lastmod,\n :slug => url_title,\n :status => Status[:published],\n :breadcrumb => title,\n :published_at => posted, \n :enable_comments => annotate.to_s,\n :keywords => keywords,\n :created_by => u,\n :updated_by => u\n )\n \n page.parts << PagePart.new(:name => 'body', :filter_id => \"Textile\", :content => body )\n page.parts << PagePart.new(:name => 'intro', :filter_id => \"Textile\", :content => body.split(/\\r\\n\\s*\\r\\n/).first)\n \n page\n end","def index\n redirect_to Project.find(params[:project_id])\n end","def index\r\n #front end view used\r\n\r\n session[:filter_type] = nil\r\n session[:filter_query] = nil\r\n Rails.cache.delete('total_stats')\r\n\r\n #randomize what project a user sees when first going to the website\r\n #changes everyday at midnight\r\n @project = []\r\n\r\n if cookies[:landing_project].blank?\r\n rand_command = ActiveRecord::Base.connection.adapter_name.downcase.include?('mysql') ? \"RAND()\" : \"RANDOM()\" #RAND() for MySQL; RANDOM() for sqlite3\r\n @project = Project.exclude_multi_project.has_outreach.published.first(:order => rand_command)\r\n cookies[:landing_project] = { :value => @project.name, :expires => Time.now.midnight + 1.day} if @project\r\n else\r\n @project = Project.find_by_name(cookies[:landing_project])\r\n end\r\n\r\n if @project\r\n results = get_project_slider_info(@project.name)\r\n @project_slider_html = results\r\n @formatted_project_name = @project.name.gsub(' ','_')\r\n end\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(:controller => 'projects', :action => 'show', :id => @formatted_project_name) }\r\n format.xml { render :xml => @project }\r\n end\r\n end","def setup\n @page = pages(:homepage)\n end","def new\n @project = Project.new\n end","def new\n @project = Project.new\n end","def new\n @project = Project.new\n end","def new\n @project = Project.new\n end","def new\n @project = Project.new\n end","def new\n @project = Project.new\n end","def new\n @project = Project.new\n end","def new\n @project = Project.new\n end","def new\n @project = Project.new\n end","def new\n @project = Project.new\n end","def new\n @project = Project.new\n end","def new\n @project = Project.new\n end","def create\n @project = Project.new(params[:project])\n\n respond_to do |format|\n if @project.save\n format.html { redirect_to(@project, :notice => 'Project was successfully created.') }\n format.xml { render :xml => @project, :status => :created, :location => @project }\n else\n prepare\n format.html { render :action => \"new\" }\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\n end\n end\n end","def project_based_shoot_finalization\n @project = Project.find_by_id params[:project_id] \n\n add_breadcrumb \"Project Management\", 'projects_url' \n set_breadcrumb_for @project, 'project_based_shoot_finalization_url' + \"(#{@project.id})\", \n \"Shoot Data Planning\"\n\n # render :file => \"projects/job_requests/concept_planning/concept_planning_fulfillment\"\n end","def new\n @project = Project.new()\n end","def new_project\n if current_admin.present? || current_client.present?\n @project = Project.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n else\n redirect_to new_admin_session_path and return\n end\n end"],"string":"[\n \"def create_empty_page(p)\\n cli.say 'Creating project page'\\n FileUtils.mkdir_p(browse_file(p, '.'))\\n %w[favicon-32.png style.css].each do |i|\\n FileUtils.cp(template_file(i), browse_file(p, i))\\n end\\n write_file(p, 'about.html') do\\n build_from_template('about.html', citation: MiGA::MiGA.CITATION)\\n end\\n end\",\n \"def index\\n @main_page = \\\"Pessoal\\\"\\n @page_title = \\\"Projetos\\\"\\n @projects = Project.all\\n @current_projects = Project.current_projects\\n end\",\n \"def index\\n\\t @title = \\\"Miradi Data Server\\\"\\n\\t \\\"Welcome to the Miradi Data Server!
    \\\" +\\n\\t\\t\\\"
    \\\" + \\n\\t\\t\\\"Project Name: \\\" +\\n\\t\\t\\\"\\\" + \\n\\t\\t\\\"
    \\\"\\n\\tend\",\n \"def create\\r\\n @project = current_user.projects.new(project_params)\\r\\n new_page = @project.pages.new({ name: generate_new_page_name})\\r\\n @project.startpage = new_page\\r\\n @project.date_created = Time.now\\r\\n @project.last_modified = Time.now\\r\\n respond_to do |format|\\r\\n if @project.save\\r\\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\\r\\n format.json { render action: 'show', status: :created, location: @project }\\r\\n else\\r\\n format.html { render action: 'new' }\\r\\n format.json { render json: @project.errors, status: :unprocessable_entity }\\r\\n end\\r\\n end\\r\\n end\",\n \"def home\\n error_404 unless (@page = Page.where(:link_url => '/').first).present?\\n \\n call_back\\n \\n @test = @profile\\n @test2 = @current_patner.nil?\\n \\n # Member.project; Project.hoster\\n \\n if !Project.all.empty?\\n @projects = Project.all\\n end\\n end\",\n \"def create_landing\\r\\n\\r\\n end\",\n \"def new\\n @brigade_project = BrigadeProject.new\\n general_static_response(@brigade_project)\\n end\",\n \"def index\\n #respond(\\\"
    \\\" + request.env.inspect + \\\"
    \\\")\\n @title = \\\"Welcome to Pastr!\\\"\\n end\",\n \"def new\\r\\n session[:from_page] = params[:from_page]\\r\\n session[:from_event] = params[:from_event]\\r\\n\\r\\n @project = Project.new\\r\\n @project.build_project_image\\r\\n @project.project_web_links.build\\r\\n @funders = Funder.all\\r\\n\\r\\n respond_to do |format|\\r\\n format.html {render :layout => 'backend'} # new.html.erb\\r\\n format.xml { render :xml => @project }\\r\\n end\\r\\n end\",\n \"def new\\n @project = Project.new\\n @title = \\\"New Project\\\"\\n end\",\n \"def new\\n @project = Project.new\\n\\n render :layout => \\\"empty\\\"\\n end\",\n \"def create\\n @project = Project.new(project_params)\\n if @project.save\\n redirect_to \\\"/charity_lp/landingpage\\\", notice: 'Research Form was successfully created.'\\n # format.json { render :show, status: :created, location: @project }\\n else\\n render 'new'\\n\\n # format.html {redirect_to \\\"/projects/new\\\", notice: 'Errors in submition, please ensure all fields are filled in correctly' }\\n # format.json { render json: @project.errors, status: :unprocessable_entity }\\n end\\n end\",\n \"def new\\n\\t\\t@project = Project.new({:project_state_type_id => ProjectStateType.find_by_code('preparation').id})\\n\\t\\tputs @project.inspect\\n\\t\\tmake_breadcrumbs\\n\\t\\t\\n\\t\\trespond_to do |format|\\n\\t\\t\\tformat.html # new.html.erb\\n\\t\\t\\tformat.json { render json: @project }\\n\\t\\tend\\n\\tend\",\n \"def first_mandate\\n # renders static page\\n end\",\n \"def new_project\\n @request = Request.new(data_type: :project)\\n @request.build_contact\\n @request.build_project\\n @request.build_general_information\\n\\n render 'new'\\n end\",\n \"def home\\n @projects = Project.all.where('published = true')\\n @header = \\\"Published Projects\\\"\\n end\",\n \"def load_index_page\\n @page ||= Language.current_root_page\\n render template: \\\"alchemy/welcome\\\", layout: false if signup_required?\\n end\",\n \"def show\\n @page_title = \\\"Voluntips | Projekt: \\\" + @project.title\\n set_show_keywords\\n end\",\n \"def show\\n @project = Project.find params[:id]\\n @page_title = \\\"Project #{@project.name}\\\"\\n end\",\n \"def home\\n\\t\\t# Home Page\\n\\tend\",\n \"def new\\n \\t@pagenav = Page.find_all_by_published('true')\\n @project = Project.new\\n\\n respond_to do |format|\\n format.html # new.html.erb\\n format.json { render json: @project }\\n end\\n end\",\n \"def index\\n redirect_to index_project_path\\n end\",\n \"def write_page\\n contents = [people,projects,events].inject({}) { |x,y| x.merge(y) }\\n File.open('index.html','w') do |f|\\n f.write(@template.render(contents))\\n end\\n end\",\n \"def new\\n redirect_to project_path id: new_project_from_hash('transient' => true,\\n 'name' => 'Untitled Project',\\n 'default_workspace' => {\\n 'name' => 'Untitled Workspace'\\n }).id\\n end\",\n \"def url_for_page( project, opts )\\n setup_project_urls( project )\\n if (opts[:page_name])\\n raise \\\"No bulletin provided!\\\" if (! opts[:bulletin])\\n url_for :controller => 'content', :action => 'page',\\n :project_name => project.name, \\n :bulletin_title => opts[:bulletin].title,\\n :page_name => opts[:page_name],\\n :layout => opts[:layout]\\n \\n end\\n end\",\n \"def create\\n flash[:notice] = 'The page was successfully created.' if page.save\\n respond_with(page, location: project_page_path(page.project, page))\\n end\",\n \"def create\\n @urlroot = Designax::Application.config.urlroot\\n if params[:pk] == \\\"new\\\" and params[:name] == \\\"project_name\\\"\\n project_name = params[:value]\\n @project = Project.new()\\n @project.project_name = project_name\\n else\\n @project = Project.new(params[:project])\\n end\\n\\n respond_to do |format|\\n if @project.save\\n redirect_url = @urlroot + \\\"/projects\\\"\\n response_url = { \\\"url\\\" => redirect_url }\\n format.json { render json: response_url, status: 200 }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @project.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def new\\n add_breadcrumb \\\"Nouveau\\\"\\n @project = Project.new\\n end\",\n \"def show\\n # turn ruby database into json\\n # route to the project 3 page with this json\\n # id = 1\\n end\",\n \"def front\\n @title = \\\"a community for DIY environmental investigation\\\"\\n render :template => \\\"home/home-2\\\"\\n end\",\n \"def create\\n if @project.save\\n flash[:success] = 'Project was saved!'\\n redirect_to root_path\\n else\\n render 'new'\\n end\\n end\",\n \"def project_new\\n new_project.click\\n end\",\n \"def new\\n\\t\\t\\tlogger.debug \\\"******* paths loaded are #{Rails.application.config.assets.paths}\\\"\\n\\t\\t\\t@landing_page = LandingPage.new\\n\\n\\t\\t\\trespond_to do |format|\\n\\t\\t\\t\\tformat.html # new.html.erb\\n\\t\\t\\t\\tformat.json { render json: @landing_page }\\n\\t\\t\\tend\\n\\t\\tend\",\n \"def new\\n @isgrey = true;\\n @current_page = \\\"ADD PROJECT\\\"\\n @project = Project.new\\n @project_attachment = @project.project_attachments.build\\n @slider_object = @project.slider_objects.build\\n @project_field = @project.project_fields.build\\n @project_other_field = @project.project_other_fields.build\\n\\n @types = Type.all\\n @new_nav = true;\\n\\n respond_to do |format|\\n format.html # new.html.erb\\n format.json { render json: @project }\\n end\\n end\",\n \"def new\\n @project = Project.new\\n \\n respond_to do |format|\\n format.html # new.html.erb\\n end\\n end\",\n \"def show\\n @project = Project.find(params[:id])\\n @page_title = \\\"Project: \\\" + @project.title\\n end\",\n \"def home\\n @events = Event.published.confirmed.ordered.tease\\n @teaser = Teaser.current.limit(1).first\\n @sponsors = Sponsor.order(\\\"position\\\").all\\n @about = Content.find_by_id(6)\\n @donate = Content.find_by_id(7)\\n render :layout => \\\"homepage\\\"\\n end\",\n \"def index\\n prepare_projects_display\\n \\n end\",\n \"def create\\r\\n\\t\\t\\t@project = params[:id].present? ? Project.find(params[:id]) : Project.new(create_step: 0)\\r\\n\\t\\t\\t\\r\\n\\t\\t\\t# Author\\r\\n\\t\\t\\tif @project.new_record?\\r\\n\\t\\t\\t\\tauthorize! :create, @project\\r\\n\\t\\t\\telse\\r\\n\\t\\t\\t\\tauthorize! :edit, @project\\r\\n\\t\\t\\tend\\r\\n\\r\\n\\t\\t\\trender layout: 'layout_back'\\r\\n\\t\\tend\",\n \"def new\\r\\n # This can and probably SHOULD be replaced with some URL rewrite magic\\r\\n # now that the project loader is Redmine project based.\\r\\n find_project()\\r\\n end\",\n \"def create\\t\\t\\t\\t\\t\\t\\t\\t\\t# Creates record in db and redirects (porbably to index)\\n\\t\\t@project = Project.new(projects_params)\\t# Passes only title and desc.\\n\\n \\trespond_to do |format|\\t\\t\\t\\t\\t# All this is doing is rendering stuff in case of json\\n \\t\\tif @project.save\\n \\t\\tformat.html { redirect_to @project, notice: 'Created a new project!' }\\n \\t\\tformat.json { render :show, status: :created, location: @project }\\n \\t\\telse\\n \\t\\tformat.html { render :new }\\n \\t\\t\\tformat.json { render json: @project.errors, status: :unprocessable_entity }\\n \\t\\tend\\n \\tend\\n\\tend\",\n \"def create\\n redirect_to pages_path\\n end\",\n \"def new\\r\\n @event = Event.new\\r\\n #@pages = Page.all\\r\\n @projects_pages = []\\r\\n projects = Project.all.sort{|a,b| a.name <=> b.name}\\r\\n projects.each do |project|\\r\\n @projects_pages << [\\\"#{project.name}\\\", project.pages.exclude_placeholder] unless project.pages.blank?\\r\\n end\\r\\n respond_to do |format|\\r\\n format.html # new.html.erb\\r\\n format.xml { render :xml => @event }\\r\\n end\\r\\n end\",\n \"def show\\r\\n @new_page = Page.new({project: @project, name: generate_new_page_name})\\r\\n @new_data_source = DataSource.new({project: @project})\\r\\n @pages_list = @project.pages.map {|i| [i.id, i.name]}\\r\\n @data_sources = @project.data_sources.includes(:data_source_type)\\r\\n end\",\n \"def create\\n @project = Project.new(project_params)\\n\\n if @project.save\\n redirect_to action: 'index'\\n else\\n render 'new'\\n end\\n end\",\n \"def create\\n cmp = AzCompany.find(params[:az_project][:owner_id])\\n @project = AzProject.create(params[:az_project][:name], cmp, current_user, params[:az_project][:public_access])\\n\\n @title = 'Создание нового сайта'\\n\\n respond_to do |format|\\n if @project.id\\n flash[:notice] = 'Проект успешно создан.'\\n format.html { redirect_to(@project) }\\n else\\n format.html { render :template => 'az_projects/new', :owner_id => cmp.id }\\n end\\n end\\n end\",\n \"def new\\n # == Admin restriction == #\\n admin_restriction_area\\n @title_admin = \\\"projets\\\"\\n @project = Project.new\\n end\",\n \"def create_village_project\\n iframe_src = \\\"

    This project created with #{ENV[\\\"APP_NAME\\\"]} and updated on \\\" + @project.updated_at.strftime(\\\"%A, %B %-d at %-I:%M %p\\\") +\\\"

    \\\"\\n iframe_src = iframe_src.html_safe.to_str\\n village_user_ids = @project.village_user_ids\\n response = access_token.post(\\\"/api/projects\\\", params: {project: {name: @project.title, project_type_id: 15, source: \\\"original\\\", description: iframe_src, thumbnail_file_id: 769508, user_ids: village_user_ids} })\\n village_project_id = response.parsed[\\\"project\\\"][\\\"id\\\"]\\n @project.update_attributes(:village_id => village_project_id)\\n end\",\n \"def create\\n \\tif user_signed_in? then\\n\\t\\t\\t@project = Project.new(params[:project])\\n authorize @project\\n\\t\\t\\tif @project.dmptemplate.nil? && params[:project][:funder_id] != \\\"\\\" then # this shouldn't be necessary - see setter for funder_id in project.rb\\n\\t\\t\\t\\tfunder = Organisation.find(params[:project][:funder_id])\\n\\t\\t\\t\\tif funder.dmptemplates.count == 1 then\\n\\t\\t\\t\\t\\t@project.dmptemplate = funder.published_templates.first\\n\\t\\t\\t\\tend\\n\\t\\t\\telsif @project.dmptemplate.nil? || params[:default_tag] == 'true' then\\n\\t\\t\\t\\tif @project.organisation.nil? || params[:default_tag] == 'true' || @project.organisation.published_templates.first.nil? then\\n\\t\\t\\t\\t\\t@project.dmptemplate = Dmptemplate.find_by_is_default(true)\\n\\t\\t\\t\\telse\\n\\t\\t\\t\\t\\t@project.dmptemplate = @project.organisation.published_templates.first\\n\\t\\t\\t\\tend\\n\\t\\t\\tend\\n\\t\\t\\t@project.principal_investigator = current_user.name(false)\\n\\n\\t\\t\\t@project.title = I18n.t('helpers.project.my_project_name')+' ('+@project.dmptemplate.title+')'\\n\\t\\t\\t@project.assign_creator(current_user.id)\\n\\t\\t\\trespond_to do |format|\\n\\t\\t\\t\\tif @project.save\\n\\t\\t\\t\\t\\tformat.html { redirect_to({:action => \\\"show\\\", :id => @project.slug, :show_form => \\\"yes\\\"}, {:notice => I18n.t('helpers.project.success')}) }\\n\\t\\t\\t\\telse\\n\\t\\t\\t\\t\\tformat.html { render action: \\\"new\\\" }\\n\\t\\t\\t\\tend\\n\\t\\t\\tend\\n\\t\\telse\\n\\t\\t\\trender(:file => File.join(Rails.root, 'public/403.html'), :status => 403, :layout => false)\\n\\t\\tend\\n\\tend\",\n \"def create(p)\\n puts \\\"Creating page #{p}\\\"\\n Dir.mkdir p unless File.exists? p\\n Content.new(\\\"#{@dir}\\\", @extension).page p\\n end\",\n \"def index\\n if spartan_signed_in?\\n if current_spartan.admin\\n @projects = Project.all()\\n @header = \\\"All Projects\\\"\\n else\\n @projects = current_spartan.projects.all()\\n @header = \\\"Your Projects\\\"\\n end\\n else\\n redirect_to '/home'\\n end\\n \\n end\",\n \"def show\\n @project = Project.find(@perk.project_id)\\n add_breadcrumb @project.name.to_s, '/projects/' + @project.id.to_s\\n end\",\n \"def create\\n visit(CentralAdmin).create_institutional_proposal\\n on ProposalLogLookup do |look|\\n look.proposal_number.set @proposal_number\\n look.search\\n look.select_item @proposal_number\\n end\\n on InstitutionalProposal do |create|\\n create.expand_all\\n @document_id=create.document_id\\n @doc_header=create.doc_title\\n @proposal_number=create.institutional_proposal_number\\n fill_out create, :proposal_type, :award_id, :activity_type, :project_title, :description\\n set_sponsor_code\\n create.save\\n end\\n if @proposal_log && $current_page.errors.size==0\\n pi = make ProjectPersonnelObject, principal_name: @proposal_log.principal_investigator,\\n full_name: @proposal_log.pi_full_name,\\n document_id: @document_id,\\n lookup_class: @lookup_class,\\n search_key: @search_key,\\n doc_header: @doc_header\\n @project_personnel << pi\\n view :contacts\\n @project_personnel.principal_investigator.set_up_units\\n end\\n end\",\n \"def create\\r\\n html=params[:page][:html]\\r\\n @page = Page.new(params[:page])\\r\\n respond_to do |format|\\r\\n if @page.save\\r\\n format.html { redirect_to @page, notice: 'Page was successfully created.' }\\r\\n format.json { render json: @page, status: :created, location: @page }\\r\\n target = \\\"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\\\"\\r\\n if !File.directory?(\\\"#{Rails.public_path}/#{@page.project_id}\\\")\\r\\n Dir.mkdir(\\\"#{Rails.public_path}/#{@page.project_id}\\\")\\r\\n Dir.mkdir(\\\"#{Rails.public_path}/#{@page.project_id}/images\\\")\\r\\n end\\r\\n File.open(target, \\\"w+\\\") do |f|\\r\\n f.write(html)\\r\\n end\\r\\n else\\r\\n format.html { render action: \\\"new\\\" }\\r\\n format.json { render json: @page.errors, status: :unprocessable_entity }\\r\\n end\\r\\n end\\r\\n end\",\n \"def splash_page\\n end\",\n \"def home\\n # check if signed_in and then display (you are currently signed in, view your profile)\\n # automatically renders page 'users/home'\\n if signed_in?\\n redirect_to current_user\\n else\\n @event = Event.find(ENV['demopage'].to_i)\\n @event_code = @event.event_code\\n @url = demo_record_vg_url(:event_code => @event.event_code)\\n\\n\\n @first_plan = Plan.find_by_my_plan_id(plan_set_one) # sets @first_plan the first plan object ACCORDING TO MY LEGEND (with my_plan_id)\\n @second_plan = Plan.find_by_my_plan_id(plan_set_two)\\n @third_plan = Plan.find_by_my_plan_id(plan_set_three)\\n render :unsigned_home, :layout => nil\\n end\\n\\n end\",\n \"def generate_main_page_with(specs)\\n main_page = Amy::Model::Main.new\\n specs['resources'].each_pair { |resource, options|\\n main_page.add_resource( { 'resource' => resource, 'title' => options['title'] } )\\n }\\n main_page.links = specs['links'] || []\\n main_page.version = specs['api_version']\\n main_page.base_url = specs['base_url']\\n @generator.do(\\\"#{Amy::BASE_DIR}/views/main.erb.html\\\", main_page)\\n end\",\n \"def about\\n # Static Page\\n end\",\n \"def create\\n @new_nav = true;\\n @project = Project.new(project_params)\\n\\n respond_to do |format|\\n if @project.save\\n if params[:project_attachments]\\n create_attachments\\n end\\n\\n if params[:project_fields]\\n create_fields\\n end\\n\\n if params[:slider_objects]\\n create_slider_objects\\n end\\n\\n format.html { redirect_to @project, notice: 'Project was successfully created.' }\\n format.json { render json: @project, status: :created, location: @project }\\n else\\n format.html { render action: \\\"new\\\" }\\n format.json { render json: @project.errors, status: :unprocessable_entity }\\n end\\n end\\n end\",\n \"def new_voyage_port\\n return if authorise_for_web(program_name?,'create')== false\\n render_new_voyage_port\\n end\",\n \"def create\\n if DeterLab.join_project(app_session.current_user_id, params[:project_id])\\n redirect_to :dashboard, notice: t(\\\".success\\\")\\n else\\n flash.now.alert = t(\\\".failure\\\")\\n render :new\\n end\\n rescue DeterLab::RequestError => e\\n show_form e.message\\n rescue DeterLab::Error => e\\n show_form t(\\\".unknown_failure\\\")\\n end\",\n \"def create\\r\\n @project = Project.new(params[:project])\\r\\n @funders = Funder.all\\r\\n\\r\\n unless @project.has_outreach\\t\\t\\t\\r\\n @placeholder_page = Page.new\\r\\n params[:funder_ids].to_a.each do |funder_id|\\r\\n @placeholder_page.funders << Funder.find_by_id(funder_id)\\r\\n end\\r\\n @placeholder_page.name = \\\"PLACEHOLDER PAGE - \\\" + @project.name\\r\\n @placeholder_page.is_placeholder = true\\r\\n @placeholder_page.has_outreach = false\\r\\n end\\r\\n\\r\\n respond_to do |format|\\r\\n if @project.save\\r\\n\\r\\n unless @project.has_outreach\\r\\n @placeholder_page.project = @project\\r\\n @placeholder_page.save!\\r\\n end\\r\\n\\r\\n expire_fragment('all_projects')\\r\\n if params[:project][:project_image_attributes].blank? || params[:project][:project_image_attributes][:image].blank?\\r\\n if session[:from_event] && session[:from_page]\\r\\n session[:from_page] = nil\\r\\n flash[:notice] = \\\"#{$projects_name_replacement.singularize.capitalize} was successfully created.\\\"\\r\\n format.html { redirect_to(:controller => 'pages', :action => 'new', :from_event => true)}\\r\\n elsif session[:from_page]\\r\\n session[:from_page] = nil\\r\\n format.html { redirect_to(new_page_path, :notice => \\\"#{$projects_name_replacement.singularize.capitalize} was successfully created.\\\") }\\r\\n else\\r\\n format.html { redirect_to( \\\"/users/manage_#{$projects_name_replacement}\\\", :notice => \\\"#{$projects_name_replacement.singularize.capitalize} was successfully created.\\\") }\\r\\n end\\r\\n format.xml { render :xml => @project, :status => :created, :location => @project }\\r\\n else\\r\\n format.html { render :action => \\\"crop_image\\\", :layout => 'backend' }\\r\\n end\\r\\n else\\r\\n @project.build_project_image\\r\\n\\r\\n format.html { render :action => \\\"new\\\", :layout => 'backend' }\\r\\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\\r\\n end\\r\\n end\\r\\n end\",\n \"def index\\n @current_page = \\\"PROJECTS\\\"\\n @projects = Project.all\\n @projects_for_review = Project.pending_review if current_user\\n @new_nav = true;\\n\\n respond_to do |format|\\n format.html # index.html.erb\\n format.json { render json: @projects }\\n end\\n end\",\n \"def generate_project_file\\n template_file = @template_dir + 'hhp_file.hhp.rhtml'\\n\\n @values = { :title => @options.title, :opname => @outputdir.basename }\\n \\n static_files = ['index.html', 'classindex.html', 'fileindex.html']\\n @values[:html_files] = static_files + (@generated_files+@classes).map{|f| f.path}.uniq\\n \\n out_file = @outputdir + @project_name\\n debug_msg \\\" rendering #{out_file}\\\"\\n render_template template_file, out_file do |io| binding end\\n end\",\n \"def project; end\",\n \"def create\\n\\t\\t@project = Project.new(params[:project].merge({:user_id => present_user.id}))\\n\\t\\tmake_breadcrumbs\\n\\n\\t\\trespond_to do |format|\\n\\t\\t\\tif @project.save\\n\\t\\t\\t\\tformat.html { redirect_to @project, notice: t('app.projects.created') }\\n\\t\\t\\t\\tformat.json { render json: @project, status: :created, location: @project }\\n\\t\\t\\telse\\n\\t\\t\\t\\tformat.html { render action: \\\"new\\\" }\\n\\t\\t\\t\\tformat.json { render json: @project.errors, status: :unprocessable_entity }\\n\\t\\t\\tend\\n\\t\\tend\\n\\tend\",\n \"def new\\n # Agrega el breadcrumb de la pagina new de proyecto\\n add_breadcrumb I18n.t('project.new'), :controller => \\\"projects\\\", :action => \\\"new\\\"\\n @project = Project.new\\n end\",\n \"def projectinfo_for(p)\\n res = sitemap.find_resource_by_page_id(\\\"projectinfo/#{project_slug(p)}\\\")\\n if res\\n return res.render\\n end\\n end\",\n \"def project_based_concept_planning_fulfillment\\n @project = Project.find_by_id params[:project_id] \\n \\n add_breadcrumb \\\"Project Management\\\", 'projects_url' \\n set_breadcrumb_for @project, 'concept_planning_fulfillment_url' + \\\"(#{@project.id})\\\", \\n \\\"Concept Planning\\\"\\n \\n # render :file => \\\"projects/job_requests/concept_planning/concept_planning_fulfillment\\\"\\n end\",\n \"def index\\n standard_index(Project, params[:page], false, \\\"\\\", :name, false, true)\\n end\",\n \"def add_project\\n\\n\\t\\t@projects = Project.new(project_params)\\n\\t\\tif @projects.save\\n\\t\\t\\tredirect_to '/details'\\n\\t\\telse\\n\\t\\t\\trender 'index'\\n\\t\\tend\\n\\tend\",\n \"def default_page\\n\\t\\t\\t\\tDir.chdir File.join(self.source, @site_name)\\n\\t\\t\\t\\tFile.open Settings::PAGES_TEMPLATE + '/page.md', 'r' do |file|\\n\\n\\t\\t\\t\\t\\tfront_matter = {\\n\\t\\t\\t\\t\\t\\t'title' => 'Home Page',\\n\\t\\t\\t\\t\\t\\t'date' => Time.now.strftime(\\\"%Y-%m-%d\\\"),\\n\\t\\t\\t\\t\\t\\t'author' => 'Your Name',\\n\\t\\t\\t\\t\\t\\t'template' => 'page'\\n\\t\\t\\t\\t\\t}\\n\\n\\t\\t\\t\\t\\tcontents = Liquid::Template.parse(file.read).render front_matter \\n\\t\\t\\t\\t\\tFile.open(File.join(\\\"pages\\\", \\\"index.md\\\"), \\\"w\\\") do |f|\\n\\t\\t\\t\\t\\t\\tf.write contents\\n\\t\\t\\t\\t\\tend\\n\\t\\t\\t\\tend\\n\\t\\t\\t\\tFileUtils.mkdir_p(File.join(self.source, @site_name, \\\"media/images\\\", \\\"index\\\"))\\n\\t\\t\\tend\",\n \"def homepage\\n end\",\n \"def homepage\\n end\",\n \"def index\\t\\t\\t\\t\\t\\t\\t\\t\\t# Index is a list of things or ...basically your index page.\\n\\t\\t@projects = Project.all\\t\\t\\t\\t\\t# Make a variable that can be seen by the view! with the @ - IT'S PLURAL!\\n\\tend\",\n \"def new\\n @page = Page.new\\n @pagelist = @club.all_pages\\n \\n @page_title = \\\"New Page\\\"\\n @site_section = \\\"admin\\\"\\n respond_to do |format|\\n format.html # new.html.erb\\n format.xml { render :xml => @page }\\n end\\n end\",\n \"def template_page(site); end\",\n \"def index\\n #@projects = Project.all\\n PivotalTracker::Client.token = current_user.setting.pt_api_key\\n logger.debug current_user.setting.pt_api_key\\n @projects = PivotalTracker::Project.all\\n respond_to do |format|\\n format.html # index.html.erb\\n format.xml { render :xml => @projects }\\n end\\n end\",\n \"def landing\\n \\n end\",\n \"def landing\\n \\n end\",\n \"def to_page\\n \\n u = User.find_by_login(authorid)\\n \\n UserActionObserver.current_user = u\\n \\n page = Page.new(\\n :title => title,\\n :created_at => lastmod,\\n :updated_at => lastmod,\\n :slug => url_title,\\n :status => Status[:published],\\n :breadcrumb => title,\\n :published_at => posted, \\n :enable_comments => annotate.to_s,\\n :keywords => keywords,\\n :created_by => u,\\n :updated_by => u\\n )\\n \\n page.parts << PagePart.new(:name => 'body', :filter_id => \\\"Textile\\\", :content => body )\\n page.parts << PagePart.new(:name => 'intro', :filter_id => \\\"Textile\\\", :content => body.split(/\\\\r\\\\n\\\\s*\\\\r\\\\n/).first)\\n \\n page\\n end\",\n \"def index\\n redirect_to Project.find(params[:project_id])\\n end\",\n \"def index\\r\\n #front end view used\\r\\n\\r\\n session[:filter_type] = nil\\r\\n session[:filter_query] = nil\\r\\n Rails.cache.delete('total_stats')\\r\\n\\r\\n #randomize what project a user sees when first going to the website\\r\\n #changes everyday at midnight\\r\\n @project = []\\r\\n\\r\\n if cookies[:landing_project].blank?\\r\\n rand_command = ActiveRecord::Base.connection.adapter_name.downcase.include?('mysql') ? \\\"RAND()\\\" : \\\"RANDOM()\\\" #RAND() for MySQL; RANDOM() for sqlite3\\r\\n @project = Project.exclude_multi_project.has_outreach.published.first(:order => rand_command)\\r\\n cookies[:landing_project] = { :value => @project.name, :expires => Time.now.midnight + 1.day} if @project\\r\\n else\\r\\n @project = Project.find_by_name(cookies[:landing_project])\\r\\n end\\r\\n\\r\\n if @project\\r\\n results = get_project_slider_info(@project.name)\\r\\n @project_slider_html = results\\r\\n @formatted_project_name = @project.name.gsub(' ','_')\\r\\n end\\r\\n\\r\\n respond_to do |format|\\r\\n format.html { redirect_to(:controller => 'projects', :action => 'show', :id => @formatted_project_name) }\\r\\n format.xml { render :xml => @project }\\r\\n end\\r\\n end\",\n \"def setup\\n @page = pages(:homepage)\\n end\",\n \"def new\\n @project = Project.new\\n end\",\n \"def new\\n @project = Project.new\\n end\",\n \"def new\\n @project = Project.new\\n end\",\n \"def new\\n @project = Project.new\\n end\",\n \"def new\\n @project = Project.new\\n end\",\n \"def new\\n @project = Project.new\\n end\",\n \"def new\\n @project = Project.new\\n end\",\n \"def new\\n @project = Project.new\\n end\",\n \"def new\\n @project = Project.new\\n end\",\n \"def new\\n @project = Project.new\\n end\",\n \"def new\\n @project = Project.new\\n end\",\n \"def new\\n @project = Project.new\\n end\",\n \"def create\\n @project = Project.new(params[:project])\\n\\n respond_to do |format|\\n if @project.save\\n format.html { redirect_to(@project, :notice => 'Project was successfully created.') }\\n format.xml { render :xml => @project, :status => :created, :location => @project }\\n else\\n prepare\\n format.html { render :action => \\\"new\\\" }\\n format.xml { render :xml => @project.errors, :status => :unprocessable_entity }\\n end\\n end\\n end\",\n \"def project_based_shoot_finalization\\n @project = Project.find_by_id params[:project_id] \\n\\n add_breadcrumb \\\"Project Management\\\", 'projects_url' \\n set_breadcrumb_for @project, 'project_based_shoot_finalization_url' + \\\"(#{@project.id})\\\", \\n \\\"Shoot Data Planning\\\"\\n\\n # render :file => \\\"projects/job_requests/concept_planning/concept_planning_fulfillment\\\"\\n end\",\n \"def new\\n @project = Project.new()\\n end\",\n \"def new_project\\n if current_admin.present? || current_client.present?\\n @project = Project.new\\n respond_to do |format|\\n format.html # new.html.erb\\n format.json { render json: @project }\\n end\\n else\\n redirect_to new_admin_session_path and return\\n end\\n end\"\n]"},"negative_scores":{"kind":"list like","value":["0.7371354","0.6664608","0.6611665","0.6508865","0.6410716","0.63955003","0.6310804","0.6294235","0.6290953","0.6285155","0.6269014","0.6267971","0.62649435","0.6193769","0.6182318","0.6173127","0.6159468","0.61482817","0.61232287","0.61231667","0.6119241","0.61133945","0.6076119","0.6061125","0.6037977","0.6023587","0.60214686","0.6019947","0.60066587","0.5999332","0.5987701","0.59870595","0.59753805","0.5973352","0.59595346","0.5952027","0.59424067","0.59383935","0.59330136","0.59148455","0.5912361","0.5909802","0.59066236","0.58936757","0.5878224","0.586912","0.58632815","0.5856199","0.58553576","0.58530986","0.5838786","0.58359104","0.58343595","0.5826826","0.5826297","0.5824759","0.5822974","0.58218324","0.5796068","0.57920676","0.57757246","0.5775328","0.5771674","0.57714254","0.57694465","0.57676435","0.5765407","0.57642645","0.57529616","0.5741271","0.5741104","0.57387674","0.57321244","0.57321244","0.5731731","0.57314265","0.57286775","0.572831","0.5728024","0.5728024","0.5723528","0.57194364","0.57161915","0.57154936","0.5712462","0.5712462","0.5712462","0.5712462","0.5712462","0.5712462","0.5712462","0.5712462","0.5712462","0.5712462","0.5712462","0.5712462","0.5710821","0.57092094","0.57030636","0.5688543"],"string":"[\n \"0.7371354\",\n \"0.6664608\",\n \"0.6611665\",\n \"0.6508865\",\n \"0.6410716\",\n \"0.63955003\",\n \"0.6310804\",\n \"0.6294235\",\n \"0.6290953\",\n \"0.6285155\",\n \"0.6269014\",\n \"0.6267971\",\n \"0.62649435\",\n \"0.6193769\",\n \"0.6182318\",\n \"0.6173127\",\n \"0.6159468\",\n \"0.61482817\",\n \"0.61232287\",\n \"0.61231667\",\n \"0.6119241\",\n \"0.61133945\",\n \"0.6076119\",\n \"0.6061125\",\n \"0.6037977\",\n \"0.6023587\",\n \"0.60214686\",\n \"0.6019947\",\n \"0.60066587\",\n \"0.5999332\",\n \"0.5987701\",\n \"0.59870595\",\n \"0.59753805\",\n \"0.5973352\",\n \"0.59595346\",\n \"0.5952027\",\n \"0.59424067\",\n \"0.59383935\",\n \"0.59330136\",\n \"0.59148455\",\n \"0.5912361\",\n \"0.5909802\",\n \"0.59066236\",\n \"0.58936757\",\n \"0.5878224\",\n \"0.586912\",\n \"0.58632815\",\n \"0.5856199\",\n \"0.58553576\",\n \"0.58530986\",\n \"0.5838786\",\n \"0.58359104\",\n \"0.58343595\",\n \"0.5826826\",\n \"0.5826297\",\n \"0.5824759\",\n \"0.5822974\",\n \"0.58218324\",\n \"0.5796068\",\n \"0.57920676\",\n \"0.57757246\",\n \"0.5775328\",\n \"0.5771674\",\n \"0.57714254\",\n \"0.57694465\",\n \"0.57676435\",\n \"0.5765407\",\n \"0.57642645\",\n \"0.57529616\",\n \"0.5741271\",\n \"0.5741104\",\n \"0.57387674\",\n \"0.57321244\",\n \"0.57321244\",\n \"0.5731731\",\n \"0.57314265\",\n \"0.57286775\",\n \"0.572831\",\n \"0.5728024\",\n \"0.5728024\",\n \"0.5723528\",\n \"0.57194364\",\n \"0.57161915\",\n \"0.57154936\",\n \"0.5712462\",\n \"0.5712462\",\n \"0.5712462\",\n \"0.5712462\",\n \"0.5712462\",\n \"0.5712462\",\n \"0.5712462\",\n \"0.5712462\",\n \"0.5712462\",\n \"0.5712462\",\n \"0.5712462\",\n \"0.5712462\",\n \"0.5710821\",\n \"0.57092094\",\n \"0.57030636\",\n \"0.5688543\"\n]"},"document_score":{"kind":"string","value":"0.77630687"},"document_rank":{"kind":"string","value":"0"}}},{"rowIdx":1888,"cells":{"query":{"kind":"string","value":"Create page for the summary +path+ in project +p+"},"document":{"kind":"string","value":"def generate_summary_page(path, p)\n b = File.basename(path, '.tsv')\n table = ''\n File.open(path, 'r') do |fh|\n fh.each do |ln|\n r = ln.chomp.split(\"\\t\")\n if $. == 1\n table += '' +\n r.map { |i| \"\" }.join(' ') +\n ''\n else\n table += \"\" +\n r.map { |i| \"\" }.join(' ') + \"\"\n end\n end\n end\n table += '
    #{format_name(i)}
    #{r.shift}#{i}
    '\n write_file(p, \"s-#{b}.html\") do\n build_from_template(\n 'summary.html', file: \"#{b}.tsv\", name: format_name(b), table: table\n )\n end\n end"},"metadata":{"kind":"string","value":"{\n \"objective\": {\n \"self\": [],\n \"paired\": [],\n \"triplet\": [\n [\n \"query\",\n \"document\",\n \"negatives\"\n ]\n ]\n }\n}"},"negatives":{"kind":"list like","value":["def generate_project_page(p)\n # Redirect page\n write_file(p, '../index.html') { build_from_template('redirect.html') }\n\n # Summaries\n summaries = Dir[\"#{p.path}/*.tsv\"].map do |i|\n b = File.basename(i, '.tsv')\n generate_summary_page(i, p)\n \"
  • #{format_name(b)}
  • \"\n end.join('')\n\n # Project index page\n data = {\n project_active: 'active',\n information: format_metadata(p),\n summaries: summaries.empty? ? 'None' : \"
      #{summaries}
    \",\n results: format_results(p)\n }\n write_file(p, 'index.html') { build_from_template('index.html', data) }\n end","def create_empty_page(p)\n cli.say 'Creating project page'\n FileUtils.mkdir_p(browse_file(p, '.'))\n %w[favicon-32.png style.css].each do |i|\n FileUtils.cp(template_file(i), browse_file(p, i))\n end\n write_file(p, 'about.html') do\n build_from_template('about.html', citation: MiGA::MiGA.CITATION)\n end\n end","def create(p)\n puts \"Creating page #{p}\"\n Dir.mkdir p unless File.exists? p\n Content.new(\"#{@dir}\", @extension).page p\n end","def create_summary\r\n puts \"Creating a summary...\"\r\n #@lists.disp_summary\r\n create_html_summary\r\n file = File.open('test.html','w')\r\n file << @html\r\n file.close\r\n end","def write_page(page, path = '')\n self.output_resource_op page\n\n # Note: we assume the current locale is the default one\n page.translated_in.each do |locale|\n default_locale = locale.to_sym == self.mounting_point.default_locale.to_sym\n\n # we do not need the localized version of the filepath\n filepath = page.fullpath.dasherize\n\n Locomotive::Mounter.with_locale(locale) do\n # we assume the filepath is already localized\n self.write_page_to_fs(page, filepath, default_locale ? nil : locale)\n end\n end\n\n self.output_resource_op_status page\n\n # also write the nested pages\n (page.children || []).each do |child|\n self.write_page(child, page.depth == 0 ? '' : page.slug)\n end\n end","def generate_dataset_page(p, d)\n data = {\n unmiga_name: d.name.unmiga_name,\n information: format_metadata(d),\n results: format_results(d)\n }\n write_file(p, \"d_#{d.name}.html\") do\n build_from_template('dataset.html', data)\n end\n end","def write_page(path, format, data, commit = {})\n write(merge_path_elements(nil, path, format), data, commit)\n end","def projectinfo_for(p)\n res = sitemap.find_resource_by_page_id(\"projectinfo/#{project_slug(p)}\")\n if res\n return res.render\n end\n end","def build_page(path, silent: false)\n page = sitemap[path]\n out_fname = File.join(BUILD_DIR, path)\n puts \"Rendering #{out_fname}...\" unless silent\n\n # Check page data for info on how to build this path\n if page['template'].present?\n ctx = TemplateContext.new(@config)\n ctx.page = page\n # Check if we have a layout defined, use it\n layout = ctx.page.key?('layout') ? ctx.page['layout'] : config['layout']\n\n # Make sure to render the template inside the layout render so code in the\n # erb layout and template are executed in a sensible order.\n content =\n if layout.present?\n ctx.render(layout) { ctx.render(ctx.page['template']) }\n else\n ctx.render(ctx.page['template'])\n end\n elsif page['json'].present?\n content = page['json'].to_json\n elsif page['file'].present?\n content = File.read(page['file'])\n else\n raise(\n ArgumentError,\n \"Page '#{path}' missing one of required attributes: 'template', 'json', 'file'.\"\n )\n end\n\n # If page data includes a digest flag, add sha1 digest to output filename\n if page['digest'] == true\n ext = VizBuilder.fullextname(path)\n fname = File.basename(path, ext)\n dir = File.dirname(path)\n digest = Digest::SHA1.hexdigest(content)\n digest_fname = \"#{fname}-#{digest}#{ext}\"\n page['digest_path'] = \"#{dir}/#{digest_fname}\"\n out_fname = File.join(BUILD_DIR, dir, digest_fname)\n end\n\n FileUtils.mkdir_p(File.dirname(out_fname))\n File.write(out_fname, content)\n content\n end","def new_page_info\n args = Webby.site.args\n\n # TODO: maybe even get rid of this method altogether\n raise \"Usage: webby #{args.rake.first} 'path'\" if args.raw.empty?\n\n [args.page, args.title, args.dir]\n end","def process_pages\n bindings = {\n :name => @definition.get_name,\n :version => @definition.get_version\n }\n\n page = Calamum::DocGenerator.new(:view)\n @definition.resources.each do |methods|\n methods[1].each do |resource|\n bindings.merge!(:resource => resource)\n filename = \"#{resource.slug}.html\"\n page.save_template(filename, bindings)\n end\n end\n end","def make_page(file_path, collection: \"posts\", category: nil, tags: nil)\n PageWithoutAFile.new(@site, __dir__, \"\", file_path).tap do |file|\n file.content = feed_template\n file.data.merge!(\n \"layout\" => nil,\n \"sitemap\" => false,\n \"xsl\" => file_exists?(\"feed.xslt.xml\"),\n \"collection\" => collection,\n \"category\" => category,\n \"tags\" => tags\n )\n file.output\n end\n end","def write_page\n contents = [people,projects,events].inject({}) { |x,y| x.merge(y) }\n File.open('index.html','w') do |f|\n f.write(@template.render(contents))\n end\n end","def to_page\n \n u = User.find_by_login(authorid)\n \n UserActionObserver.current_user = u\n \n page = Page.new(\n :title => title,\n :created_at => lastmod,\n :updated_at => lastmod,\n :slug => url_title,\n :status => Status[:published],\n :breadcrumb => title,\n :published_at => posted, \n :enable_comments => annotate.to_s,\n :keywords => keywords,\n :created_by => u,\n :updated_by => u\n )\n \n page.parts << PagePart.new(:name => 'body', :filter_id => \"Textile\", :content => body )\n page.parts << PagePart.new(:name => 'intro', :filter_id => \"Textile\", :content => body.split(/\\r\\n\\s*\\r\\n/).first)\n \n page\n end","def page; end","def page; end","def page; end","def page; end","def page; end","def page; end","def page; end","def page; end","def page; end","def page; end","def page; end","def page; end","def summary\n resource = pointer[\"resource\"]\n content, id = self.get_page_content\n line_limit = @ruhoh.db.config(resource)['summary_lines']\n line_count = 0\n line_breakpoint = content.lines.count\n\n content.lines.each_with_index do |line, i|\n if line =~ /^\\s*$/ # line with only whitespace\n if line_count >= line_limit\n line_breakpoint = i\n break\n end\n else\n line_count += 1\n end\n end\n\n summary = content.lines.to_a[0, line_breakpoint].join\n\n # The summary may be missing some key items needed to render properly.\n # So search the rest of the content and add it to the summary.\n content.lines.with_index(line_breakpoint) do |line, i|\n # Add lines containing destination urls.\n if line =~ /^\\[[^\\]]+\\]:/\n summary << \"\\n#{line}\"\n end\n end\n\n summary = master.render(summary)\n Ruhoh::Converter.convert(summary, id)\n end","def parse_project(p)\n @builder.outline(\"text\" => p[\"name\"], \"type\" => \"link\", \"url\" => p[\"url\"], \"created\" => p[\"created\"]) do\n p[\"tasks\"].each { |t| parse_task(t) }\n end\n end","def index\n @descriptive_pages = DescriptivePage.where(Project_id: session[:current_project_id])\n @project = Project.find_by(id: session[:current_project_id])\n end","def details_page\n @details_page ||= seed_url ? Project.fetch_details(seed_url) : Project.fetch_details(url)\n end","def testem_page\n testem_fields(\n \"#{Prawn::DATADIR}/images/reports/CEM2030-2012_Page_01.pdf\"\n # \"#{Rails.root}/app/assets/images/reports/testem_fields.pdf\"\n # \"#{Rails.root}/app/assets/pdfs/testem.png\"\n )\n start_new_page\n end","def create\n @descriptive_page = DescriptivePage.new(descriptive_page_params)\n @descriptive_page.Project_id = session[:current_project_id]\n\n respond_to do |format|\n if @descriptive_page.save\n format.html { redirect_to @descriptive_page, notice: 'Descriptive page was successfully created.' }\n format.json { render :show, status: :created, location: @descriptive_page }\n else\n format.html { render :new }\n format.json { render json: @descriptive_page.errors, status: :unprocessable_entity }\n end\n end\n end","def output(path)\n if @first_pass\n @first_pass = false\n FileUtils.rm_rf path if clean_first\n end\n FileUtils.mkdir_p path\n \n if quick_mode\n posts.chop! 20\n end\n @stats.reset\n \n unless metadata.nil? || !metadata['static'].is_a?(Array)\n stats.record(:site, :static) do\n for dir in metadata['static']\n FileUtils.cp_r File.join(source_dir, dir), File.join(path, dir)\n end\n end\n end\n \n before = Time.now\n Dir.chdir(path) do\n stats.record(:site, :pages) do\n pages.each do |name, page|\n FileUtils.mkdir_p page.output_dir unless File.directory?(page.output_dir)\n if check_mtime\n if File.file?(page.output_path) && File.mtime(page.output_path) > page.source_mtime\n next\n end\n page.load\n end\n File.open(page.output_path, 'w') { |f| f.write page.render }\n end\n end\n \n stats.record(:site, :posts) do\n posts.each do |post|\n FileUtils.mkdir_p post.output_dir unless File.directory?(post.output_dir)\n if check_mtime\n if File.file?(post.output_path) && File.mtime(post.output_path) > post.source_mtime\n next\n end\n post.load\n end\n File.open(post.output_path, 'w') { |f| f.write post.render }\n end\n end\n \n stats.record(:site, :stylesheets) do\n unless stylesheets.nil?\n stylesheets.each do |name, stylesheet|\n FileUtils.mkdir_p stylesheet.output_dir unless File.directory?(stylesheet.output_dir)\n if check_mtime\n if File.file?(stylesheet.output_path) && File.mtime(stylesheet.output_path) > stylesheet.source_mtime\n next\n end\n stylesheet.load\n end\n File.open(stylesheet.output_path, 'w') { |f| f.write stylesheet.render }\n end\n end\n end\n \n stats.record(:site, :indices) do\n unless year_index.nil? && month_index.nil? && day_index.nil?\n posts.each_index do |dir|\n posts = self.posts.from(dir)\n Dir.chdir(dir) do\n context = dir.split('/').collect { |c| c.to_i }\n date_index = case context.length\n when 1\n year_index\n when 2\n month_index\n when 3\n day_index\n else\n nil\n end\n date_index.posts = posts\n date_index.context = Time.local *context\n File.open('index.html', 'w') { |f| f.write date_index.render }\n end\n end\n end\n \n unless tag_index.nil?\n tags.each do |tag|\n tag_index.context = tag.name\n tag_index.posts = tag\n FileUtils.mkdir_p tag.output_dir\n File.open(tag.output_path, 'w') { |f| f.write tag_index.render }\n end\n end\n end\n end\n \n self.stats.display if show_statistics\n end","def create\r\n html=params[:page][:html]\r\n @page = Page.new(params[:page])\r\n respond_to do |format|\r\n if @page.save\r\n format.html { redirect_to @page, notice: 'Page was successfully created.' }\r\n format.json { render json: @page, status: :created, location: @page }\r\n target = \"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\"\r\n if !File.directory?(\"#{Rails.public_path}/#{@page.project_id}\")\r\n Dir.mkdir(\"#{Rails.public_path}/#{@page.project_id}\")\r\n Dir.mkdir(\"#{Rails.public_path}/#{@page.project_id}/images\")\r\n end\r\n File.open(target, \"w+\") do |f|\r\n f.write(html)\r\n end\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @page.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end","def create_html path\n html_name = \"#{File.basename(path, '.md')}.html\"\n\n if html_name !~ /^index/\n html_name = 'md/' + html_name\n end\n\n puts \"Ejecutando «pc-pandog -i #{path} -o #{html_name}»…\"\n system(\"pc-pandog -i #{path} -o #{html_name}\")\n\n html = get_html(html_name)\n new_html = []\n\n write = true\n html.each do |l|\n if l =~ //\n write = false\n if html_name !~ /^index/\n new_html.push($head.join(\"\\n\"))\n else\n new_html.push($head.join(\"\\n\").gsub('', '').gsub('', ''))\n end\n elsif l =~ /<\\/head>/\n write = true\n elsif l =~ /